答对了就发正确的音乐卡片
This commit is contained in:
@@ -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"""<appmsg appid="wx904fb3ecf62c7dea" sdkver="0">
|
||||
<title>{song_name}</title>
|
||||
<des>{singer_name}-点击三角直接播放</des>
|
||||
<action>view</action>
|
||||
<type>3</type>
|
||||
<showtype>0</showtype>
|
||||
<content />
|
||||
<url>{data_url}</url>
|
||||
<dataurl>{play_url}</dataurl>
|
||||
<lowurl/>
|
||||
<lowdataurl/>
|
||||
<recorditem />
|
||||
<thumburl />
|
||||
<messageaction />
|
||||
<laninfo />
|
||||
<extinfo />
|
||||
<sourceusername />
|
||||
<sourcedisplayname />
|
||||
<commenturl />
|
||||
<appattach>
|
||||
<totallen>0</totallen>
|
||||
<attachid />
|
||||
<emoticonmd5></emoticonmd5>
|
||||
<fileext />
|
||||
<aeskey></aeskey>
|
||||
</appattach>
|
||||
<webviewshared>
|
||||
<publisherId />
|
||||
<publisherReqId>0</publisherReqId>
|
||||
</webviewshared>
|
||||
<weappinfo>
|
||||
<pagepath />
|
||||
<username />
|
||||
<appid />
|
||||
<appservicetype>0</appservicetype>
|
||||
</weappinfo>
|
||||
<websearch />
|
||||
<songalbumurl>{singer_pic}</songalbumurl>
|
||||
</appmsg>
|
||||
<scene>0</scene>
|
||||
<appinfo>
|
||||
<version>49</version>
|
||||
<appname>汽水音乐</appname>
|
||||
</appinfo>
|
||||
<commenturl />"""
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user