from logging import Logger
from rollbot import as_command
from rollbot.injection.util import Request

from commands.tarot import tarot
from commands.querying import inspire
from commands.simple import inquire

from rollbot.types import Attachment

@as_command
async def omen(req: Request, logger: Logger):
    inquiry = inquire()
    drawing = tarot(False, False)
    formatted = f"{inquiry}\n---\n{drawing}"
    inspiration = await inspire(req, logger)
    try:
        async with req.get(inspiration) as res:
            image = Attachment("image", await res.read())
    except:
        logger.exception("Failed to actually get inspiration image")
        return formatted + "\n---\nFailed to load inspiration"
    return formatted, image
     
