调整注解位置
This commit is contained in:
@@ -99,13 +99,17 @@ class GameTaskPlugin(MessagePluginInterface):
|
||||
|
||||
return command in self._commands
|
||||
|
||||
def calculate_reward_points(self, message: Dict[str, Any], success: bool, response: str) -> int:
|
||||
"""计算奖励积分"""
|
||||
def calculate_game_points(self, message: Dict[str, Any], success: bool, response: str) -> int:
|
||||
"""计算游戏积分"""
|
||||
if not success:
|
||||
return 0
|
||||
try:
|
||||
return int(response)
|
||||
except (TypeError, ValueError):
|
||||
return 0
|
||||
|
||||
@plugin_stats_decorator(plugin_name="百科问答")
|
||||
@points_reward_decorator(calculate_game_points, "game", "百科答题奖励")
|
||||
def process_message(self, message: Dict[str, Any]) -> Tuple[bool, Optional[str]]:
|
||||
"""处理消息"""
|
||||
content = str(message.get("content", "")).strip()
|
||||
@@ -133,8 +137,9 @@ class GameTaskPlugin(MessagePluginInterface):
|
||||
self._handle_get_task(sender, roomid)
|
||||
return True, "获取任务成功"
|
||||
elif command == "/a":
|
||||
# 修改这里,传入整个 message 对象
|
||||
points = self._handle_submit_answer(message)
|
||||
# 修改这里,不要直接传递 message 对象
|
||||
content = str(message.get("content", "")).strip()
|
||||
points = self._handle_submit_answer(content, sender, roomid)
|
||||
return True, str(points)
|
||||
elif command == "/r":
|
||||
self._handle_show_rank(sender, roomid)
|
||||
@@ -247,25 +252,9 @@ class GameTaskPlugin(MessagePluginInterface):
|
||||
sender
|
||||
)
|
||||
|
||||
|
||||
def calculate_game_points(self, message: Dict[str, Any], success: bool, response: str) -> int:
|
||||
"""计算游戏积分"""
|
||||
if not success:
|
||||
return 0
|
||||
try:
|
||||
return int(response)
|
||||
except (TypeError, ValueError):
|
||||
return 0
|
||||
|
||||
# 修复参数问题,确保方法签名与调用方式匹配
|
||||
@points_reward_decorator(calculate_game_points, "game", "百科答题奖励")
|
||||
def _handle_submit_answer(self, message: Dict[str, Any]) -> int:
|
||||
def _handle_submit_answer(self, content: str, sender: str, roomid: str) -> int:
|
||||
"""处理提交答案请求"""
|
||||
try:
|
||||
content = str(message.get("content", "")).strip()
|
||||
sender = message.get("sender")
|
||||
roomid = message.get("roomid", "")
|
||||
|
||||
parts = content.split(" ", 2)
|
||||
if len(parts) < 3:
|
||||
self.message_util.send_text_msg(
|
||||
|
||||
Reference in New Issue
Block a user