forked from zovos/bot_tg
Ну короче реализация вайба, я ща ОБОССУСЬ НАХУЙ
This commit is contained in:
parent
2e9c715fb8
commit
5072450244
2 changed files with 26 additions and 2 deletions
28
main.py
28
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,11 +413,15 @@ 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()))
|
||||
|
||||
|
|
|
|||
BIN
maket/Radiohead - Creep.mp3
Normal file
BIN
maket/Radiohead - Creep.mp3
Normal file
Binary file not shown.
Loading…
Reference in a new issue