-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1742 from byehack/ContinueHandling
Support ContinueHandling
- Loading branch information
Showing
6 changed files
with
183 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from telebot.async_telebot import AsyncTeleBot | ||
from telebot.asyncio_handler_backends import ContinueHandling | ||
|
||
|
||
bot = AsyncTeleBot('TOKEN') | ||
|
||
@bot.message_handler(commands=['start']) | ||
async def start(message): | ||
await bot.send_message(message.chat.id, 'Hello World!') | ||
return ContinueHandling() | ||
|
||
@bot.message_handler(commands=['start']) | ||
async def start2(message): | ||
""" | ||
This handler comes after the first one, but it will never be called. | ||
But you can call it by returning ContinueHandling() in the first handler. | ||
If you return ContinueHandling() in the first handler, the next | ||
registered handler with appropriate filters will be called. | ||
""" | ||
await bot.send_message(message.chat.id, 'Hello World2!') | ||
|
||
import asyncio | ||
asyncio.run(bot.polling()) # just a reminder that infinity polling | ||
# wraps polling into try/except block just as sync version, | ||
# but you can use any of them because neither of them stops if you | ||
# pass non_stop=True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from telebot import TeleBot | ||
from telebot.handler_backends import ContinueHandling | ||
|
||
|
||
bot = TeleBot('TOKEN') | ||
|
||
@bot.message_handler(commands=['start']) | ||
def start(message): | ||
bot.send_message(message.chat.id, 'Hello World!') | ||
return ContinueHandling() | ||
|
||
@bot.message_handler(commands=['start']) | ||
def start2(message): | ||
""" | ||
This handler comes after the first one, but it will never be called. | ||
But you can call it by returning ContinueHandling() in the first handler. | ||
If you return ContinueHandling() in the first handler, the next | ||
registered handler with appropriate filters will be called. | ||
""" | ||
bot.send_message(message.chat.id, 'Hello World2!') | ||
|
||
bot.infinity_polling() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters