1
0
Fork 0
forked from zovos/bot_tg

add new zaloopa

This commit is contained in:
q 2026-02-20 14:23:47 +03:00
parent 1d79125500
commit f385bedd9b
2 changed files with 37 additions and 0 deletions

36
main.py
View file

@ -2,6 +2,7 @@ import asyncio
import logging
import os
import re
import requests
from io import BytesIO
from pathlib import Path
from textwrap import wrap
@ -131,6 +132,7 @@ HINT_TEXT = (
f"• /maket «id» «текст» — доступные: {templates_list_text()} (1: 737x414, точка 104,240).\n"
"• /gen_mem Up:верх Down:низ — отправь с фото (как подпись) или ответом на фото.\n"
"• /break — узнать, сколько минут до перекура.\n"
"• /prices — цены с x-server.\n"
"Подсказка: в группах команда должна быть слитно с ботом (/gen_mem@username)."
)
@ -405,6 +407,38 @@ async def handle_keywords(message: types.Message):
else:
logger.warning(f"Файл не найден по пути: {audio_path}")
async def handle_prices(message: Message):
def fetch():
return requests.get(
"https://твой-домен/magnit/products",
headers={"X-Token": "sisi"},
timeout=10,
)
try:
resp = await asyncio.to_thread(fetch)
if resp.status_code != 200:
await message.answer("пошел нахуй")
return
data = resp.json()
if not data:
await message.answer("иди нахуй")
return
text = "смерть в 25:\n\n"
for item in data:
name = item.get("name")
price = item.get("price")
text += f"{name}{price}\n"
await message.answer(text[:4000])
except Exception:
await message.answer("unable to connect x-server гандон")
def main():
token = os.getenv("BOT_TOKEN")
@ -424,6 +458,7 @@ def main():
BotCommand(command="gen_mem", description="Мем из фото (ответом)"),
BotCommand(command="break", description="Сколько минут до перекура"),
BotCommand(command="size", description="хуй"),
BotCommand(command="prices", description="цены x-server"),
]
)
except Exception: # noqa: WPS440
@ -436,6 +471,7 @@ def main():
dp.message.register(handle_break, Command("break"))
dp.message.register(handle_maket, Command("maket"))
dp.message.register(handle_size, Command("size"))
dp.message.register(handle_prices, Command("prices"))

View file

@ -1,2 +1,3 @@
aiogram==3.4.1
pillow==10.3.0
requests==2.31.0