mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
removed TextFilterKey in example, instead TextMatchFilter was modified
This commit is contained in:
@ -9,16 +9,9 @@ import asyncio
|
||||
from telebot.async_telebot import AsyncTeleBot
|
||||
from telebot import types
|
||||
from telebot.custom_filters import TextFilter
|
||||
from telebot.asyncio_filters import AdvancedCustomFilter
|
||||
from telebot.asyncio_filters import TextMatchFilter
|
||||
|
||||
bot = AsyncTeleBot("1254795383:AAE7gbj1aas4lEDHB1eVuZZhSGPWcH1B5ds")
|
||||
|
||||
|
||||
class TextFilterKey(AdvancedCustomFilter):
|
||||
key = 'text'
|
||||
|
||||
async def check(self, message, config: TextFilter):
|
||||
return config.check(message)
|
||||
bot = AsyncTeleBot("")
|
||||
|
||||
|
||||
@bot.message_handler(text=TextFilter(equals='hello'))
|
||||
@ -99,5 +92,5 @@ async def poll_question_handler_ignore_case(poll: types.Poll):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
bot.add_custom_filter(TextFilterKey())
|
||||
bot.add_custom_filter(TextMatchFilter())
|
||||
asyncio.run(bot.polling())
|
||||
|
@ -6,18 +6,11 @@ with (message_handler, callback_query_handler, poll_handler)
|
||||
"""
|
||||
|
||||
from telebot import TeleBot, types
|
||||
from telebot.custom_filters import TextFilter, AdvancedCustomFilter
|
||||
from telebot.custom_filters import TextFilter, TextMatchFilter
|
||||
|
||||
bot = TeleBot("")
|
||||
|
||||
|
||||
class TextFilterKey(AdvancedCustomFilter):
|
||||
key = 'text'
|
||||
|
||||
def check(self, message, config: TextFilter):
|
||||
return config.check(message)
|
||||
|
||||
|
||||
@bot.message_handler(text=TextFilter(equals='hello'))
|
||||
def hello_handler(message: types.Message):
|
||||
bot.send_message(message.chat.id, message.text)
|
||||
@ -96,5 +89,5 @@ def poll_question_handler_ignore_case(poll: types.Poll):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
bot.add_custom_filter(TextFilterKey())
|
||||
bot.add_custom_filter(TextMatchFilter())
|
||||
bot.infinity_polling()
|
||||
|
Reference in New Issue
Block a user