斗鱼鱼吧订阅功能
This commit is contained in:
@@ -434,13 +434,17 @@ class DouyuPlugin(MessagePluginInterface):
|
||||
# 发现新动态
|
||||
nickname = target_feed.get("publisher", {}).get("nickname", "未知主播")
|
||||
content = target_feed.get("text", "")
|
||||
ctime = target_feed.get("ctime")
|
||||
from datetime import datetime
|
||||
publish_time = datetime.fromtimestamp(int(ctime)).strftime('%Y-%m-%d %H:%M:%S') if ctime else "未知时间"
|
||||
|
||||
# 限制内容长度
|
||||
if len(content) > 200:
|
||||
content = content[:200] + "..."
|
||||
|
||||
full_url = f"https://yuba.douyu.com/feed/{feed_id}"
|
||||
|
||||
await self._notify_groups_yuba(hash_id, nickname, content, full_url)
|
||||
await self._notify_groups_yuba(hash_id, nickname, content, full_url, publish_time)
|
||||
|
||||
# 保存标记
|
||||
self.redis_manager.set_yuba_last_id(hash_id, feed_id)
|
||||
@@ -452,9 +456,9 @@ class DouyuPlugin(MessagePluginInterface):
|
||||
except Exception as e:
|
||||
logger.error(f"斗鱼鱼吧定时任务异常: {e}")
|
||||
|
||||
async def _notify_groups_yuba(self, hash_id: str, nickname: str, content: str, url: str):
|
||||
async def _notify_groups_yuba(self, hash_id: str, nickname: str, content: str, url: str, publish_time: str = "未知时间"):
|
||||
groups = self.redis_manager.groups_for_yuba(hash_id)
|
||||
text = f"🌟 斗鱼鱼吧动态提醒 \n👤 主播:{nickname}\n📝 内容:{content}\n🔗 链接:{url}"
|
||||
text = f"🌟 斗鱼鱼吧动态提醒 \n👤 主播:{nickname}\n⏰ 时间:{publish_time}\n📝 内容:{content}\n🔗 链接:{url}"
|
||||
for gid in groups:
|
||||
if GroupBotManager.get_group_permission(gid, self.feature) == PermissionStatus.ENABLED:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user