|
@@ -5,31 +5,20 @@ import time
|
|
|
import requests
|
|
|
from requests_html import HTMLSession
|
|
|
|
|
|
-from rollbot import RollbotResponse, RollbotFailure, as_plugin, pop_arg
|
|
|
+from rollbot import RollbotResponse, RollbotFailure, as_plugin, pop_arg, with_help
|
|
|
|
|
|
from config import get_config, get_secret
|
|
|
|
|
|
from .util import upload_image
|
|
|
|
|
|
+@with_help("Using the command !inspire will request an inspiration image from http://inspirobot.me/")
|
|
|
@as_plugin
|
|
|
def inspire(message):
|
|
|
- argstr = message.raw_args
|
|
|
-
|
|
|
- if argstr is not None and "!explain" in argstr:
|
|
|
- return "Using the command !inspire will request an inspiration image from http://inspirobot.me/"
|
|
|
-
|
|
|
try:
|
|
|
url = requests.get("http://inspirobot.me/api?generate=true").text
|
|
|
return RollbotResponse(message, img=url)
|
|
|
except ConnectionError as e:
|
|
|
- return RollbotResponse(
|
|
|
- message,
|
|
|
- failure=RollbotFailure.SERVICE_DOWN,
|
|
|
- debugging={
|
|
|
- "explain": "Could not reach inspirobot.",
|
|
|
- "exception": e
|
|
|
- }
|
|
|
- )
|
|
|
+ return RollbotFailure.SERVICE_DOWN.with_reason("Could not reach inspirobot.").with_exception(e)
|
|
|
|
|
|
|
|
|
@as_plugin
|
|
@@ -220,10 +209,9 @@ def selfie(message):
|
|
|
return run_upload(message, r.content)
|
|
|
|
|
|
|
|
|
+@with_help("The !cat command grabs a cat from https://thiscatdoesnotexist.com/")
|
|
|
@as_plugin
|
|
|
def cat(message):
|
|
|
- if message.raw_args is not None and "!explain" in message.raw_args:
|
|
|
- return "The !cat command grabs a cat from https://thiscatdoesnotexist.com/"
|
|
|
try:
|
|
|
r = requests.get("https://thiscatdoesnotexist.com/", headers={ "User-Agent": "Rollbot" })
|
|
|
except ConnectionError as e:
|
|
@@ -232,10 +220,9 @@ def cat(message):
|
|
|
return run_upload(message, r.content)
|
|
|
|
|
|
|
|
|
+@with_help("The !npc command grabs a person from https://thispersondoesnotexist.com/")
|
|
|
@as_plugin
|
|
|
def npc(message):
|
|
|
- if message.raw_args is not None and "!explain" in message.raw_args:
|
|
|
- return "The !npc command grabs a person from https://thispersondoesnotexist.com/"
|
|
|
try:
|
|
|
r = requests.get("https://thispersondoesnotexist.com/image", headers={ "User-Agent": "Rollbot" })
|
|
|
except ConnectionError as e:
|
|
@@ -244,14 +231,12 @@ def npc(message):
|
|
|
return run_upload(message, r.content)
|
|
|
|
|
|
|
|
|
+@with_help("The !imagine command uses the text2img API at https://deepai.org/machine-learning-model/text2img")
|
|
|
@as_plugin
|
|
|
def imagine(message):
|
|
|
if message.raw_args is None:
|
|
|
return RollbotFailure.INVALID_ARGUMENTS.with_reason("The !imagine command needs text to imagine!")
|
|
|
|
|
|
- if "!explain" in message.raw_args:
|
|
|
- return "The !imagine command uses the text2img API at https://deepai.org/machine-learning-model/text2img"
|
|
|
-
|
|
|
try:
|
|
|
r = requests.post(
|
|
|
"https://api.deepai.org/api/text2img",
|
|
@@ -270,11 +255,11 @@ def imagine(message):
|
|
|
|
|
|
art_number = 0
|
|
|
|
|
|
+@with_help("The !art command uses the 9gans gallery at https://9gans.com/ which generates 9 images every hour. \
|
|
|
+This command will cycle through those 9 images, so if you fire it 10 times in quick succession, the tenth \
|
|
|
+piece of art might be the same as the first.")
|
|
|
@as_plugin
|
|
|
def art(message):
|
|
|
- if message.raw_args is not None and "!explain" in message.raw_args:
|
|
|
- return "The !art command uses the 9gans gallery at https://9gans.com/ which generates 9 images every hour."
|
|
|
-
|
|
|
global art_number
|
|
|
art_number += 1
|
|
|
art_number %= 9
|