重大版本调整:gewechat兼容。
This commit is contained in:
@@ -3,7 +3,6 @@ import requests
|
||||
import lz4.block as lb
|
||||
from typing import Dict, Any, List, Optional, Tuple
|
||||
|
||||
from wcferry import Wcf
|
||||
|
||||
from plugin_common.message_plugin_interface import MessagePluginInterface
|
||||
from plugin_common.plugin_interface import PluginStatus
|
||||
@@ -48,7 +47,6 @@ class MusicPlugin(MessagePluginInterface):
|
||||
self.LOG.info(f"正在初始化 {self.name} 插件...")
|
||||
|
||||
# 保存上下文对象
|
||||
self.wcf = context.get("wcf")
|
||||
self.event_system = context.get("event_system")
|
||||
self.message_util = context.get("message_util")
|
||||
|
||||
@@ -90,12 +88,11 @@ class MusicPlugin(MessagePluginInterface):
|
||||
command = content.split(" ")[0]
|
||||
sender = message.get("sender")
|
||||
roomid = message.get("roomid", "")
|
||||
wcf: Wcf = message.get("wcf")
|
||||
gbm: GroupBotManager = message.get("gbm")
|
||||
|
||||
# 检查命令格式
|
||||
if len(content.split(" ")) == 1:
|
||||
wcf.send_text(f"❌命令格式错误!\n{self.command_format}",
|
||||
self.message_util.send_text(f"❌命令格式错误!\n{self.command_format}",
|
||||
(roomid if roomid else sender), sender)
|
||||
return False, "命令格式错误"
|
||||
|
||||
@@ -110,7 +107,7 @@ class MusicPlugin(MessagePluginInterface):
|
||||
# 搜索歌曲
|
||||
song_info = self._search_song(user_song_name)
|
||||
if not song_info or not song_info.get("play_url"):
|
||||
wcf.send_text(f"❌未找到歌曲:{user_song_name}",
|
||||
self.message_util.send_text(f"❌未找到歌曲:{user_song_name}",
|
||||
(roomid if roomid else sender), sender)
|
||||
return False, "未找到歌曲"
|
||||
|
||||
@@ -204,19 +201,18 @@ 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 = wcf.query_sql('MSG0.db', "SELECT * FROM MSG where type = 49 limit 1")
|
||||
wcf.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 = wcf.forward_msg(data[0]["MsgSvrID"], receiver)
|
||||
self.LOG.info(f"插件化:点歌发送结果: {result}")
|
||||
# # 修改消息数据库里面的消息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
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user