mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Merge pull request #1308 from coder2020official/master
Added example and editd description.
This commit is contained in:
commit
f854163626
21
examples/custom_filters/is_filter_example.py
Normal file
21
examples/custom_filters/is_filter_example.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import telebot
|
||||||
|
from telebot import custom_filters
|
||||||
|
|
||||||
|
bot = telebot.TeleBot('TOKEN')
|
||||||
|
|
||||||
|
|
||||||
|
# Check if message is a reply
|
||||||
|
@bot.message_handler(is_reply=True)
|
||||||
|
def start_filter(message):
|
||||||
|
bot.send_message(message.chat.id, "Looks like you replied to my message.")
|
||||||
|
|
||||||
|
# Check if message was forwarded
|
||||||
|
@bot.message_handler(is_forwarded=True)
|
||||||
|
def text_filter(message):
|
||||||
|
bot.send_message(message.chat.id, "I do not accept forwarded messages!")
|
||||||
|
|
||||||
|
# Do not forget to register filters
|
||||||
|
bot.add_custom_filter(custom_filters.IsReplyFilter())
|
||||||
|
bot.add_custom_filter(custom_filters.ForwardFilter())
|
||||||
|
|
||||||
|
bot.polling(non_stop=True)
|
@ -87,7 +87,7 @@ class ChatFilter(AdvancedCustomFilter):
|
|||||||
|
|
||||||
class ForwardFilter(SimpleCustomFilter):
|
class ForwardFilter(SimpleCustomFilter):
|
||||||
"""
|
"""
|
||||||
Check whether message was forwarded.
|
Check whether message was forwarded from channel or group.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user