From ca88e297248278031a9c7d439ec536790014297d Mon Sep 17 00:00:00 2001 From: Dodo <62124595+TogetsuDo@users.noreply.github.com> Date: Fri, 25 Oct 2024 16:19:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=BB=E5=8A=A8=E5=8F=91=E8=A8=80?= =?UTF-8?q?=E7=9A=84=E6=88=B3=E4=B8=80=E6=88=B3=E7=AE=80=E5=8D=95=E9=80=82?= =?UTF-8?q?=E9=85=8D=20(#123)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/repeater/__init__.py | 7 ++++++- src/plugins/repeater/model.py | 10 +++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/plugins/repeater/__init__.py b/src/plugins/repeater/__init__.py index 36979d9..b09de1e 100644 --- a/src/plugins/repeater/__init__.py +++ b/src/plugins/repeater/__init__.py @@ -272,7 +272,7 @@ async def speak_up(): if not ret: return - bot_id, group_id, messages = ret + bot_id, group_id, messages, target_id = ret for msg in messages: logger.info( @@ -282,6 +282,11 @@ async def speak_up(): 'message': msg, 'group_id': group_id }) + if target_id: + await get_bot(str(bot_id)).call_api('group_poke', **{ + 'user_id': target_id, + 'group_id': group_id + }) await asyncio.sleep(random.randint(2, 5)) diff --git a/src/plugins/repeater/model.py b/src/plugins/repeater/model.py index 873b1a2..21d3386 100644 --- a/src/plugins/repeater/model.py +++ b/src/plugins/repeater/model.py @@ -311,9 +311,9 @@ def reply_post_proc(raw_message: str, new_msg: str, bot_id: int, group_id: int) return False @ staticmethod - def speak() -> Optional[Tuple[int, int, List[Message]]]: + def speak() -> Optional[Tuple[int, int, List[Message], Optional[int]]]: ''' - 主动发言,返回当前最希望发言的 bot 账号、群号、发言消息 List,也有可能不发言 + 主动发言,返回当前最希望发言的 bot 账号、群号、发言消息 List、戳一戳目标,也有可能不发言 ''' basic_msgs_len = 10 @@ -426,13 +426,13 @@ def msg_filter(msg: Dict[str, Any]) -> bool: if not answer: break speak_list.extend(answer) - + + target_id = None if random.random() < Chat.SPEAK_POKE_PROBABILITY: target_id = random.choice( Chat._message_dict[group_id])['user_id'] - speak_list.append(Message('[CQ:poke,qq={}]'.format(target_id))) - return (bot_id, group_id, speak_list) + return (bot_id, group_id, speak_list, target_id) return None