855 协议版本-调整完毕内容

This commit is contained in:
liuwei
2025-04-30 13:22:33 +08:00
parent 869bce8a18
commit 454d084715
88 changed files with 1565 additions and 7816 deletions

View File

@@ -1,4 +1,3 @@
import logging
from datetime import datetime
from typing import Dict, Any, List, Optional, Tuple
@@ -6,16 +5,16 @@ import xml.etree.ElementTree as ET
import dacite
from gewechat.client import gewe_client
from gewechat.response.model.group.chatroom_member_detail import ChatroomMemberDetail
from plugin_common.message_plugin_interface import MessagePluginInterface
from plugin_common.plugin_interface import PluginStatus
from utils.robot_cmd.robot_command import Feature, PermissionStatus, GroupBotManager
from message_util import MessageUtil # 导入消息工具类
from wechat_ipad import WechatAPIClient
class GroupMemberChangePlugin(MessagePluginInterface):
"""群成员变更监控插件"""
@property
def name(self) -> str:
return "群成员变更监控"
@@ -46,7 +45,6 @@ class GroupMemberChangePlugin(MessagePluginInterface):
def __init__(self):
super().__init__()
self.LOG = logging.getLogger(f"Plugin.{self.name}")
def initialize(self, context: Dict[str, Any]) -> bool:
"""初始化插件"""
@@ -58,7 +56,11 @@ class GroupMemberChangePlugin(MessagePluginInterface):
self.LOG.info(f"{self.name} 插件初始化完成")
return True
def process_message(self, message: Dict[str, Any]) -> Tuple[bool, Optional[str]]:
def can_process(self, message: Dict[str, Any]) -> bool:
"""检查是否可以处理该消息"""
return True
async def process_message(self, message: Dict[str, Any]) -> Tuple[bool, Optional[str]]:
"""处理接收到的消息"""
content = str(message.get("content", "")).strip()
@@ -67,6 +69,7 @@ class GroupMemberChangePlugin(MessagePluginInterface):
roomid = message.get("roomid", "")
gbm: GroupBotManager = message.get("gbm")
bot: WechatAPIClient = message.get("bot")
# 检查权限
if roomid and gbm.get_group_permission(roomid, Feature.GROUP_MEMBER_CHANGE) == PermissionStatus.DISABLED:
return False, "没有权限"
@@ -114,18 +117,18 @@ class GroupMemberChangePlugin(MessagePluginInterface):
wxid = member["wxid"]
nickname = member["nickname"]
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
# now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
member_wxids = [wxid]
profile: ChatroomMemberDetail = dacite.from_dict(ChatroomMemberDetail,
gewe_client.client.get_chatroom_member_detail(
gewe_client.client.app_id,
member_wxids))
if profile.ret == 200:
gewe_client.client.post_link(gewe_client.client.app_id, sender,
title=f"👏欢迎 {nickname} 加入群聊!🎉",
description=f"⌚时间:{now}\n",
url="https://hot.imsyy.top/#/",
thumb_url=profile.data[0].big_head_img_url)
await bot.send_at_message(roomid, f"👏欢迎 {nickname} 加入群聊!🎉", member_wxids)
# members = await bot.get_contract_detail(member_wxids, roomid)
# if members:
# gewe_client.client.post_link(gewe_client.client.app_id, sender,
# title=f"👏欢迎 {nickname} 加入群聊!🎉",
# description=f"⌚时间:{now}\n",
# url="https://hot.imsyy.top/#/",
# thumb_url=profile.data[0].big_head_img_url)
return True, "已发送进群欢迎语"
return False, "无需执行"