Compare commits
2 commits
e151ae5269
...
11ad1c43c9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11ad1c43c9 | ||
|
|
5072450244 |
2 changed files with 28 additions and 2 deletions
30
main.py
30
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()))
|
||||
|
|
|
|||
BIN
maket/Radiohead - Creep.mp3
Normal file
BIN
maket/Radiohead - Creep.mp3
Normal file
Binary file not shown.
Loading…
Reference in a new issue