|
@@ -227,4 +227,22 @@ def cat(message):
|
|
|
return RollbotFailure.SERVICE_DOWN.with_reason("Could not reach cat generator.").with_exception(e)
|
|
|
|
|
|
return run_upload(message, r.content)
|
|
|
-
|
|
|
+
|
|
|
+@as_plugin
|
|
|
+def imagine(message):
|
|
|
+ try:
|
|
|
+ r = requests.post(
|
|
|
+ "https://api.deepai.org/api/text2img",
|
|
|
+ data={ "text": message.raw_args },
|
|
|
+ # TODO rules for this API key seem unclear on the site
|
|
|
+ # if this stops working, maybe refresh the key
|
|
|
+ headers={ "api-key": "quickstart-QUdJIGlzIGNvbWluZy4uLi4K"}
|
|
|
+ )
|
|
|
+ except ConnectionError as e:
|
|
|
+ return RollbotFailure.SERVICE_DOWN.with_reason("Could not reach text2img service.").with_exception(e)
|
|
|
+
|
|
|
+ result = r.json().get("output_url", None)
|
|
|
+ if result is None:
|
|
|
+ return RollbotFailure.SERVICE_DOWN.with_reason(f"Response from text2img was invalid: {r.text}")
|
|
|
+
|
|
|
+ return RollbotResponse(message, img=result)
|