调整json格式存储link信息

This commit is contained in:
liuwei
2025-06-10 14:29:08 +08:00
parent 4286bb21a2
commit 1d61576ae7
6 changed files with 191 additions and 39 deletions

View File

@@ -1,16 +1,15 @@
import xml.etree.ElementTree as ET
from datetime import datetime
from typing import Dict, Any, List, Optional, Tuple
import xml.etree.ElementTree as ET
from base.plugin_common.message_plugin_interface import MessagePluginInterface
from base.plugin_common.plugin_interface import PluginStatus
from db.connection import DBConnectionManager
from db.contacts_db import ContactsDBOperator
from utils.robot_cmd.robot_command import Feature, PermissionStatus, GroupBotManager
from utils.robot_cmd.robot_command import PermissionStatus, GroupBotManager
from utils.wechat.contact_manager import ContactManager
from wechat_ipad import WechatAPIClient
from wechat_ipad.models.appmsg_xml import LINK_XML
from wechat_ipad.models.appmsg_xml import LINK_XML_WELCOME
class GroupMemberChangePlugin(MessagePluginInterface):
@@ -141,7 +140,7 @@ class GroupMemberChangePlugin(MessagePluginInterface):
contact_db.save_chatroom_member_simple(roomid, member_details)
except Exception as e:
self.LOG.warning(f"新增群员信息失败: {e}")
xml_content = f"{LINK_XML}".format(nickname=nickname, now=now, head_url=head_url)
xml_content = f"{LINK_XML_WELCOME}".format(nickname=nickname, now=now, head_url=head_url)
await bot.send_link_xml_message(xml_content, roomid)
return True, "已发送进群欢迎语"

View File

@@ -13,6 +13,7 @@ from utils.decorator.async_job import async_job
from utils.decorator.plugin_decorators import plugin_stats_decorator
from utils.robot_cmd.robot_command import PermissionStatus, GroupBotManager
from wechat_ipad import WechatAPIClient
from wechat_ipad.models.appmsg_xml import LINK_XML_NORMAL
class MessagePushTask(MessagePluginInterface):
@@ -174,7 +175,14 @@ class MessagePushTask(MessagePluginInterface):
# 发送链接消息
if content_link:
await self.bot.send_link_message(group_id, content_link)
# content_link json 读取内容
link_data = json.loads(content_link)
xml_content = f"{LINK_XML_NORMAL}".format(title=link_data.get('title', ''),
des=link_data.get('des', ''),
url=link_data.get('url', ''),
thumburl=link_data.get('thumburl', '')
)
await self.bot.send_link_xml_message(xml_content, group_id)
# # 发送小程序消息
# if content_miniprogram: