mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Register_XXX_Handler
This commit is contained in:
parent
cd92d95f91
commit
716323e56a
5
examples/register_handler/config.py
Normal file
5
examples/register_handler/config.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import telebot
|
||||||
|
|
||||||
|
api_token = ''
|
||||||
|
|
||||||
|
bot = telebot.TeleBot(api_token)
|
9
examples/register_handler/handlers.py
Normal file
9
examples/register_handler/handlers.py
Normal file
@ -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.
|
19
examples/register_handler/main.py
Normal file
19
examples/register_handler/main.py
Normal file
@ -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()
|
Loading…
Reference in New Issue
Block a user