From 056d1537cb442cdb4472851fcf13de0701568da6 Mon Sep 17 00:00:00 2001 From: ChangingSelf Date: Thu, 13 Mar 2025 13:10:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9B=9E=E5=A4=8D=E9=9D=9E?= =?UTF-8?q?=E8=87=AA=E5=B7=B1=E7=9A=84=E6=88=B3=E4=B8=80=E6=88=B3=EF=BC=8C?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E8=AF=86=E5=88=AB=E6=8B=8D=E4=B8=80=E6=8B=8D?= =?UTF-8?q?=E7=AD=89=E6=96=87=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/chat/bot.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/plugins/chat/bot.py b/src/plugins/chat/bot.py index b90b3d0f3..7179f2573 100644 --- a/src/plugins/chat/bot.py +++ b/src/plugins/chat/bot.py @@ -53,10 +53,15 @@ class ChatBot: """处理收到的通知""" # 戳一戳通知 if isinstance(event, PokeNotifyEvent): + # 不处理其他人的戳戳 + if not event.is_tome(): + return + # 用户屏蔽,不区分私聊/群聊 if event.user_id in global_config.ban_user_id: return - reply_poke_probability = 1 # 回复戳一戳的概率 + + reply_poke_probability = 1 # 回复戳一戳的概率,如果要改可以在这里改,暂不提取到配置文件 if random() < reply_poke_probability: user_info = UserInfo( @@ -66,10 +71,15 @@ class ChatBot: platform="qq", ) group_info = GroupInfo(group_id=event.group_id, group_name=None, platform="qq") + + raw_message = "[戳了戳]你" + if info := event.raw_info: + raw_message = f"[{info[2]}]你" + message_cq = MessageRecvCQ( message_id=None, user_info=user_info, - raw_message=str("[戳了戳]你"), + raw_message=raw_message, group_info=group_info, reply_message=None, platform="qq", @@ -120,8 +130,13 @@ class ChatBot: # 用户屏蔽,不区分私聊/群聊 if event.user_id in global_config.ban_user_id: return - - if event.reply and hasattr(event.reply, 'sender') and hasattr(event.reply.sender, 'user_id') and event.reply.sender.user_id in global_config.ban_user_id: + + if ( + event.reply + and hasattr(event.reply, "sender") + and hasattr(event.reply.sender, "user_id") + and event.reply.sender.user_id in global_config.ban_user_id + ): logger.debug(f"跳过处理回复来自被ban用户 {event.reply.sender.user_id} 的消息") return # 处理私聊消息