Files
limoka/dorotorothequickend/DorotoroModules/FoodRecipe.py
2025-07-10 21:02:34 +03:00

52 lines
2.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# █████████████████████████████████████████
# █────██────█────█────█───█────█────█────█
# █─██──█─██─█─██─█─██─██─██─██─█─██─█─██─█
# █─██──█─██─█────█─██─██─██─██─█────█─██─█
# █─██──█─██─█─█─██─██─██─██─██─█─█─██─██─█
# █────██────█─█─██────██─██────█─█─██────█
# █████████████████████████████████████████
#
#
# Copyright 2022 t.me/Dorotoro
# https://www.gnu.org/licenses/agpl-3.0.html
# meta banner: https://raw.githubusercontent.com/dorotorothequickend/DorotoroModules/main/banners/DorotoroFoodRecipe.png
# meta developer: @DorotoroMods
from .. import loader, utils
from ..utils import answer
from telethon.tl.types import Message
@loader.tds
class FoodRecipe(loader.Module):
"""Ищет рецепт блюда по его названию."""
strings = {'name': 'FoodRecipe'}
@loader.command() # используем декоратор команды
async def foodrecipecmd(self, message: Message):
"<название блюда> - найти рецепт блюда."
args = utils.get_args_raw(message)
msg = await answer(message, 'Пожалуйста подождите. Рецепт в поиске...!')
if not args:
await answer(message, "Поедим пустоту вместе! Введи ингридиенты или название блюда, пожалуйста.")
async with self._client.conversation("@cookinghelpbot") as conv:
msgg = await conv.send_message(args)
r = await conv.get_response()
if r.message == "Рецепт не загрузился, либо его нет":
await answer(msg, "🔧 Рецепт не найден.")
return
elif r.message == "Одного из ингридиента нету":
await answer(msg, "🔧 Один из ингредиентов отсутствует. ")
return
else:
await r.click(data="cook")
k = await conv.get_response()
await msgg.delete()
await r.delete()
await k.delete()
ingridienti = r.text[15:]
retept = k.text
text = f"<b>Рецепт найден!\n\n{ingridienti}\n\nРецепт:\n{retept}</b>"
await answer(msg, text)