Answer the question
In order to leave comments, you need to log in
How to read text from message PyTelegramBotApi?
Hello! Started studying the PyTelegramBotApi library. There was a problem: I receive the text in a variable not the one I am going to enter, but with which I call the timer function.
import telebot
from telebot import types
import time
token = ""
bot = telebot.TeleBot(token)
# content_types=['text'] - сработает, если нам прислали текстовое сообщение
@bot.message_handler(commands=['start'])
def start(message):
user = message.chat.id
bot.send_message(user, "HI, here is my new bot, that works like a timer.")
bot.send_message(user, "Your main command here is - /todo")
@bot.message_handler(commands=['todo'])
def todo(message):
user = message.chat.id
bot.send_message(user, "Now there are only two functions:")
bot.send_message(user, "Timer for once time - /timer")
bot.send_message(user, "Timer for a few times - /ltimer")
@bot.message_handler(commands=['timer'])
def timer(message):
user = message.chat.id
bot.send_message(user, "Write here what u need to be reminded of")
text1 = message.text
remind = message.text
bot.send_message(user, remind)
if __name__ == '__main__':
bot.infinity_polling()
Answer the question
In order to leave comments, you need to log in
You need register_next_step_handler(). With it, when /timer is called, the bot will wait for the next message. An example can be found here https://github.com/eternnoir/pyTelegramBotAPI/blob...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question