测试auth动态化

This commit is contained in:
liuwei
2025-06-09 15:10:54 +08:00
parent 1fcabfd365
commit aaaf555156
10 changed files with 62 additions and 39 deletions

View File

@@ -13,14 +13,14 @@ from wechat_ipad import WechatAPIClient
def points_reward_decorator(points_calculator: Union[int, Callable], source_type: str = "other",
description: str = None, feature: Feature = None):
description: str = None, feature_key: str = None):
"""积分奖励装饰器
Args:
points_calculator: 积分数量或计算函数,如果是函数,接收(self, message, success, response)参数并返回积分数量
source_type: 积分来源类型 (checkin, game, other)
description: 积分奖励描述
feature: 功能权限枚举
feature_key: 功能权限键名
Returns:
装饰器函数
@@ -34,8 +34,10 @@ def points_reward_decorator(points_calculator: Union[int, Callable], source_type
bot: WechatAPIClient = message.get("bot")
revoke: MessageAutoRevoke = message.get("revoke")
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, "没有权限"
# 调用原始异步方法
@@ -106,8 +108,10 @@ def points_reward_decorator(points_calculator: Union[int, Callable], source_type
# 检查权限
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, "没有权限"
# 调用原始同步方法