Исправлен вывод рейтинга в случае ошибки получения информации об одном из участников.
This commit is contained in:
parent
54ef3bbddd
commit
b233e67a21
1 changed files with 8 additions and 2 deletions
|
|
@ -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:
|
||||
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: str
|
||||
try:
|
||||
info = await bot.get_chat_member(chat_id, user['user_id'])
|
||||
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 += '{}. id={} - {}\n'.format(i, name, user['value'])
|
||||
i = i + 1
|
||||
|
||||
return result
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue