how can I measure the time the user uses to interact with the bot?
E.g.
The bot sends a message.
We want to measure the time from the reception of the message to a response (click on a put on the online keyboard). I need this using python telegram bot library in python.
2
Answers
This is not something that the
python-telegram-bot
library can solve for you, you have to do the computation by yourself. But Telegram API provides you with all the information you need.Every time you send a message, in the response Telegram sends you timestamp and ID of the sent message (see sendMessage method). You can save this in a database.
Once user interacts with the message (e.g. clicking on the button), you’ll receive another Update which should also contain timestamp, and if the user action was an interaction with your previous message, it will also contain this message’s ID. For example, if the user pressed a button, the
Update
will contain object callback_query with the ID of the message containing the button that was pressed. You can then search for this in the database and measure how long it took until the user’s interaction.here is small function to do it, i hope you know how to use it..
This is code for make human readable time
Here is the code for using the upward function…
I think this should help you, Hope ya would love my answer and i gave you the correct one