From a156eaeb989adfe59dcc73d0164eff279716609d Mon Sep 17 00:00:00 2001 From: liuwei Date: Thu, 5 Jun 2025 11:12:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B6=88=E6=81=AFXML?= =?UTF-8?q?=E5=86=85=E5=AE=B9=EF=BC=8C=E6=8F=90=E5=8F=96=E5=88=B0=E9=9D=99?= =?UTF-8?q?=E6=80=81=E6=96=87=E4=BB=B6=E9=87=8C=E9=9D=A2=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/group_member_change/main.py | 50 +-------------- plugins/music/main.py | 50 ++------------- wechat_ipad/models/appmsg_xml.py | 95 +++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 93 deletions(-) create mode 100644 wechat_ipad/models/appmsg_xml.py diff --git a/plugins/group_member_change/main.py b/plugins/group_member_change/main.py index bb736d3..7b6da90 100644 --- a/plugins/group_member_change/main.py +++ b/plugins/group_member_change/main.py @@ -10,6 +10,7 @@ from db.contacts_db import ContactsDBOperator from utils.robot_cmd.robot_command import Feature, PermissionStatus, GroupBotManager from utils.wechat.contact_manager import ContactManager from wechat_ipad import WechatAPIClient +from wechat_ipad.models.appmsg_xml import LINK_XML class GroupMemberChangePlugin(MessagePluginInterface): @@ -134,53 +135,8 @@ class GroupMemberChangePlugin(MessagePluginInterface): contact_db.save_chatroom_member_simple(roomid, member_details) except Exception as e: self.LOG.warning(f"新增群员信息失败: {e}") - xml_content = f""" - - 👏欢迎 {nickname} 加入群聊!🎉 - ⌚时间:{now} - view - 5 - 0 - - https://hot.imsyy.top/#/ - - - - - {head_url} - - - - - - - - 0 - - - - - - - - 0 - - - - - - 0 - - - - Jyunere - 0 - - 1 - - - - """ + xml_content = f"{LINK_XML}".format(nickname=nickname, now=now, head_url=head_url) + await bot.send_link_xml_message(xml_content, roomid) return True, "已发送进群欢迎语" return False, "无需执行" diff --git a/plugins/music/main.py b/plugins/music/main.py index aabc173..3644b57 100644 --- a/plugins/music/main.py +++ b/plugins/music/main.py @@ -13,6 +13,8 @@ from wechat_ipad import WechatAPIClient import aiohttp +from wechat_ipad.models.appmsg_xml import MUSIC_XML + class MusicPlugin(MessagePluginInterface): """音乐点播插件""" @@ -161,52 +163,8 @@ class MusicPlugin(MessagePluginInterface): 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 - 汽水音乐 - -""" + xml_message = f"{MUSIC_XML}".format(song_name=song_name, singer_name=singer_name, play_url=play_url, + data_url=data_url, singer_pic=singer_pic) self.LOG.info(f"发送音乐消息:{xml_message}") res = await bot.send_app_message(wxid=receiver, xml=xml_message, type=0) diff --git a/wechat_ipad/models/appmsg_xml.py b/wechat_ipad/models/appmsg_xml.py new file mode 100644 index 0000000..0976f0b --- /dev/null +++ b/wechat_ipad/models/appmsg_xml.py @@ -0,0 +1,95 @@ +LINK_XML = """ + + 👏欢迎 {nickname} 加入群聊!🎉 + ⌚时间:{now} + view + 5 + 0 + + https://hot.imsyy.top/#/ + + + + + {head_url} + + + + + + + + 0 + + + + + + + + 0 + + + + + + 0 + + + +Jyunere +0 + + 1 + + + +""" + +MUSIC_XML = """ + + {song_name} + {singer_name}-点击三角直接播放 + view + 3 + 0 + + {data_url} + {play_url} + + + + + + + + + + + + 0 + + + + + + + + 0 + + + + + + 0 + + + {singer_pic} + +0 + + 49 + 汽水音乐 + + +"""