From e2441165c9e07c2f80568109545612a12b79c115 Mon Sep 17 00:00:00 2001 From: Rock Chin <1010553892@qq.com> Date: Sun, 1 Jan 2023 18:27:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A2=AB=E7=A6=81=E8=A8=80=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E5=A4=84=E7=90=86=E6=B6=88=E6=81=AF=20#62?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/qqbot/manager.py | 3 ++- pkg/qqbot/process.py | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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: