diff --git a/main.py b/main.py index 3639d99..3eb7df6 100644 --- a/main.py +++ b/main.py @@ -7,10 +7,10 @@ from pathlib import Path from textwrap import wrap import random -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 @@ -364,6 +364,7 @@ async def handle_gen_mem(message: Message, bot: Bot): await message.reply_photo(BufferedInputFile(output.getvalue(), filename="meme.jpg")) +<<<<<<< HEAD async def handle_size(message: Message): size = round(random.uniform(0.1, 35.0), 1) @@ -384,6 +385,27 @@ async def handle_size(message: Message): f"📏 Твой хуек: {size} см\n" f"Ты: {status}" ) +======= +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}") +>>>>>>> SUDOZOVCHIK-CREEP-FUNCTION def main(): @@ -417,10 +439,14 @@ def main(): dp.message.register(handle_maket, Command("maket")) dp.message.register(handle_size, Command("size")) + + 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