How to create a bot on pythonfor telegram that will delete messages with certain emoji? ChatGPT’s dont help, i dont have a idea for creating.
import asyncio
from aiogram import Bot, Dispatcher, types
from aiogram.fsm.storage.memory import MemoryStorage
API_TOKEN = '-----------' # Замените на ваш токен
# Создаем бота и диспетчер
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot, storage=MemoryStorage())
# Список эмодзи для удаления
emojis_to_delete = ['🏀', '⚽', '🎲', '🎰']
@dp.message_handler()
async def handle_message(message: types.Message):
text = message.text
for emoji in emojis_to_delete:
text = text.replace(emoji, '')
await message.answer(text, parse_mode=types.ParseMode.HTML)
async def main():
await dp.start_polling()
if __name__ == '__main__':
asyncio.run(main())
Dont working.
New contributor
Andrese Live is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.