diff --git a/pkg/qqbot/manager.py b/pkg/qqbot/manager.py index 67f8ee11..a301664f 100644 --- a/pkg/qqbot/manager.py +++ b/pkg/qqbot/manager.py @@ -112,7 +112,8 @@ class QQBotManager: def send(self, event, msg, check_quote=True): asyncio.run( - self.bot.send(event, msg, quote=True if hasattr(config, "quote_origin") and config.quote_origin and check_quote else False)) + self.bot.send(event, msg, quote=True if hasattr(config, + "quote_origin") and config.quote_origin and check_quote else False)) # 私聊消息处理 def on_person_message(self, event: MessageEvent): diff --git a/pkg/qqbot/process.py b/pkg/qqbot/process.py index 6cf3d94a..c82b9324 100644 --- a/pkg/qqbot/process.py +++ b/pkg/qqbot/process.py @@ -1,4 +1,5 @@ # 此模块提供了消息处理的具体逻辑的接口 +import asyncio import datetime import pkg.qqbot.manager as manager @@ -27,6 +28,14 @@ def process_message(launcher_type: str, launcher_id: int, text_message: str, mes reply = [] session_name = "{}_{}".format(launcher_type, launcher_id) + # 检查是否被禁言 + result = mgr.bot.member_info(target=launcher_id, member_id=mgr.bot.qq).get() + result = asyncio.run(result) + if result.mute_time_remaining > 0: + logging.info("机器人被禁言,跳过消息处理(group_{},剩余{}s)".format(launcher_id, + result.mute_time_remaining)) + return reply + pkg.openai.session.get_session(session_name).acquire_response_lock() try: