eternnoir / pyTelegramBotAPI

Python Telegram bot api.
GNU General Public License v2.0
8.09k stars 2.03k forks source link

problems with process_new_updates #340

Closed XoXoJI closed 4 years ago

XoXoJI commented 7 years ago

Please answer these questions before submitting your issue. Thanks!

  1. What version of pyTelegramBotAPI are you using? 2.3.1
  2. What OS are you using? Linux
  3. What version of python are you using? 2.7

When I push my bot on server, he didn't cath my commands. Then I set threaded = False and he has began to work. bot = telebot.TeleBot(API_TOKEN, threaded=False)

But I have problem with process_new_updates. Bot doesn't transfer to a command which I specified or he do it on second or more my answer to him

@bot.message_handler(regexp='^Bread$')
def bread_borodino(message):
    markup = telebot.types.ReplyKeyboardRemove()
    msg = bot.send_message(message.chat.id, u'How many', reply_markup=markup)
    bot.register_next_step_handler(msg, check_quantity)

def check_quantity(message):
    if message.text != '\start' and message.text != '\help':
        try:
            if int(message.text) > 0:
                main_menu(message, u'Catched')
            else:
                msg = bot.send_message(message.chat.id, u'Need more')
                bot.register_next_step_handler(msg, check_quantity)
        except ValueError:
            msg = bot.send_message(message.chat.id, u'Only digits')
            bot.register_next_step_handler(msg, check_quantity)

How fix it?

intra-au commented 7 years ago

can you please provide full version of the script? are you using webhook or polling?

ArtemCid commented 6 years ago

I have the same issue right now. The handlers of commands not called. When turn off multi-threading it works. On local machine I can't reproduce the bug. It's reproduced on two hostings: Microsoft Azure (Windows server) and PythonAnywhere (Linux).

pyTelegramBotAPI==3.6.3 telebot==0.0.3

Does anybody founded a solution?

GerardHenninger commented 5 years ago

Have the same problem; with threading the message handlers don't work. Without threading they work but the bot goes to "sleep" after a while and sometimes takes minutes to respond (and sometimes doesn't restart at all".

Is there still no fix for this?

RooTooRD commented 8 months ago

I have the same problem when I host on pythonanywhere(linux) and use multi-threading, the message handler doesn't work the temporary solution right now is to disable multi-threading with bot = telebot.TeleBot(API_TOKEN, threaded=False)