加入斗鱼开播下播提醒
This commit is contained in:
@@ -211,13 +211,19 @@ class DouyuPlugin(MessagePluginInterface):
|
|||||||
room_name = room_info.get("room_name", "")
|
room_name = room_info.get("room_name", "")
|
||||||
avatar = room_info.get("avatar", {}) or {}
|
avatar = room_info.get("avatar", {}) or {}
|
||||||
thumb_url = str(avatar.get("small", "") or "").strip().strip("`").strip()
|
thumb_url = str(avatar.get("small", "") or "").strip().strip("`").strip()
|
||||||
|
video_loop_raw = room_info.get("videoLoop", 0)
|
||||||
|
try:
|
||||||
|
video_loop = int(str(video_loop_raw))
|
||||||
|
except Exception:
|
||||||
|
video_loop = 0
|
||||||
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 and video_loop == 0 else False
|
||||||
status_obj = {
|
status_obj = {
|
||||||
"is_live": curr_live,
|
"is_live": curr_live,
|
||||||
"nickname": nickname,
|
"nickname": nickname,
|
||||||
"room_name": room_name
|
"room_name": room_name,
|
||||||
|
"is_loop": True if video_loop == 1 else False
|
||||||
}
|
}
|
||||||
self.redis_manager.set_room_status(room_id, status_obj)
|
self.redis_manager.set_room_status(room_id, status_obj)
|
||||||
if prev_live is None and curr_live is False:
|
if prev_live is None and curr_live is False:
|
||||||
@@ -229,7 +235,7 @@ class DouyuPlugin(MessagePluginInterface):
|
|||||||
await self._notify_groups_live(room_id, nickname, room_name, thumb_url)
|
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, video_loop == 1)
|
||||||
continue
|
continue
|
||||||
await asyncio.sleep(0.1)
|
await asyncio.sleep(0.1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -251,9 +257,11 @@ class DouyuPlugin(MessagePluginInterface):
|
|||||||
logger.error(f"发送斗鱼开播提醒失败: {e}")
|
logger.error(f"发送斗鱼开播提醒失败: {e}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
async def _notify_groups_offline(self, room_id: str, nickname: str, room_name: str):
|
async def _notify_groups_offline(self, room_id: str, nickname: str, room_name: str, is_loop: bool = False):
|
||||||
groups = self.redis_manager.groups_for_room(room_id)
|
groups = self.redis_manager.groups_for_room(room_id)
|
||||||
text = f"🔔 斗鱼提醒:{nickname} 下播啦~\n 🏷️ {room_name}"
|
text = f"🔔 斗鱼提醒:{nickname} 下播啦~\n 🏷️ {room_name}"
|
||||||
|
if is_loop:
|
||||||
|
text += "(当前为轮播)"
|
||||||
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:
|
||||||
|
|||||||
Reference in New Issue
Block a user