调整代码
This commit is contained in:
+11
-19
@@ -1,9 +1,9 @@
|
||||
import logging
|
||||
import requests
|
||||
import lz4.block as lb
|
||||
from typing import Dict, Any, List, Optional, Tuple
|
||||
|
||||
|
||||
from gewechat.client import gewe_client
|
||||
from gewechat.response.gewe_resp import GeweResponse
|
||||
from plugin_common.message_plugin_interface import MessagePluginInterface
|
||||
from plugin_common.plugin_interface import PluginStatus
|
||||
from utils.decorator.plugin_decorators import plugin_stats_decorator
|
||||
@@ -93,7 +93,7 @@ class MusicPlugin(MessagePluginInterface):
|
||||
# 检查命令格式
|
||||
if len(content.split(" ")) == 1:
|
||||
self.message_util.send_text(f"❌命令格式错误!\n{self.command_format}",
|
||||
(roomid if roomid else sender), sender)
|
||||
(roomid if roomid else sender), sender)
|
||||
return False, "命令格式错误"
|
||||
|
||||
# 检查权限
|
||||
@@ -108,11 +108,11 @@ class MusicPlugin(MessagePluginInterface):
|
||||
song_info = self._search_song(user_song_name)
|
||||
if not song_info or not song_info.get("play_url"):
|
||||
self.message_util.send_text(f"❌未找到歌曲:{user_song_name}",
|
||||
(roomid if roomid else sender), sender)
|
||||
(roomid if roomid else sender), sender)
|
||||
return False, "未找到歌曲"
|
||||
|
||||
# 发送音乐
|
||||
self._send_music_message(wcf, song_info, roomid or sender)
|
||||
self._send_music_message(song_info, roomid or sender)
|
||||
return True, "发送成功"
|
||||
|
||||
except Exception as e:
|
||||
@@ -143,7 +143,7 @@ class MusicPlugin(MessagePluginInterface):
|
||||
self.LOG.error(f"搜索歌曲出错: {e}")
|
||||
return {}
|
||||
|
||||
def _send_music_message(self, wcf, song_info: Dict[str, Any], receiver: str) -> bool:
|
||||
def _send_music_message(self, song_info: Dict[str, Any], receiver: str) -> bool:
|
||||
"""发送音乐消息"""
|
||||
try:
|
||||
song_name = song_info.get("song_name", "")
|
||||
@@ -201,19 +201,11 @@ class MusicPlugin(MessagePluginInterface):
|
||||
</appinfo>
|
||||
<commenturl />
|
||||
</msg>"""
|
||||
# # 修改消息数据库里面的消息content内容
|
||||
# text_bytes = xml_message.encode('utf-8')
|
||||
# compressed_data = lb.compress(text_bytes, store_size=False).hex()
|
||||
#
|
||||
# data = self.message_util.query_sql('MSG0.db', "SELECT * FROM MSG where type = 49 limit 1")
|
||||
# self.message_util.query_sql('MSG0.db',
|
||||
# f"""UPDATE MSG SET CompressContent = x'{compressed_data}', BytesExtra=x'', type=49, SubType=3,
|
||||
# IsSender=0, TalkerId=2 WHERE MsgSvrID={data[0]['MsgSvrID']}"""
|
||||
# )
|
||||
#
|
||||
# result = self.message_util.forward_msg(data[0]["MsgSvrID"], receiver)
|
||||
# self.LOG.info(f"插件化:点歌发送结果: {result}")
|
||||
return True
|
||||
resp = gewe_client.client.post_app_msg(gewe_client.client.app_id, receiver, xml_message)
|
||||
data = GeweResponse(resp)
|
||||
self.LOG.info(f"发送音乐消息:{data}")
|
||||
if data.is_success:
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
self.LOG.error(f"发送音乐消息出错: {e}")
|
||||
|
||||
Reference in New Issue
Block a user