feat: gate media downloads by group and retry douyu checks

This commit is contained in:
liuwei
2026-04-13 15:53:34 +08:00
parent d581b9650e
commit 7df4bd216f
4 changed files with 117 additions and 26 deletions

View File

@@ -19,6 +19,7 @@ from db.levels_db import LevelsDBOperator
from db.message_storage import MessageStorageDB
# 导入积分系统
from db.points_db import PointsDBOperator, PointSource
from utils.robot_cmd.robot_command import Feature, GroupBotManager, PermissionStatus
from utils.wechat.contact_manager import ContactManager
from wechat_ipad import WechatAPIClient
from wechat_ipad.models.message import WxMessage, MessageType
@@ -317,8 +318,22 @@ class MessageStorage:
batch_size: 每次处理多少条默认20条
"""
try:
enabled_groups = [
group_id
for group_id in GroupBotManager.local_cache.get("group_list", set())
if GroupBotManager.get_group_permission(group_id, Feature.MEDIA_DOWNLOAD) == PermissionStatus.ENABLED
]
if not enabled_groups:
logger.debug("媒体下载功能未在任何群启用,跳过本轮媒体处理")
return
# 查询未处理的图片/表情消息
pending_messages = self.message_db.get_pending_media_messages(minutes_ago, batch_size)
pending_messages = self.message_db.get_pending_media_messages(
minutes_ago,
batch_size,
group_ids=enabled_groups
)
if not pending_messages:
logger.debug(f"未发现待处理的媒体消息(最近{minutes_ago}分钟)")