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