临时调整权限模块,备份
This commit is contained in:
@@ -18,6 +18,10 @@ from wechat_ipad import WechatAPIClient
|
||||
class XiurenImagePlugin(MessagePluginInterface):
|
||||
"""秀人图片插件"""
|
||||
|
||||
# 功能权限常量
|
||||
FEATURE_KEY = "XIUREN_IMAGE"
|
||||
FEATURE_DESCRIPTION = "🖼️ 秀人图片功能 [秀人]"
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return "秀人图片"
|
||||
@@ -42,10 +46,20 @@ class XiurenImagePlugin(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__()
|
||||
# 使用Path对象处理路径,自动适应不同操作系统
|
||||
self.image_folder = str(Path(Path(__file__).parent.parent.parent, "xiuren"))
|
||||
# 注册功能权限
|
||||
self.feature = self.register_feature()
|
||||
|
||||
def initialize(self, context: Dict[str, Any]) -> bool:
|
||||
"""初始化插件"""
|
||||
@@ -97,8 +111,8 @@ class XiurenImagePlugin(MessagePluginInterface):
|
||||
|
||||
return command in self._commands
|
||||
|
||||
@plugin_stats_decorator(plugin_name="秀人图片")
|
||||
@plugin_points_cost(9, "秀人图片消耗积分", Feature.PIC)
|
||||
@plugin_stats_decorator(plugin_name="秀人网图片")
|
||||
@plugin_points_cost(2, "秀人网图片消耗积分", FEATURE_KEY)
|
||||
async def process_message(self, message: Dict[str, Any]) -> Tuple[bool, Optional[str]]:
|
||||
"""处理消息"""
|
||||
content = str(message.get("content", "")).strip()
|
||||
@@ -109,7 +123,7 @@ class XiurenImagePlugin(MessagePluginInterface):
|
||||
bot: WechatAPIClient = message.get("bot")
|
||||
revoke: MessageAutoRevoke = message.get("revoke")
|
||||
# 检查权限
|
||||
if roomid and gbm.get_group_permission(roomid, Feature.PIC) == PermissionStatus.DISABLED:
|
||||
if roomid and gbm.get_group_permission(roomid, self.feature) == PermissionStatus.DISABLED:
|
||||
return False, "没有权限"
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user