Browse Source

Merge branch 'omen' of kirkleon/rollbot4 into master

kirkleon 3 years ago
parent
commit
8ae953ce64
2 changed files with 14 additions and 4 deletions
  1. 13 3
      commands/commands/omen.py
  2. 1 1
      commands/commands/querying.py

+ 13 - 3
commands/commands/omen.py

@@ -6,9 +6,19 @@ 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):
-    yield inquire()
-    yield tarot(False, False)
-    yield await inspire(req, 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
      

+ 1 - 1
commands/commands/querying.py

@@ -2,7 +2,7 @@ from logging import Logger
 import random
 import asyncio
 
-from aiohttp import FormData, MultipartWriter
+from aiohttp import MultipartWriter
 from bs4 import BeautifulSoup
 
 from rollbot import as_command, RollbotFailure, Attachment