From 716323e56adb08c7a6acf5bc66b78fea1218a41b Mon Sep 17 00:00:00 2001 From: _run Date: Wed, 22 Sep 2021 22:46:19 +0500 Subject: [PATCH] Register_XXX_Handler --- examples/register_handler/config.py | 5 +++++ examples/register_handler/handlers.py | 9 +++++++++ examples/register_handler/main.py | 19 +++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 examples/register_handler/config.py create mode 100644 examples/register_handler/handlers.py create mode 100644 examples/register_handler/main.py diff --git a/examples/register_handler/config.py b/examples/register_handler/config.py new file mode 100644 index 0000000..50f8a62 --- /dev/null +++ b/examples/register_handler/config.py @@ -0,0 +1,5 @@ +import telebot + +api_token = '' + +bot = telebot.TeleBot(api_token) \ No newline at end of file diff --git a/examples/register_handler/handlers.py b/examples/register_handler/handlers.py new file mode 100644 index 0000000..5d65b35 --- /dev/null +++ b/examples/register_handler/handlers.py @@ -0,0 +1,9 @@ +# All handlers can be written in this file +from config import bot + +def start_executor(message): + bot.send_message(message.chat.id, 'Hello!') + +# Write more handlers here if you wish. You don't need a decorator + +# Just create function and register in main file. \ No newline at end of file diff --git a/examples/register_handler/main.py b/examples/register_handler/main.py new file mode 100644 index 0000000..1d670e9 --- /dev/null +++ b/examples/register_handler/main.py @@ -0,0 +1,19 @@ +import telebot +from telebot import custom_filters +import config +bot = telebot.TeleBot(config.api_token) + +import handlers + +bot.register_message_handler(handlers.start_executor, commands=['start']) # Start command executor + +# See also +# bot.register_callback_query_handler(*args, **kwargs) +# bot.register_channel_post_handler(*args, **kwargs) +# bot.register_chat_member_handler(*args, **kwargs) +# bot.register_inline_handler(*args, **kwargs) +# bot.register_my_chat_member_handler(*args, **kwargs) +# bot.register_edited_message_handler(*args, **kwargs) +# And other functions.. + +bot.polling() \ No newline at end of file