W
W
WalterFox2020-04-27 22:48:35
Python
WalterFox, 2020-04-27 22:48:35

How to get user_id by username in TelegramBotApi?

Good afternoon/night/evening/morning everyone.
There was a not quite ordinary situation:
In the chat bot that I am currently writing (I use Python, the library is TelegramBotAPI), the !balance: "@example" command must be implemented. But all the data stored in my db is called from it by user ID. Why am I doing all this? I need to somehow get his user_id at the address of a person (@example) ... Tell me
how to do this.
Or, alternatively, tell me how to get information about all chat users, that would also be nice.
PS message.from_user.id is not the topic here, the sender is not the owner of the address.
PPS Maybe there is a telegram bot that returns information about the user at his address? If you know - tell me, I'll consider it as an option.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Lee, 2020-04-28
@WalterFox

Something nifiga did not understand. You have a database that contains id and balance. Why get the user's id before his dialog? (This is memory inefficient) When the user writes to the bot (replenishes the balance, etc.), it adds it to the database with the default balance.
At the first message, check whether it is in the database.

E
Elvis, 2020-04-27
@Dr_Elvis

If the user has not written to you in the bot, you will not find out information about him.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question