Skip to content

Commit 0fecf46

Browse files
Create continue_handling.py
1 parent 982e642 commit 0fecf46

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

examples/continue_handling.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from telebot import TeleBot
2+
from telebot.handler_backends import ContinueHandling
3+
4+
5+
bot = TeleBot('TOKEN')
6+
7+
@bot.message_handler(commands=['start'])
8+
def start(message):
9+
bot.send_message(message.chat.id, 'Hello World!')
10+
return ContinueHandling()
11+
12+
@bot.message_handler(commands=['start'])
13+
def start2(message):
14+
"""
15+
This handler comes after the first one, but it will never be called.
16+
But you can call it by returning ContinueHandling() in the first handler.
17+
18+
If you return ContinueHandling() in the first handler, the next
19+
registered handler with appropriate filters will be called.
20+
"""
21+
bot.send_message(message.chat.id, 'Hello World2!')
22+
23+
bot.infinity_polling()

0 commit comments

Comments
 (0)