eternnoir / pyTelegramBotAPI

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

The register_next_step_handler method cannot be used in examples/multibot #1924

Closed MaGua-Bishop closed 1 year ago

MaGua-Bishop commented 1 year ago

Please answer these questions before submitting your issue. Thanks!

  1. What version of pyTelegramBotAPI are you using? 4.10.0
  2. What OS are you using? mac os
  3. What version of python are you using? python3.8

I was using the code in examples/multibot and found that I couldn't use the register_next_step_handler method, which doesn't work with subobots, this method is very useful to me, is there a workaround

MaGua-Bishop commented 1 year ago

I tried to read the source code and work it out myself, but the logic was beyond me. I could determine that next_step_backend would solve this problem, but when I tried to define next_step_backend, I found that it was invalid. I'm sorry to bother you. Looking forward to your reply

bot.next_step_backend = {group_id: telebot.Handler(step.add_group_send_text, bot_data=bot_data,
                                                  bot=bot)}
MaGua-Bishop commented 1 year ago

Sorry, I have found the answer to this question. Repeat creating a new Telebot object in the example /multibot. This can be solved by reusing objects. I asked a stupid question