恢复猜歌名功能

This commit is contained in:
liuwei
2025-06-10 08:44:06 +08:00
parent e1bdd9c76b
commit bc66fa731f

View File

@@ -181,24 +181,35 @@ class GuessSongPlugin(MessagePluginInterface):
return command in self._commands
@plugin_stats_decorator(plugin_name="猜歌名")
@plugin_points_cost(2, "猜歌名消耗积分", FEATURE_KEY)
@plugin_stats_decorator(plugin_name="猜歌名游戏")
async def process_message(self, message: Dict[str, Any]) -> Tuple[bool, Optional[str]]:
"""处理消息"""
content = str(message.get("content", "")).strip()
self.LOG.debug(f"插件执行: {self.name}{content}")
# 简化命令处理,只检查开头是否包含命令前缀
command_found = False
for cmd in self._commands:
if content.startswith(cmd):
command_found = True
content = content[len(cmd):].strip()
break
if not command_found:
return False, "不匹配的命令"
sender = message.get("sender")
roomid = message.get("roomid", "")
gbm: GroupBotManager = message.get("gbm")
bot: WechatAPIClient = message.get("bot")
# 使用roomid或sender作为游戏会话ID
session_id = roomid if roomid else sender
# 检查权限
if roomid and gbm.get_group_permission(roomid, self.feature) == PermissionStatus.DISABLED:
return False, "没有权限"
# 使用roomid或sender作为游戏会话ID
session_id = roomid if roomid else sender
# 获取当前游戏会话
current_game = None
if self.redis_db: