mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
![coder2020official](/assets/img/avatar_default.png)
Created useful filters that can be used in message handlers. Created some examples on using them.
17 lines
471 B
Python
17 lines
471 B
Python
import telebot
|
|
|
|
bot = telebot.TeleBot('TOKEN')
|
|
|
|
|
|
# Check if message starts with @admin tag
|
|
@bot.message_handler(text_startswith="@admin")
|
|
def start_filter(message):
|
|
bot.send_message(message.chat.id, "Looks like you are calling admin, wait...")
|
|
|
|
# Check if text is hi or hello
|
|
@bot.message_handler(text=['hi','hello'])
|
|
def text_filter(message):
|
|
bot.send_message(message.chat.id, "Hi, {name}!".format(name=message.from_user.first_name))
|
|
|
|
|
|
bot.polling(non_stop=True) |