测试auth动态化
This commit is contained in:
@@ -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, "没有权限"
|
||||
|
||||
# 调用原始同步方法
|
||||
|
||||
@@ -27,6 +27,29 @@ class PermissionStatus(Enum):
|
||||
class Feature(Enum):
|
||||
"""功能权限枚举,带序号"""
|
||||
ROBOT = 1, "🔧 群机器人 [总开关]"
|
||||
# DAILY_NEWS = 2, "📰 每日新闻自动播报 [每日8:30定时发送]"
|
||||
# DAILY_SUMMARY = 3, "🕤 每日群发言总结 [每日9:30定时发送]"
|
||||
# AI_CAPABILITY = 4, "🤖 AI对话 [ai, 聊天, AI] 用法:ai 如何写一个机器人?"
|
||||
# SUMMARY_CAPABILITY = 5, "📝 群总结能力 [#总结]"
|
||||
# PDF_CAPABILITY = 6, "📄 sehuatang PDF能力 [无]"
|
||||
# EPIC = 7, "📊 EPIC自动播报 [每周五自动发送]" # 新增的功能
|
||||
# PIC = 8, "🖼️ 图来能力 [图来, 秀人]"
|
||||
# TASK_GAME = 9, "📚 百科答题 [/t, /s, /a 任务ID 答案]"
|
||||
# MUSIC = 10, "🎵 点歌功能 [点歌, 音乐, 音乐点播, 点播音乐, 音乐点歌]"
|
||||
# SIGNIN = 11, "✅ 签到功能 [签到, 每日签到, qd, Qd, QD, 上班, 牛马]"
|
||||
# POINT_TRADE = 12, "🎁 积分赠送 [积分赠送 1 @XX, 积分排行, 打劫 @XX, 保释 @XX]"
|
||||
# BEAUTY_LEG = 13, "🦵 腿来能力 [美腿, 腿来]"
|
||||
# VIDEO = 14, "🎥 黑丝视频 [黑丝视频, 黑丝, 来个黑丝, 搞个黑丝]"
|
||||
# VIDEO_MAN = 15, "💪 肌肉视频 [猛男, 肌肉, 帅哥]"
|
||||
# # GROUP_ADD = 16, "加群提醒"
|
||||
# DOUYIN_PARSER = 17, "🎥 抖音链接转视频"
|
||||
# GROUP_MEMBER_CHANGE = 18, "👥 群成员变更提醒 [自动触发]"
|
||||
# # KID_PHOTO_EXTRACT = 19, "儿童照片提取转发功能" # 小朋友照片提取功能
|
||||
# NEWS = 20, "🌍 全球政治经济新闻"
|
||||
# WEATHER = 21, "🌤️ 天气查询 [上海天气, 天气上海]"
|
||||
# JD_TOKEN = 22, "🔑 JD_京豆token设置 [设置京东 pt_key=xxx;pt_pin=xxx; 备注名称]"
|
||||
# AI_AUTO = 23, "💬 仿真对话"
|
||||
# GUESS_MUSIC = 24, "🎤 猜歌名游戏 [猜歌名 - 开始 | 猜歌名 歌手名 - 指定歌手 | 猜歌名 歌名 - 提交答案]"
|
||||
|
||||
def __new__(cls, value, description):
|
||||
obj = object.__new__(cls)
|
||||
|
||||
Reference in New Issue
Block a user