A
A
Arkady Baganin2019-11-03 21:35:38
Python
Arkady Baganin, 2019-11-03 21:35:38

How to get the username of the user who clicked on the button?

Good afternoon!
I will describe briefly. I'm creating a bot and at this stage I'm trying to save and get the user's Jwt token for further work with the API. But this is not the task, the token is saved with the username of the user, but I don’t get it because I get the username of the bot and try to get a record in sqlite db using it.
How to solve it?
The code:

with sqlite3.connect(config.db_name, isolation_level=None) as conn:
                cursor = conn.cursor()
                stmt = "SELECT token FROM users WHERE username=:login"
                args = {'login': str(call.message.from_user.username)}
                cursor.execute(stmt, args)
                row = cursor.fetchone()
                token = row[0] if row is not None else ''
                print(str(call.message.from_user.username))

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question