临时调整权限模块,备份

This commit is contained in:
liuwei
2025-06-09 14:12:31 +08:00
parent cedab1cefd
commit 9d15bf965b
30 changed files with 882 additions and 138 deletions

View File

@@ -16,6 +16,10 @@ from wechat_ipad.models.appmsg_xml import LINK_XML
class GroupMemberChangePlugin(MessagePluginInterface):
"""群成员变更监控插件"""
# 功能权限常量
FEATURE_KEY = "GROUP_MEMBER_CHANGE"
FEATURE_DESCRIPTION = "👥 群成员变更监控 [自动监控群成员变动并发送通知]"
@property
def name(self) -> str:
return "群成员变更监控"
@@ -46,6 +50,8 @@ class GroupMemberChangePlugin(MessagePluginInterface):
def __init__(self):
super().__init__()
# 注册功能权限
self.feature = self.register_feature()
def initialize(self, context: Dict[str, Any]) -> bool:
"""初始化插件"""
@@ -56,9 +62,15 @@ class GroupMemberChangePlugin(MessagePluginInterface):
def can_process(self, message: Dict[str, Any]) -> bool:
"""检查是否可以处理该消息"""
content = message.get("content")
if not content or "<sysmsg" not in content:
if not self.enable:
return False
content = str(message.get("content", "")).strip()
roomid = message.get("roomid", "")
if GroupBotManager.get_group_permission(roomid, self.feature) == PermissionStatus.DISABLED:
return False
return True
async def process_message(self, message: Dict[str, Any]) -> Tuple[bool, Optional[str]]:
@@ -74,7 +86,7 @@ class GroupMemberChangePlugin(MessagePluginInterface):
bot: WechatAPIClient = message.get("bot")
# 检查权限
if roomid and gbm.get_group_permission(roomid, Feature.GROUP_MEMBER_CHANGE) == PermissionStatus.DISABLED:
if roomid and gbm.get_group_permission(roomid, self.feature) == PermissionStatus.DISABLED:
return False, "没有权限"
xml_content = str(content).strip().replace("\n", "").replace("\t", "")
@@ -146,6 +158,14 @@ class GroupMemberChangePlugin(MessagePluginInterface):
"""插件支持的命令列表"""
return []
@property
def feature_key(self) -> Optional[str]:
return self.FEATURE_KEY
@property
def feature_description(self) -> Optional[str]:
return self.FEATURE_DESCRIPTION
def get_help(self) -> str:
"""获取插件帮助信息"""
return "群成员变更监控插件:自动监控群成员变动并发送通知。"