临时调整权限模块,备份
This commit is contained in:
@@ -18,11 +18,15 @@ from .news_crawler import nbc, cnn, abc, fox, bbc
|
||||
|
||||
|
||||
class GlobalNewsPlugin(MessagePluginInterface):
|
||||
"""全球政治经济新闻插件"""
|
||||
"""全球新闻插件"""
|
||||
|
||||
# 功能权限常量
|
||||
FEATURE_KEY = "GLOBAL_NEWS"
|
||||
FEATURE_DESCRIPTION = "🌍 全球新闻功能 [全球新闻, 国际新闻, 环球新闻, 政经新闻]"
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return "全球政治经济新闻"
|
||||
return "全球新闻"
|
||||
|
||||
@property
|
||||
def version(self) -> str:
|
||||
@@ -30,7 +34,7 @@ class GlobalNewsPlugin(MessagePluginInterface):
|
||||
|
||||
@property
|
||||
def description(self) -> str:
|
||||
return "提供全球政治经济新闻,支持多个国际新闻源"
|
||||
return "提供全球政治经济新闻查询功能"
|
||||
|
||||
@property
|
||||
def author(self) -> str:
|
||||
@@ -44,11 +48,21 @@ class GlobalNewsPlugin(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.bot: WechatAPIClient = None
|
||||
self._news_tasks = {} # 存储正在进行的新闻抓取任务
|
||||
# 注册功能权限
|
||||
self.feature = self.register_feature()
|
||||
|
||||
def initialize(self, context: Dict[str, Any]) -> bool:
|
||||
"""初始化插件"""
|
||||
@@ -89,8 +103,8 @@ class GlobalNewsPlugin(MessagePluginInterface):
|
||||
|
||||
return command in self._commands
|
||||
|
||||
@plugin_stats_decorator(plugin_name="全球政治经济新闻")
|
||||
@plugin_points_cost(5, "全球新闻消耗积分", Feature.NEWS)
|
||||
@plugin_stats_decorator(plugin_name="全球新闻")
|
||||
@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()
|
||||
@@ -98,10 +112,10 @@ class GlobalNewsPlugin(MessagePluginInterface):
|
||||
sender = message.get("sender")
|
||||
roomid = message.get("roomid", "")
|
||||
gbm: GroupBotManager = message.get("gbm")
|
||||
self.bot: WechatAPIClient = message.get("bot")
|
||||
bot: WechatAPIClient = message.get("bot")
|
||||
|
||||
# 检查权限
|
||||
if roomid and gbm.get_group_permission(roomid, Feature.NEWS) == PermissionStatus.DISABLED:
|
||||
if roomid and gbm.get_group_permission(roomid, self.feature) == PermissionStatus.DISABLED:
|
||||
return False, "没有权限"
|
||||
|
||||
# 生成唯一任务ID
|
||||
|
||||
Reference in New Issue
Block a user