测试auth动态化
This commit is contained in:
@@ -284,7 +284,7 @@ class GameTaskPlugin(MessagePluginInterface):
|
||||
sender
|
||||
)
|
||||
|
||||
@points_reward_decorator(calculate_game_points, "game", "百科答题奖励", Feature.TASK_GAME)
|
||||
@points_reward_decorator(calculate_game_points, "game", "百科答题奖励", FEATURE_KEY)
|
||||
async def _handle_submit_answer(self, message: Dict[str, Any]) -> Tuple[bool, Optional[str]]:
|
||||
"""处理提交答案请求"""
|
||||
try:
|
||||
|
||||
@@ -259,7 +259,7 @@ class GuessSongPlugin(MessagePluginInterface):
|
||||
await bot.send_text_message(session_id, f"❌开始猜歌游戏出错,请稍后重试", sender)
|
||||
return False, f"处理出错: {e}"
|
||||
|
||||
@points_reward_decorator(5, "game", "猜歌名游戏", Feature.GUESS_MUSIC)
|
||||
@points_reward_decorator(5, "game", "猜歌名游戏", FEATURE_KEY)
|
||||
async def _check_answer(self, message: Dict[str, Any]) -> Tuple[bool, str]:
|
||||
"""检查答案"""
|
||||
try:
|
||||
|
||||
@@ -154,7 +154,7 @@ class JDTokenPlugin(MessagePluginInterface):
|
||||
|
||||
# 功能权限常量
|
||||
FEATURE_KEY = "JD_TOKEN"
|
||||
FEATURE_DESCRIPTION = "🔑 京东签到Token设置 [设置京东]"
|
||||
FEATURE_DESCRIPTION = "JD_京豆token设置 [设置京东 pt_key=xxx;pt_pin=xxx; 备注名称]"
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
|
||||
@@ -1,26 +1,29 @@
|
||||
import os
|
||||
import random
|
||||
from datetime import datetime, timedelta
|
||||
from loguru import logger
|
||||
import pytz
|
||||
from typing import Dict, Any, List, Optional, Tuple
|
||||
|
||||
from db.connection import DBConnectionManager
|
||||
import pytz
|
||||
from loguru import logger
|
||||
|
||||
from base.plugin_common.message_plugin_interface import MessagePluginInterface
|
||||
from base.plugin_common.plugin_interface import PluginStatus
|
||||
from utils.decorator.plugin_decorators import plugin_stats_decorator
|
||||
from utils.revoke.message_auto_revoke import MessageAutoRevoke
|
||||
from utils.robot_cmd.robot_command import Feature, PermissionStatus, GroupBotManager
|
||||
from db.connection import DBConnectionManager
|
||||
from db.sign_in import SignInDB
|
||||
from db.sign_in_redis import SignInRedisDB
|
||||
import random
|
||||
import os
|
||||
|
||||
from utils.decorator.plugin_decorators import plugin_stats_decorator
|
||||
from utils.decorator.points_decorator import points_reward_decorator
|
||||
from utils.revoke.message_auto_revoke import MessageAutoRevoke
|
||||
from utils.robot_cmd.robot_command import PermissionStatus, GroupBotManager
|
||||
from wechat_ipad import WechatAPIClient
|
||||
|
||||
|
||||
class MessageSignPlugin(MessagePluginInterface):
|
||||
"""签到插件"""
|
||||
|
||||
# 功能权限常量
|
||||
FEATURE_KEY = "SIGN_IN"
|
||||
FEATURE_DESCRIPTION = "✅ 签到功能 [签到, 每日签到, qd, Qd, QD, 上班, 牛马]"
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return "签到系统"
|
||||
@@ -207,7 +210,7 @@ class MessageSignPlugin(MessagePluginInterface):
|
||||
self.bot = message.get("bot")
|
||||
|
||||
# 检查权限
|
||||
if roomid and gbm.get_group_permission(roomid, Feature.SIGNIN) == PermissionStatus.DISABLED:
|
||||
if roomid and gbm.get_group_permission(roomid, self.feature) == PermissionStatus.DISABLED:
|
||||
return False, "没有权限"
|
||||
|
||||
# 处理补签命令
|
||||
@@ -221,7 +224,7 @@ class MessageSignPlugin(MessagePluginInterface):
|
||||
return False, "不支持的命令"
|
||||
|
||||
# 添加签到处理方法,应用积分奖励装饰器
|
||||
@points_reward_decorator(calculate_sign_in_points, "checkin", "每日签到奖励", Feature.SIGNIN)
|
||||
@points_reward_decorator(calculate_sign_in_points, "checkin", "每日签到奖励", FEATURE_KEY)
|
||||
async def _handle_sign_in(self, message: Dict[str, Any]) -> Tuple[bool, Optional[str]]:
|
||||
"""处理签到请求"""
|
||||
sender = message.get("sender")
|
||||
|
||||
@@ -19,6 +19,10 @@ from wechat_ipad.models.appmsg_xml import MUSIC_XML
|
||||
class MusicPlugin(MessagePluginInterface):
|
||||
"""音乐点播插件"""
|
||||
|
||||
# 功能权限常量
|
||||
FEATURE_KEY = "MUSIC"
|
||||
FEATURE_DESCRIPTION = "🎵 点歌功能 [点歌, 音乐, 音乐点播, 点播音乐, 音乐点歌]"
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return "音乐点播"
|
||||
@@ -45,6 +49,7 @@ class MusicPlugin(MessagePluginInterface):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.feature = self.register_feature()
|
||||
|
||||
def initialize(self, context: Dict[str, Any]) -> bool:
|
||||
"""初始化插件"""
|
||||
@@ -84,7 +89,7 @@ class MusicPlugin(MessagePluginInterface):
|
||||
return command in self._commands
|
||||
|
||||
@plugin_stats_decorator(plugin_name="音乐点播")
|
||||
@plugin_points_cost(2, "音乐点播消耗积分", Feature.MUSIC)
|
||||
@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()
|
||||
@@ -102,7 +107,7 @@ class MusicPlugin(MessagePluginInterface):
|
||||
return False, "命令格式错误"
|
||||
|
||||
# 检查权限
|
||||
if roomid and gbm.get_group_permission(roomid, Feature.MUSIC) == PermissionStatus.DISABLED:
|
||||
if roomid and gbm.get_group_permission(roomid, self.feature) == PermissionStatus.DISABLED:
|
||||
return False, "没有权限"
|
||||
|
||||
# 提取歌曲名
|
||||
|
||||
@@ -13,18 +13,6 @@ from db.connection import DBConnectionManager
|
||||
class StatsCollectorPlugin(PluginInterface):
|
||||
"""统计收集插件"""
|
||||
|
||||
# 功能权限常量
|
||||
FEATURE_KEY = "STATS_COLLECTOR"
|
||||
FEATURE_DESCRIPTION = "📊 指令记录功能 [自动记录指令使用情况]"
|
||||
|
||||
@property
|
||||
def feature_key(self) -> Optional[str]:
|
||||
return self.FEATURE_KEY
|
||||
|
||||
@property
|
||||
def feature_description(self) -> Optional[str]:
|
||||
return self.FEATURE_DESCRIPTION
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return "指令记录"
|
||||
@@ -63,7 +51,6 @@ class StatsCollectorPlugin(PluginInterface):
|
||||
self.db_manager = DBConnectionManager.get_instance()
|
||||
self.stats_db = StatsDBOperator(self.db_manager)
|
||||
# 注册功能权限
|
||||
self.feature = self.register_feature()
|
||||
|
||||
def initialize(self, config: Dict[str, Any]) -> bool:
|
||||
"""初始化插件"""
|
||||
|
||||
@@ -57,6 +57,7 @@ class VideoPlugin(MessagePluginInterface):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.bot: WechatAPIClient = None
|
||||
self.feature = self.register_feature()
|
||||
# 使用Path对象处理路径,自动适应不同操作系统
|
||||
self.download_dir = str(Path(Path(__file__).parent, "down_load_dir"))
|
||||
|
||||
@@ -112,7 +113,7 @@ class VideoPlugin(MessagePluginInterface):
|
||||
return command in self._commands
|
||||
|
||||
@plugin_stats_decorator(plugin_name="视频插件")
|
||||
@plugin_points_cost(2, "视频插件消耗积分", Feature.VIDEO)
|
||||
@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()
|
||||
@@ -123,7 +124,7 @@ class VideoPlugin(MessagePluginInterface):
|
||||
self.bot: WechatAPIClient = message.get("bot")
|
||||
|
||||
# 检查权限
|
||||
if roomid and gbm.get_group_permission(roomid, Feature.VIDEO) == PermissionStatus.DISABLED:
|
||||
if roomid and gbm.get_group_permission(roomid, self.feature) == PermissionStatus.DISABLED:
|
||||
return False, "没有权限"
|
||||
|
||||
try:
|
||||
|
||||
@@ -13,7 +13,7 @@ from base.plugin_common.plugin_interface import PluginStatus
|
||||
from utils.decorator.plugin_decorators import plugin_stats_decorator
|
||||
from utils.decorator.points_decorator import plugin_points_cost
|
||||
from utils.robot_cmd.robot_command import Feature, PermissionStatus, GroupBotManager
|
||||
from base.wechat_api.wechat_api_client import WechatAPIClient
|
||||
from wechat_ipad import WechatAPIClient
|
||||
|
||||
|
||||
class VideoManPlugin(MessagePluginInterface):
|
||||
@@ -21,7 +21,7 @@ class VideoManPlugin(MessagePluginInterface):
|
||||
|
||||
# 功能权限常量
|
||||
FEATURE_KEY = "VIDEO_MAN"
|
||||
FEATURE_DESCRIPTION = "💪 猛男视频功能 [猛男视频, 猛男, 来个猛男, 搞个猛男]"
|
||||
FEATURE_DESCRIPTION = "💪 肌肉视频 [猛男, 肌肉, 帅哥]"
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
|
||||
Reference in New Issue
Block a user