优化消息XML内容,提取到静态文件里面。
This commit is contained in:
@@ -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"""
|
||||
<appmsg appid="" sdkver="1">
|
||||
<title>👏欢迎 {nickname} 加入群聊!🎉</title>
|
||||
<des>⌚时间:{now}</des>
|
||||
<action>view</action>
|
||||
<type>5</type>
|
||||
<showtype>0</showtype>
|
||||
<content />
|
||||
<url>https://hot.imsyy.top/#/</url>
|
||||
<dataurl />
|
||||
<lowurl />
|
||||
<lowdataurl />
|
||||
<recorditem />
|
||||
<thumburl>{head_url}</thumburl>
|
||||
<messageaction />
|
||||
<laninfo />
|
||||
<extinfo />
|
||||
<sourceusername />
|
||||
<sourcedisplayname />
|
||||
<commenturl />
|
||||
<appattach>
|
||||
<totallen>0</totallen>
|
||||
<attachid />
|
||||
<emoticonmd5 />
|
||||
<fileext />
|
||||
<aeskey />
|
||||
</appattach>
|
||||
<webviewshared>
|
||||
<publisherId />
|
||||
<publisherReqId>0</publisherReqId>
|
||||
</webviewshared>
|
||||
<weappinfo>
|
||||
<pagepath />
|
||||
<username />
|
||||
<appid />
|
||||
<appservicetype>0</appservicetype>
|
||||
</weappinfo>
|
||||
<websearch />
|
||||
</appmsg>
|
||||
<fromusername>Jyunere</fromusername>
|
||||
<scene>0</scene>
|
||||
<appinfo>
|
||||
<version>1</version>
|
||||
<appname></appname>
|
||||
</appinfo>
|
||||
<commenturl></commenturl>
|
||||
"""
|
||||
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, "无需执行"
|
||||
|
||||
@@ -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"""<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 />"""
|
||||
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)
|
||||
|
||||
95
wechat_ipad/models/appmsg_xml.py
Normal file
95
wechat_ipad/models/appmsg_xml.py
Normal file
@@ -0,0 +1,95 @@
|
||||
LINK_XML = """
|
||||
<appmsg appid="" sdkver="1">
|
||||
<title>👏欢迎 {nickname} 加入群聊!🎉</title>
|
||||
<des>⌚时间:{now}</des>
|
||||
<action>view</action>
|
||||
<type>5</type>
|
||||
<showtype>0</showtype>
|
||||
<content />
|
||||
<url>https://hot.imsyy.top/#/</url>
|
||||
<dataurl />
|
||||
<lowurl />
|
||||
<lowdataurl />
|
||||
<recorditem />
|
||||
<thumburl>{head_url}</thumburl>
|
||||
<messageaction />
|
||||
<laninfo />
|
||||
<extinfo />
|
||||
<sourceusername />
|
||||
<sourcedisplayname />
|
||||
<commenturl />
|
||||
<appattach>
|
||||
<totallen>0</totallen>
|
||||
<attachid />
|
||||
<emoticonmd5 />
|
||||
<fileext />
|
||||
<aeskey />
|
||||
</appattach>
|
||||
<webviewshared>
|
||||
<publisherId />
|
||||
<publisherReqId>0</publisherReqId>
|
||||
</webviewshared>
|
||||
<weappinfo>
|
||||
<pagepath />
|
||||
<username />
|
||||
<appid />
|
||||
<appservicetype>0</appservicetype>
|
||||
</weappinfo>
|
||||
<websearch />
|
||||
</appmsg>
|
||||
<fromusername>Jyunere</fromusername>
|
||||
<scene>0</scene>
|
||||
<appinfo>
|
||||
<version>1</version>
|
||||
<appname></appname>
|
||||
</appinfo>
|
||||
<commenturl></commenturl>
|
||||
"""
|
||||
|
||||
MUSIC_XML = """
|
||||
<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 />
|
||||
"""
|
||||
Reference in New Issue
Block a user