This commit is contained in:
jxxghp
2025-07-20 11:50:44 +08:00
parent 7f302c13c7
commit 215cc09c1f
2 changed files with 30 additions and 22 deletions
+3 -3
View File
@@ -188,8 +188,8 @@ class TelegramModule(_ModuleBase, _MessageBase[Telegram]):
)
return None
@staticmethod
def _handle_text_message(msg: dict, client_config: NotificationConf, client: Telegram) -> Optional[CommingMessage]:
def _handle_text_message(self, msg: dict,
client_config: NotificationConf, client: Telegram) -> Optional[CommingMessage]:
"""
处理普通文本消息
"""
@@ -204,7 +204,7 @@ class TelegramModule(_ModuleBase, _MessageBase[Telegram]):
f"userid={user_id}, username={user_name}, chat_id={chat_id}, text={text}")
# Clean bot mentions from text to ensure consistent processing
cleaned_text = TelegramModule._clean_bot_mention(text, client._bot_username if client else None)
cleaned_text = self._clean_bot_mention(text, client.bot_username if client else None)
# 检查权限
admin_users = client_config.config.get("TELEGRAM_ADMINS")
+10 -2
View File
@@ -113,8 +113,8 @@ class Telegram:
# 发送给主程序处理
RequestUtils(timeout=15).post_res(self._ds_url, json=callback_json)
except Exception as e:
logger.error(f"处理按钮回调失败:{str(e)}")
except Exception as err:
logger.error(f"处理按钮回调失败:{str(err)}")
_bot.answer_callback_query(call.id, "处理失败,请重试")
def run_polling():
@@ -131,6 +131,14 @@ class Telegram:
self._polling_thread.start()
logger.info("Telegram消息接收服务启动")
@property
def bot_username(self) -> Optional[str]:
"""
获取Bot用户名
:return: Bot用户名或None
"""
return self._bot_username
def _update_user_chat_mapping(self, userid: int, chat_id: int) -> None:
"""
更新用户与聊天的映射关系