Fix !sub names: warm entity cache before resolving, show per-rule result
get_entity fails silently for chats not yet cached in current session. Call get_dialogs() first to populate the cache, then resolve all titles. Show each updated name so it's clear what was resolved (and what wasn't). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
501614f9c9
commit
73e8e4b507
@ -177,8 +177,9 @@ class Bot():
|
||||
subs = self.__config.list_subscriptions()
|
||||
if not subs:
|
||||
return "No subscriptions"
|
||||
updated = 0
|
||||
for s in subs:
|
||||
await self.__bot.get_dialogs()
|
||||
lines = []
|
||||
for i, s in enumerate(subs, start=1):
|
||||
src = s.get('srcChatId')
|
||||
dst = s.get('action', {}).get('chatId')
|
||||
ftype = s.get('filter', {}).get('type', '')
|
||||
@ -188,8 +189,8 @@ class Bot():
|
||||
name = "[{0}] '{1}' = [{2}] {3} -> [{4}] {5}".format(
|
||||
ftype, value, src, src_title, dst, dst_title)
|
||||
self.__config.set_name(s['id'], name)
|
||||
updated += 1
|
||||
return "Updated {0} names".format(updated)
|
||||
lines.append("{0}. {1}".format(i, name))
|
||||
return "Updated {0} names:\n{1}".format(len(lines), "\n".join(lines))
|
||||
|
||||
async def __get_chat_title(self, chat_id: int) -> str:
|
||||
try:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user