mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-21 21:58:04 +00:00
🐛 Fix error handler in callback query of error_callable
修复Bot在处理callback query的消息类型时回复的消息以和自动删除通知错误的问题
This commit is contained in:
parent
d5f8bf505a
commit
ba44956dd4
@ -41,6 +41,9 @@ async def send_user_notification(update: Update, context: CallbackContext, text:
|
|||||||
return None
|
return None
|
||||||
logger.info("尝试通知用户 %s[%s] 在 %s[%s] 的错误信息[%s]", user.full_name, user.id, chat.full_name, chat.id, text)
|
logger.info("尝试通知用户 %s[%s] 在 %s[%s] 的错误信息[%s]", user.full_name, user.id, chat.full_name, chat.id, text)
|
||||||
try:
|
try:
|
||||||
|
if update.callback_query:
|
||||||
|
await update.callback_query.answer(text, show_alert=True)
|
||||||
|
return None
|
||||||
return await message.reply_text(text, reply_markup=buttons, allow_sending_without_reply=True)
|
return await message.reply_text(text, reply_markup=buttons, allow_sending_without_reply=True)
|
||||||
except ConnectTimeout:
|
except ConnectTimeout:
|
||||||
logger.error("httpx 模块连接服务器 ConnectTimeout 发送 update_id[%s] 错误信息失败", update.update_id)
|
logger.error("httpx 模块连接服务器 ConnectTimeout 发送 update_id[%s] 错误信息失败", update.update_id)
|
||||||
@ -154,11 +157,10 @@ def error_callable(func: Callable) -> Callable:
|
|||||||
if text:
|
if text:
|
||||||
notice_message = await send_user_notification(update, context, text)
|
notice_message = await send_user_notification(update, context, text)
|
||||||
message = update.effective_message
|
message = update.effective_message
|
||||||
if message:
|
if message and not update.callback_query and filters.ChatType.GROUPS.filter(message):
|
||||||
if filters.ChatType.GROUPS.filter(message):
|
if notice_message:
|
||||||
if notice_message:
|
add_delete_message_job(context, notice_message.chat_id, notice_message.message_id, 60)
|
||||||
add_delete_message_job(context, notice_message.chat_id, notice_message.message_id, 60)
|
add_delete_message_job(context, message.chat_id, message.message_id, 60)
|
||||||
add_delete_message_job(context, message.chat_id, message.message_id, 60)
|
|
||||||
else:
|
else:
|
||||||
user = update.effective_user
|
user = update.effective_user
|
||||||
chat = update.effective_chat
|
chat = update.effective_chat
|
||||||
|
Loading…
Reference in New Issue
Block a user