Receive information from Telebot

Asked

Viewed 201 times

-1

I’m developing a Telegram bot and part of it is already functional. Now, I need to receive a user input with questions that the system asks so that I can further automate the processes. In the documentation, I couldn’t find a way to do it (https://pypi.org/project/pyTelegramBotAPI) and in the example codes on Github I also did not find any code that receives this.

The part of the code I need to receive user information from:

## -------------- Começa o cadastro --------------------
@bot.message_handler(commands=['vamosla'])
def send_message(message):
    bot.send_message(message, "Digite seu Nome completo: ")
    # Ler o texto digitado
    # Armazena a informação
    time.sleep(2)
    bot.send_message(message.chat.id, "O que acha de fazermos agora?\n /start: Ir para o menu principal.\n /atendimento: Ser atendido. \n /sair: Finalizar atendimento.")

Is it possible to receive this information?

1 answer

1

Hello! I have been developing some Telegram-bots lately and have been using the framework telepot. In it, the process of receiving and sending messages is very simple and never had problem.

To start the bot:

import telepot
bot = telepot.Bot('***** PUT YOUR TOKEN HERE *****')

You can easily access new messages sent by users via the command:

updates = bot.getUpdates()[0]
chat_id = updates['message']['chat']['id']
message = updates['message']['text']

And to send the answer is even easier:

bot.sendMessage(chat_id, 'Hey!')

I hope I helped! Read the documentation to learn more! https://telepot.readthedocs.io/en/latest/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.