S
S
SashaN692020-07-20 12:11:30
Python
SashaN69, 2020-07-20 12:11:30

How to request input from user in TG bot?

How can I implement input from a user of type input in python? I need the user to send data to the bot, click on the button and this data is sent to the database. I tried a lot of things but nothing worked (

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Boronnikov, 2020-07-20
@red-cat-fat

So just read the content of the message that comes to the bot from the user in the chat. Why not input?
Here is an example of an echo bot . See how the incoming message is processed there:

@bot.message_handler(content_types=["text"])
def repeat_all_messages(message): # Название функции не играет никакой роли, в принципе
    bot.send_message(message.chat.id, message.text) #message.text - это сообщение, которое получает сервер. Его и обрабатывай

A
Angelex, 2020-07-20
@angelex

Use states. Example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question