Skip to content

Commit

Permalink
fix: 主动发言的戳一戳简单适配 (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
TogetsuDo authored Oct 25, 2024
1 parent a86ed6e commit ca88e29
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/plugins/repeater/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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))


Expand Down
10 changes: 5 additions & 5 deletions src/plugins/repeater/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit ca88e29

Please sign in to comment.