加入斗鱼开播下播提醒
This commit is contained in:
@@ -203,6 +203,8 @@ class DouyuPlugin(MessagePluginInterface):
|
||||
show_status = room_info.get("show_status")
|
||||
nickname = room_info.get("nickname", "")
|
||||
room_name = room_info.get("room_name", "")
|
||||
avatar = room_info.get("avatar", {}) or {}
|
||||
thumb_url = str(avatar.get("small", "") or "").strip().strip("`").strip()
|
||||
prev = self.redis_manager.get_room_status(room_id) or {}
|
||||
prev_live = prev.get("is_live")
|
||||
curr_live = True if show_status == 1 else False
|
||||
@@ -215,10 +217,10 @@ class DouyuPlugin(MessagePluginInterface):
|
||||
if prev_live is None and curr_live is False:
|
||||
continue
|
||||
if prev_live is None and curr_live is True:
|
||||
await self._notify_groups_live(room_id, nickname, room_name)
|
||||
await self._notify_groups_live(room_id, nickname, room_name, thumb_url)
|
||||
continue
|
||||
if prev_live is False and curr_live is True:
|
||||
await self._notify_groups_live(room_id, nickname, room_name)
|
||||
await self._notify_groups_live(room_id, nickname, room_name, thumb_url)
|
||||
continue
|
||||
if prev_live is True and curr_live is False:
|
||||
await self._notify_groups_offline(room_id, nickname, room_name)
|
||||
@@ -230,10 +232,10 @@ class DouyuPlugin(MessagePluginInterface):
|
||||
except Exception as e:
|
||||
logger.error(f"斗鱼定时任务异常: {e}")
|
||||
|
||||
async def _notify_groups_live(self, room_id: str, nickname: str, room_name: str):
|
||||
async def _notify_groups_live(self, room_id: str, nickname: str, room_name: str, thumb_url: str):
|
||||
groups = self.redis_manager.groups_for_room(room_id)
|
||||
text = f"🚀 斗鱼开播通知 \n🎤 {nickname} 正在直播中!\n 📌 房间标题:{room_name} \n 👉 点击观看:https://www.douyu.com/{room_id}"
|
||||
xml_content = DOUYU_MESSAGE_XML.format(title=room_name, liver=nickname, roomid=room_id)
|
||||
xml_content = DOUYU_MESSAGE_XML.format(title=room_name, liver=nickname, roomid=room_id, thumburl=thumb_url)
|
||||
for gid in groups:
|
||||
if GroupBotManager.get_group_permission(gid, self.feature) == PermissionStatus.ENABLED:
|
||||
try:
|
||||
|
||||
@@ -242,7 +242,7 @@ LINK_XML_NEWS = """
|
||||
<commenturl></commenturl>
|
||||
"""
|
||||
|
||||
DOUYU_MESSAGE_XML ="""
|
||||
DOUYU_MESSAGE_XML = """
|
||||
<appmsg appid="wx6be84d532f192698" sdkver="0">
|
||||
<title>正在直播:{title},请点击观看</title>
|
||||
<des>主播: {liver} </des>
|
||||
@@ -273,7 +273,7 @@ DOUYU_MESSAGE_XML ="""
|
||||
<appattach></appattach>
|
||||
<extinfo />
|
||||
<androidsource>2</androidsource>
|
||||
<thumburl />
|
||||
<thumburl>{thumburl}</thumburl>
|
||||
<mediatagname />
|
||||
<messageaction><![CDATA[]]></messageaction>
|
||||
<messageext><![CDATA[]]></messageext>
|
||||
|
||||
Reference in New Issue
Block a user