临时调整权限模块,备份
This commit is contained in:
@@ -14,6 +14,10 @@ from wechat_ipad import WechatAPIClient
|
||||
class WeatherPlugin(MessagePluginInterface):
|
||||
"""天气查询插件"""
|
||||
|
||||
# 功能权限常量
|
||||
FEATURE_KEY = "WEATHER"
|
||||
FEATURE_DESCRIPTION = "🌤️ 天气查询功能 [天气]"
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return "天气查询"
|
||||
@@ -38,9 +42,19 @@ class WeatherPlugin(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.plugin_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
# 注册功能权限
|
||||
self.feature = self.register_feature()
|
||||
|
||||
def initialize(self, context: Dict[str, Any]) -> bool:
|
||||
"""初始化插件"""
|
||||
@@ -88,17 +102,18 @@ class WeatherPlugin(MessagePluginInterface):
|
||||
return command in self._commands
|
||||
|
||||
@plugin_stats_decorator(plugin_name="天气查询")
|
||||
@plugin_points_cost(2, "天气查询消耗积分", Feature.WEATHER)
|
||||
@plugin_points_cost(1, "天气查询消耗积分", FEATURE_KEY)
|
||||
async def process_message(self, message: Dict[str, Any]) -> Tuple[bool, Optional[str]]:
|
||||
"""处理消息"""
|
||||
content = str(message.get("content", "")).strip()
|
||||
self.LOG.debug(f"插件执行: {self.name}:{content}")
|
||||
sender = message.get("sender")
|
||||
roomid = message.get("roomid", "")
|
||||
gbm: GroupBotManager = message.get("gbm")
|
||||
bot: WechatAPIClient = message.get("bot")
|
||||
|
||||
# 检查权限
|
||||
if roomid and GroupBotManager.get_group_permission(roomid, Feature.WEATHER) == PermissionStatus.DISABLED:
|
||||
if roomid and gbm.get_group_permission(roomid, self.feature) == PermissionStatus.DISABLED:
|
||||
return False, "没有权限"
|
||||
|
||||
# 处理消息内容 - 不再使用jieba分词
|
||||
|
||||
Reference in New Issue
Block a user