Commit 03d108b
Changed files (1)
src
history
src/history/utils.py
@@ -111,14 +111,23 @@ async def list_chat_ids(client: Client, message: Message):
One Turso database may be read by multiple Telegram accounts, we can use tags to filter by account
For example,
- tags: {my_uid}_SKIP_LIST -> skip list this chat of `my_uid` account
+ tags:
+ {my_uid}_SKIP_LIST -> skip list of `my_uid` account
+ SKIP_LIST_IN_{chatid} -> skip list in this chat_id
+ ONLY_LIST_IN_{chatid} -> only list in this chat_id
"""
resp = await turso_exec([{"type": "execute", "stmt": {"sql": "SELECT * FROM chatinfo;"}}], silent=True, retry=2, **TURSO_KWARGS)
chats = turso_parse_resp(resp)
me = await myself(client)
+ cid = slim_cid(message.chat.id)
msg = ""
for x in sorted(chats, key=lambda x: x["ctype"]):
- if f"{me.id}_SKIP_LIST" in strings_list(x.get("tags", "")):
+ tags = strings_list(x.get("tags", ""))
+ if "ONLY_LIST_IN_" in x.get("tags", "") and f"ONLY_LIST_IN_{cid}" not in tags:
+ continue
+ if "SKIP_LIST_IN_" in x.get("tags", "") and f"SKIP_LIST_IN_{cid}" in tags:
+ continue
+ if f"{me.id}_SKIP_LIST" in tags:
continue
msg += f"`/history #{x['cid']}` {CTYPE_EMOJI[x['ctype']]}: {x['ctitle']}\n"
await send2tg(client, message, texts=msg)