Исправлен вывод рейтинга в случае ошибки получения информации об одном из участников.

This commit is contained in:
Kirill Kirilenko 2026-03-23 19:51:56 +03:00
parent 54ef3bbddd
commit 924d728533

View file

@ -21,8 +21,14 @@ async def format_rating(chat_id: int, top_users: List[Any], bot: Bot) -> str:
result = ''
i = 1
for user in top_users:
name: str
try:
info = await bot.get_chat_member(chat_id, user['user_id'])
result += '{}. {} - {}\n'.format(i, utils.full_name(info.user.first_name, info.user.last_name), user['value'])
name = utils.full_name(info.user.first_name, info.user.last_name)
except Exception as e:
print(f"Не удалось получить информацию об участнике (id={user['user_id']}): {e}")
name = f"id={user['user_id']}"
result += '{}. {} - {}\n'.format(i, name, user['value'])
i = i + 1
return result