1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00
pyTelegramBotAPI/examples/asynchronous_telebot/custom_filters/is_filter_example.py

24 lines
673 B
Python
Raw Normal View History

2021-11-27 21:41:39 +03:00
from telebot.async_telebot import AsyncTeleBot
import telebot
2021-11-27 23:04:49 +03:00
2021-11-27 21:41:39 +03:00
bot = AsyncTeleBot('TOKEN')
# Check if message is a reply
@bot.message_handler(is_reply=True)
async def start_filter(message):
await bot.send_message(message.chat.id, "Looks like you replied to my message.")
# Check if message was forwarded
@bot.message_handler(is_forwarded=True)
async def text_filter(message):
await bot.send_message(message.chat.id, "I do not accept forwarded messages!")
# Do not forget to register filters
bot.add_custom_filter(telebot.asyncio_filters.IsReplyFilter())
bot.add_custom_filter(telebot.asyncio_filters.ForwardFilter())
2021-12-12 13:07:30 +03:00
import asyncio
asyncio.run(bot.polling())