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