B
B
Beko962021-03-03 15:37:05
Python
Beko96, 2021-03-03 15:37:05

How to implement an infinite loop for a bot telebot module?

import telebot
bot = telebot.TeleBot('TOKEN')

@bot.message_handler(commands=['start'])
def start(message):
while True:
msg = bot.send_message(message.chat.id,'enter data: ')
bot.register_next_step_handler(msg,foo)

def foo(message):
data = message.text
# and something else ...
# and while this is happening, the loop should pause as input waits until you enter data

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