3

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.

2 Answers2

1

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)
stuckoverflow
  • 625
  • 2
  • 7
  • 23
0

you can get the inforamtion of an account by checking the entity.

You can try to get the entity with this method:

entity = client.get_entity(chat_id)

then Print the entity and try to get the name from there with something like name = entity.chat.name

alessandro buffoli
  • 658
  • 2
  • 10
  • 29