临时调整权限模块,备份
This commit is contained in:
@@ -2,6 +2,7 @@ from typing import Dict, Any, List, Optional, Tuple
|
||||
|
||||
from base.plugin_common.message_plugin_interface import MessagePluginInterface
|
||||
from base.plugin_common.plugin_interface import PluginStatus
|
||||
from utils.robot_cmd.robot_command import GroupBotManager, PermissionStatus
|
||||
from utils.wechat.contact_manager import ContactManager
|
||||
from db.connection import DBConnectionManager
|
||||
from db.group_virtual_redis import GroupVirtualRedisDB
|
||||
@@ -12,6 +13,10 @@ from wechat_ipad.models.message import WxMessage
|
||||
class GroupVirtualPlugin(MessagePluginInterface):
|
||||
"""跨群聊天插件"""
|
||||
|
||||
# 功能权限常量
|
||||
FEATURE_KEY = "GROUP_VIRTUAL"
|
||||
FEATURE_DESCRIPTION = "🔄 跨群聊天功能 [自动转发群组间消息]"
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return "跨群聊天"
|
||||
@@ -36,11 +41,21 @@ class GroupVirtualPlugin(MessagePluginInterface):
|
||||
def commands(self) -> List[str]:
|
||||
return [] # 不处理任何命令
|
||||
|
||||
@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.data = None
|
||||
self.message_cache = set() # 用于防止消息循环转发
|
||||
self.group_virtual_redis = None
|
||||
# 注册功能权限
|
||||
self.feature = self.register_feature()
|
||||
|
||||
def initialize(self, context: Dict[str, Any]) -> bool:
|
||||
"""初始化插件"""
|
||||
@@ -79,8 +94,13 @@ class GroupVirtualPlugin(MessagePluginInterface):
|
||||
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
|
||||
|
||||
# 只处理群消息
|
||||
if not roomid:
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user