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()
|
subs = self.__config.list_subscriptions()
|
||||||
if not subs:
|
if not subs:
|
||||||
return "No subscriptions"
|
return "No subscriptions"
|
||||||
updated = 0
|
await self.__bot.get_dialogs()
|
||||||
for s in subs:
|
lines = []
|
||||||
|
for i, s in enumerate(subs, start=1):
|
||||||
src = s.get('srcChatId')
|
src = s.get('srcChatId')
|
||||||
dst = s.get('action', {}).get('chatId')
|
dst = s.get('action', {}).get('chatId')
|
||||||
ftype = s.get('filter', {}).get('type', '')
|
ftype = s.get('filter', {}).get('type', '')
|
||||||
@ -188,8 +189,8 @@ class Bot():
|
|||||||
name = "[{0}] '{1}' = [{2}] {3} -> [{4}] {5}".format(
|
name = "[{0}] '{1}' = [{2}] {3} -> [{4}] {5}".format(
|
||||||
ftype, value, src, src_title, dst, dst_title)
|
ftype, value, src, src_title, dst, dst_title)
|
||||||
self.__config.set_name(s['id'], name)
|
self.__config.set_name(s['id'], name)
|
||||||
updated += 1
|
lines.append("{0}. {1}".format(i, name))
|
||||||
return "Updated {0} names".format(updated)
|
return "Updated {0} names:\n{1}".format(len(lines), "\n".join(lines))
|
||||||
|
|
||||||
async def __get_chat_title(self, chat_id: int) -> str:
|
async def __get_chat_title(self, chat_id: int) -> str:
|
||||||
try:
|
try:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user