临时调整权限模块,备份
This commit is contained in:
@@ -14,6 +14,10 @@ from .bot_ai import InterventionBot
|
||||
class AIAutoResponsePlugin(MessagePluginInterface):
|
||||
"""AI自动对话插件"""
|
||||
|
||||
# 功能权限常量
|
||||
FEATURE_KEY = "AI_AUTO_RESPONSE"
|
||||
FEATURE_DESCRIPTION = "🤖 AI自动对话功能 [自动对话]"
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return "AI自动对话"
|
||||
@@ -38,11 +42,21 @@ class AIAutoResponsePlugin(MessagePluginInterface):
|
||||
def commands(self) -> List[str]:
|
||||
return self._commands
|
||||
|
||||
@property
|
||||
def feature_key(self) -> Optional[str]:
|
||||
return self.FEATURE_KEY
|
||||
|
||||
@property
|
||||
def feature_description(self) -> Optional[str]:
|
||||
return self.FEATURE_DESCRIPTION
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.intervention_bot = None
|
||||
self.group_messages = {} # 存储每个群的最近消息
|
||||
self.max_messages = 20 # 每个群最多存储的消息数量
|
||||
# 注册功能权限
|
||||
self.feature = self.register_feature()
|
||||
|
||||
# DIFY API配置
|
||||
self.dify_api_url = ""
|
||||
@@ -89,7 +103,7 @@ class AIAutoResponsePlugin(MessagePluginInterface):
|
||||
content = str(message.get("content", "")).strip()
|
||||
roomid = message.get("roomid", "")
|
||||
|
||||
if GroupBotManager.get_group_permission(roomid, Feature.AI_AUTO) == PermissionStatus.DISABLED:
|
||||
if GroupBotManager.get_group_permission(roomid, self.feature) == PermissionStatus.DISABLED:
|
||||
return False
|
||||
# 如果是群消息,且该群启用了自动回复,则处理
|
||||
if roomid:
|
||||
@@ -133,7 +147,7 @@ class AIAutoResponsePlugin(MessagePluginInterface):
|
||||
roomid = message.get("roomid", "")
|
||||
bot: WechatAPIClient = message.get("bot")
|
||||
# 检查权限
|
||||
if roomid and GroupBotManager.get_group_permission(roomid, Feature.AI_AUTO) == PermissionStatus.DISABLED:
|
||||
if roomid and GroupBotManager.get_group_permission(roomid, self.feature) == PermissionStatus.DISABLED:
|
||||
return False, "没有权限"
|
||||
# 处理自动回复
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user