diff --git a/main.py b/main.py index 60d9723..b37a7cc 100644 --- a/main.py +++ b/main.py @@ -6,10 +6,10 @@ from io import BytesIO from pathlib import Path from textwrap import wrap -from aiogram import Bot, Dispatcher, F +from aiogram import Bot, Dispatcher, F, types from aiogram.enums import ParseMode from aiogram.filters import Command, CommandStart -from aiogram.types import BufferedInputFile, Message, BotCommand +from aiogram.types import BufferedInputFile, Message, BotCommand, FSInputFile from aiogram.client.default import DefaultBotProperties from PIL import Image, ImageDraw, ImageFont from datetime import datetime, time, timedelta @@ -363,6 +363,26 @@ async def handle_gen_mem(message: Message, bot: Bot): await message.reply_photo(BufferedInputFile(output.getvalue(), filename="meme.jpg")) +KEYWORDS = {'крип', 'радиохэд', 'creep', 'radiohead'} +# I'M CREEP +async def handle_keywords(message: types.Message): + + if message.text and message.text.startswith('/'): + return + + text = message.text.lower() + + if any(re.search(rf'\b{word}\b', text) for word in KEYWORDS): + audio_path = BASE_DIR / "maket" / "Radiohead - Creep.mp3" + + if audio_path.exists(): + await message.answer_audio( + audio=FSInputFile(audio_path), + caption="I'm a creep, I'm a weirdo..." + ) + else: + logger.warning(f"Файл не найден по пути: {audio_path}") + def main(): token = os.getenv("BOT_TOKEN") @@ -393,10 +413,14 @@ def main(): dp.message.register(handle_break, Command("break")) dp.message.register(handle_maket, Command("maket")) + + async def handle_gen_mem_cmd(message: Message, bot: Bot): await handle_gen_mem(message, bot) dp.message.register(handle_gen_mem_cmd, Command("gen_mem")) + + dp.message.register(handle_keywords, F.text) logger.info("Bot is starting...") asyncio.run(dp.start_polling(bot, allowed_updates=dp.resolve_used_update_types())) diff --git a/maket/Radiohead - Creep.mp3 b/maket/Radiohead - Creep.mp3 new file mode 100644 index 0000000..4887e28 Binary files /dev/null and b/maket/Radiohead - Creep.mp3 differ