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