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__)
|
plugin_root = os.path.dirname(__file__)
|
||||||
candidate_dirs = [
|
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"),
|
os.path.join(plugin_root, "src", "reports", "templates"),
|
||||||
]
|
]
|
||||||
for candidate in candidate_dirs:
|
for candidate in candidate_dirs:
|
||||||
@@ -112,7 +114,9 @@ class QQGroupDailyAnalysis(Star):
|
|||||||
candidate_paths = [
|
candidate_paths = [
|
||||||
os.path.join(plugin_root, "assets", f"{template_name}-demo.jpg"),
|
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", 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(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, "demo.jpg"),
|
||||||
os.path.join(template_base_dir, template_name, "preview.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(), {})
|
platform_map = platforms.get(str(platform_id).strip(), {})
|
||||||
if isinstance(platform_map, dict):
|
if isinstance(platform_map, dict):
|
||||||
groups.update(
|
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:
|
else:
|
||||||
for platform_map in platforms.values():
|
for platform_map in platforms.values():
|
||||||
if not isinstance(platform_map, dict):
|
if not isinstance(platform_map, dict):
|
||||||
continue
|
continue
|
||||||
groups.update(
|
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)
|
sorted_groups = sorted(groups)
|
||||||
|
|||||||
@@ -68,15 +68,37 @@ class ConfigManager:
|
|||||||
else target_simple_id
|
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:
|
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:
|
if item == target_simple_id:
|
||||||
return True
|
return True
|
||||||
# 允许 Telegram 话题会话通过父群 ID 命中简单群号白/黑名单
|
# 允许 Telegram 话题会话通过父群 ID 命中简单群号白/黑名单
|
||||||
return "#" in target_simple_id and item == target_parent_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":
|
if mode == "whitelist":
|
||||||
return is_in_list
|
return is_in_list
|
||||||
|
|||||||
@@ -218,8 +218,10 @@ class TelegramAdapter(PlatformAdapter):
|
|||||||
group_id, msg, sender_name_cache
|
group_id, msg, sender_name_cache
|
||||||
)
|
)
|
||||||
messages.append(msg)
|
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:
|
if oldest_record_time and oldest_record_time < cutoff_time:
|
||||||
@@ -813,7 +815,7 @@ class TelegramAdapter(PlatformAdapter):
|
|||||||
return uid, None
|
return uid, None
|
||||||
|
|
||||||
pairs = await asyncio.gather(*(_fetch_avatar(uid) for uid in user_ids))
|
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