加入新闻链接信息,每次新闻发送三个链接
This commit is contained in:
16
robot.py
16
robot.py
@@ -31,6 +31,7 @@ from utils.sehuatang.shehuatang_undetected import pdf_file_path_undetected
|
||||
from utils.wechat.contact_manager import ContactManager
|
||||
from utils.wechat.message_to_db import MessageStorage
|
||||
from wechat_ipad import WechatAPIClient
|
||||
from wechat_ipad.models.appmsg_xml import LINK_XML_NEWS
|
||||
from wechat_ipad.models.message import WxMessage, MessageType
|
||||
|
||||
# 定义全局信号量,限制最大并发 10
|
||||
@@ -515,6 +516,19 @@ class Robot:
|
||||
except Exception as e:
|
||||
self.LOG.error(f"send_group_image_message:{feature.description} error:{e}")
|
||||
|
||||
async def send_group_xml_message(self, msg: str, feature: Feature):
|
||||
"""向所有启用了特定功能的群发送文本消息"""
|
||||
try:
|
||||
receivers = self.gbm.get_group_list()
|
||||
if not receivers:
|
||||
return
|
||||
|
||||
for r in receivers:
|
||||
if self.gbm.get_group_permission(r, feature) == PermissionStatus.ENABLED:
|
||||
await self.ipad_bot.send_link_message(r, msg)
|
||||
except Exception as e:
|
||||
self.LOG.error(f"send_group_xml_message:{feature.description} error:{e}")
|
||||
|
||||
async def send_group_file_message(self, path: str, feature: Feature):
|
||||
try:
|
||||
receivers = self.gbm.get_group_list()
|
||||
@@ -693,6 +707,8 @@ class Robot:
|
||||
await self.send_group_txt_message(news, Feature.DAILY_NEWS)
|
||||
path = News().get_news_60s()
|
||||
await self.send_group_image_message(path, Feature.DAILY_NEWS)
|
||||
|
||||
await self.send_group_xml_message(LINK_XML_NEWS, Feature.DAILY_NEWS)
|
||||
except Exception as e:
|
||||
self.LOG.error(f"newsBaiduReportAuto error:{e}")
|
||||
|
||||
|
||||
@@ -184,3 +184,52 @@ VIDEO_XML_MESSAGE = """
|
||||
</appinfo>
|
||||
<commenturl></commenturl>
|
||||
"""
|
||||
|
||||
|
||||
LINK_XML_NEWS = """
|
||||
<appmsg appid="" sdkver="1">
|
||||
<title>实时新闻热点</title>
|
||||
<des>点击查看实时新闻热点</des>
|
||||
<action>view</action>
|
||||
<type>5</type>
|
||||
<showtype>0</showtype>
|
||||
<content />
|
||||
<url>https://newsnow.busiyi.world/</url>
|
||||
<dataurl />
|
||||
<lowurl />
|
||||
<lowdataurl />
|
||||
<recorditem />
|
||||
<thumburl>https://wx.qlogo.cn/mmhead/ver_1/dhelVOGwHxiasCJI1…ibwpC1LtKOgnicETlWCx10G1iahWtTAGAfr6jX9oOcxMp/132</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>
|
||||
"""
|
||||
Reference in New Issue
Block a user