Answer the question
In order to leave comments, you need to log in
Why telegram bot can't see messages?
Hello.
I created a bot "bot_1" in telegram, it receives messages from a specific service "service_1".
Right now I need to filter messages from 'service_1' (if the message contains the text "text_1" then I need to delete that message).
I tried to do like this:
import logging
from aiogram import Bot, Dispatcher, executor, types
API_TOKEN = 'token' # токен бота для отправки авито объявлений
# Configure logging
logging.basicConfig(level=logging.INFO)
# Initialize bot and dispatcher
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)
# удалить конкретные сообщения (содержащие в тексе "плохое слово")
@dp.message_handler()
async def filter_messages(message: types.Message):
if 'text_1' in message.text:
# remove massage
await message.delete()
if __name__ == '__main__':
executor.start_polling(dp, skip_updates=True)
Answer the question
In order to leave comments, you need to log in
The Telegram Bot API prevents bots from reading messages sent by other bots.
You can get around this limitation using the MTProto API for bots. For Python to work with MTProto on behalf of a bot, there are Pyrogram and Telethon libraries .
For more information about the difference between Bot API and MTProto API, how to use bots with MTProto API, read this article: https://habr.com/ru/post/543676/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question