diff --git a/plugins/guess_song/main.py b/plugins/guess_song/main.py
index 38f45ca..311079d 100644
--- a/plugins/guess_song/main.py
+++ b/plugins/guess_song/main.py
@@ -208,7 +208,10 @@ class GuessSongPlugin(MessagePluginInterface):
"song_name": song_info.get("song_name", ""),
"singer_name": song_info.get("singer_name", ""),
"start_time": time.time(),
- "hint_given": False
+ "hint_given": False,
+ "play_url": song_info.get("play_url"),
+ "singer_pic": song_info.get('cover', '') or song_info.get('cover', ''),
+ "data_url": song_info.get('link', '')
}
if self.redis_db:
@@ -263,7 +266,7 @@ class GuessSongPlugin(MessagePluginInterface):
# 删除游戏会话
if self.redis_db:
self.redis_db.delete_game_session(session_id)
-
+ await self._send_music_message(bot, game_data, session_id)
return True, "猜对了"
else:
# 答案错误
@@ -399,3 +402,67 @@ class GuessSongPlugin(MessagePluginInterface):
except Exception as e:
self.LOG.error(f"发送歌曲片段出错: {e}")
return False
+
+ async def _send_music_message(self, bot: WechatAPIClient, song_info: Dict[str, Any], receiver: str) -> bool:
+ """发送音乐消息"""
+ try:
+ song_name = song_info.get("song_name", "")
+ singer_name = song_info.get("singer_name", "")
+ play_url = song_info.get("play_url", "")
+ singer_pic = song_info.get("singer_pic", "")
+ data_url = song_info.get("data_url", "")
+
+ xml_message = f"""
+ {song_name}
+ {singer_name}-点击三角直接播放
+ view
+ 3
+ 0
+
+ {data_url}
+ {play_url}
+
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 0
+
+
+ {singer_pic}
+
+0
+
+ 49
+ 汽水音乐
+
+"""
+
+ self.LOG.info(f"发送音乐消息:{xml_message}")
+ res = await bot.send_app_message(wxid=receiver, xml=xml_message, type=0)
+ self.LOG.info(f"发送音乐消息 res:{res}")
+ return True
+
+ except Exception as e:
+ self.LOG.error(f"发送音乐消息出错: {e}")
+ return False