mirror of
https://github.com/Nezumi-2711/astrbot_plugin_qq_group_daily_analysis.git
synced 2026-09-22 13:38:43 +00:00
fix: 修复TG分页取数与话题白名单匹配
This commit is contained in:
@@ -97,7 +97,9 @@ class QQGroupDailyAnalysis(Star):
|
||||
"""解析报告模板目录(兼容新旧目录结构)"""
|
||||
plugin_root = os.path.dirname(__file__)
|
||||
candidate_dirs = [
|
||||
os.path.join(plugin_root, "src", "infrastructure", "reporting", "templates"),
|
||||
os.path.join(
|
||||
plugin_root, "src", "infrastructure", "reporting", "templates"
|
||||
),
|
||||
os.path.join(plugin_root, "src", "reports", "templates"),
|
||||
]
|
||||
for candidate in candidate_dirs:
|
||||
@@ -112,7 +114,9 @@ class QQGroupDailyAnalysis(Star):
|
||||
candidate_paths = [
|
||||
os.path.join(plugin_root, "assets", f"{template_name}-demo.jpg"),
|
||||
os.path.join(plugin_root, "assets", f"{template_name}.jpg"),
|
||||
os.path.join(plugin_root, "assets", "templates", f"{template_name}-demo.jpg"),
|
||||
os.path.join(
|
||||
plugin_root, "assets", "templates", f"{template_name}-demo.jpg"
|
||||
),
|
||||
os.path.join(plugin_root, "assets", "templates", f"{template_name}.jpg"),
|
||||
os.path.join(template_base_dir, template_name, "demo.jpg"),
|
||||
os.path.join(template_base_dir, template_name, "preview.jpg"),
|
||||
@@ -428,14 +432,18 @@ class QQGroupDailyAnalysis(Star):
|
||||
platform_map = platforms.get(str(platform_id).strip(), {})
|
||||
if isinstance(platform_map, dict):
|
||||
groups.update(
|
||||
str(gid).strip() for gid in platform_map.keys() if str(gid).strip()
|
||||
str(gid).strip()
|
||||
for gid in platform_map.keys()
|
||||
if str(gid).strip()
|
||||
)
|
||||
else:
|
||||
for platform_map in platforms.values():
|
||||
if not isinstance(platform_map, dict):
|
||||
continue
|
||||
groups.update(
|
||||
str(gid).strip() for gid in platform_map.keys() if str(gid).strip()
|
||||
str(gid).strip()
|
||||
for gid in platform_map.keys()
|
||||
if str(gid).strip()
|
||||
)
|
||||
|
||||
sorted_groups = sorted(groups)
|
||||
|
||||
@@ -68,15 +68,37 @@ class ConfigManager:
|
||||
else target_simple_id
|
||||
)
|
||||
|
||||
def _is_match(item: str, target: str, target_simple_id: str) -> bool:
|
||||
def _is_match(
|
||||
item: str,
|
||||
target: str,
|
||||
target_simple_id: str,
|
||||
target_parent_id: str,
|
||||
) -> bool:
|
||||
if ":" in item:
|
||||
return item == target
|
||||
if item == target:
|
||||
return True
|
||||
|
||||
# 允许 Telegram 话题会话通过“父 UMO”命中,
|
||||
# 例如: item=telegram2:GroupMessage:-1001
|
||||
# target=telegram2:GroupMessage:-1001#2264
|
||||
if "#" in target_simple_id:
|
||||
if ":" not in target:
|
||||
return False
|
||||
item_prefix, item_tail = item.rsplit(":", 1)
|
||||
target_prefix, _ = target.rsplit(":", 1)
|
||||
return (
|
||||
item_prefix == target_prefix and item_tail == target_parent_id
|
||||
)
|
||||
return False
|
||||
if item == target_simple_id:
|
||||
return True
|
||||
# 允许 Telegram 话题会话通过父群 ID 命中简单群号白/黑名单
|
||||
return "#" in target_simple_id and item == target_parent_id
|
||||
|
||||
is_in_list = any(_is_match(item, target, target_simple_id) for item in glist)
|
||||
is_in_list = any(
|
||||
_is_match(item, target, target_simple_id, target_parent_id)
|
||||
for item in glist
|
||||
)
|
||||
|
||||
if mode == "whitelist":
|
||||
return is_in_list
|
||||
|
||||
@@ -218,8 +218,10 @@ class TelegramAdapter(PlatformAdapter):
|
||||
group_id, msg, sender_name_cache
|
||||
)
|
||||
messages.append(msg)
|
||||
if len(messages) >= target_count:
|
||||
break
|
||||
|
||||
# 当前页完整处理后已足够,停止继续翻更旧页面。
|
||||
if len(messages) >= target_count:
|
||||
break
|
||||
|
||||
# 下一页一定更旧,若当前页最旧记录已越过时间窗口则可提前停止
|
||||
if oldest_record_time and oldest_record_time < cutoff_time:
|
||||
@@ -813,7 +815,7 @@ class TelegramAdapter(PlatformAdapter):
|
||||
return uid, None
|
||||
|
||||
pairs = await asyncio.gather(*(_fetch_avatar(uid) for uid in user_ids))
|
||||
return {uid: avatar_url for uid, avatar_url in pairs}
|
||||
return dict(pairs)
|
||||
|
||||
# ==================== 辅助方法 ====================
|
||||
|
||||
|
||||
Reference in New Issue
Block a user