临时调整权限模块,备份
This commit is contained in:
@@ -177,13 +177,13 @@ def points_reward_decorator(points_calculator: Union[int, Callable], source_type
|
||||
return decorator
|
||||
|
||||
|
||||
def plugin_points_cost(points: int, description: str = None, feature: Feature = None):
|
||||
def plugin_points_cost(points: int, description: str = None, feature_key: str = None):
|
||||
"""插件积分消费装饰器
|
||||
|
||||
Args:
|
||||
points: 消费积分数量
|
||||
description: 积分消费描述
|
||||
feature: 功能权限枚举
|
||||
feature_key: 功能权限键名
|
||||
|
||||
Returns:
|
||||
装饰器函数
|
||||
@@ -195,8 +195,10 @@ def plugin_points_cost(points: int, description: str = None, feature: Feature =
|
||||
try:
|
||||
# 检查权限
|
||||
roomid = message.get("roomid", "")
|
||||
if feature and roomid:
|
||||
if GroupBotManager.get_group_permission(roomid, feature) == PermissionStatus.DISABLED:
|
||||
if feature_key and roomid:
|
||||
# 获取功能权限枚举
|
||||
feature = getattr(Feature, feature_key, None)
|
||||
if feature and GroupBotManager.get_group_permission(roomid, feature) == PermissionStatus.DISABLED:
|
||||
return False, "没有权限"
|
||||
|
||||
# 检查是否开启了积分获取功能
|
||||
@@ -271,16 +273,18 @@ def plugin_points_cost(points: int, description: str = None, feature: Feature =
|
||||
try:
|
||||
# 检查权限
|
||||
roomid = message.get("roomid", "")
|
||||
if feature and roomid:
|
||||
if GroupBotManager.get_group_permission(roomid, feature) == PermissionStatus.DISABLED:
|
||||
if feature_key and roomid:
|
||||
# 获取功能权限枚举
|
||||
feature = getattr(Feature, feature_key, None)
|
||||
if feature and GroupBotManager.get_group_permission(roomid, feature) == PermissionStatus.DISABLED:
|
||||
return False, "没有权限"
|
||||
|
||||
# 检查是否开启了积分获取功能
|
||||
if (GroupBotManager.get_group_permission(roomid,
|
||||
Feature.SIGNIN) == PermissionStatus.DISABLED
|
||||
and GroupBotManager.get_group_permission(
|
||||
roomid, Feature.TASK_GAME) == PermissionStatus.DISABLED):
|
||||
return func(self, message)
|
||||
# if (GroupBotManager.get_group_permission(roomid,
|
||||
# Feature.SIGNIN) == PermissionStatus.DISABLED
|
||||
# and GroupBotManager.get_group_permission(
|
||||
# roomid, Feature.TASK_GAME) == PermissionStatus.DISABLED):
|
||||
# return func(self, message)
|
||||
|
||||
# 获取消息信息
|
||||
sender = message.get("sender", "")
|
||||
|
||||
Reference in New Issue
Block a user