From b95ab104e38775c9c214d945cc0ca01cb3528a55 Mon Sep 17 00:00:00 2001 From: coder2020official Date: Mon, 13 Sep 2021 23:09:06 +0500 Subject: [PATCH] Update custom_filters.py --- telebot/custom_filters.py | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/telebot/custom_filters.py b/telebot/custom_filters.py index 2491185..dd1f1a2 100644 --- a/telebot/custom_filters.py +++ b/telebot/custom_filters.py @@ -84,3 +84,49 @@ class ChatFilter(AdvancedCustomFilter): key = 'chat_id' def check(self, message, text): return message.chat.id in text + +class ForwardFilter(SimpleCustomFilter): + """ + Check whether message was forwarded. + + Example: + + @bot.message_handler(is_forwarded=True) + """ + + key = 'is_forwarded' + + def check(self, message): + return message.forward_from_chat is not None + +class IsReplyFilter(SimpleCustomFilter): + """ + Check whether message is a reply. + + Example: + + @bot.message_handler(is_reply=True) + """ + + key = 'is_reply' + + def check(self, message): + return message.reply_to_message is not None + + + +class LanguageFilter(AdvancedCustomFilter): + """ + Check users language_code. + + Example: + + @bot.message_handler(language_code=['ru']) + """ + + key = 'language_code' + + def check(self, message, text): + if type(text) is list:return message.from_user.language_code in text + else: return message.from_user.language_code == text +