chore: tg_filter emoji fix, sprint spec update, tg_digest script

This commit is contained in:
Gan, Jimmy
2026-07-12 01:41:15 +08:00
parent f1ada7d277
commit af24287748
3 changed files with 114 additions and 4 deletions
+7 -3
View File
@@ -40,7 +40,7 @@ THRESHOLD = 40
# Scan config
MSGS_PER_GROUP = 500
GROUPS_PER_CYCLE = 56
GROUPS_PER_CYCLE = 0 # 0 = scan all eligible groups (was 56)
# Keywords
INTERESTING_KEYWORDS = [
@@ -146,7 +146,7 @@ async def scan_and_report(dry_run: bool = False) -> list:
else:
sorted_candidates.append((cid, title, ""))
sorted_candidates.sort(key=lambda x: (x[2] == "", x[2]))
sorted_candidates = sorted_candidates[:GROUPS_PER_CYCLE]
sorted_candidates = sorted_candidates[:len(candidates)] if GROUPS_PER_CYCLE == 0 else sorted_candidates[:GROUPS_PER_CYCLE]
log.info(f"Scanning {len(sorted_candidates)} groups this cycle")
@@ -169,7 +169,11 @@ async def scan_and_report(dry_run: bool = False) -> list:
sender = None
if msg.from_user:
sender = msg.from_user.first_name or msg.from_user.username or str(msg.from_user.id)
text = (msg.text or msg.caption or "")[:2000]
try:
text = (msg.text or msg.caption or "")[:2000]
except (UnicodeDecodeError, UnicodeEncodeError):
# surrogate-pass decode failure on certain emoji sequences
text = (str(msg.caption or "")[:2000]) if msg.caption else "[text unreadable]"
item = {
"chat_id": chat_id, "chat_title": chat_title, "message_id": msg.id,
"sender": sender, "text": text, "score": score,