Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Telegram API: how to get username from id (Python telepot)?

I save ids of all users of my bot in a database but how can I get their current username if I know id? I'm using Python 3 and Telepot framework.

like image 469
Igor Krutilin Avatar asked Jul 14 '26 17:07

Igor Krutilin


1 Answers

Information about a user from user_id can be obtained by the getChat method in telepot.

bot = telepot.Bot(TOKEN)
info = bot.getChat(user_id)
print(info)
like image 177
stuckoverflow Avatar answered Jul 16 '26 05:07

stuckoverflow



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!