✨ Started work on converting all commands to slash-commands
This commit is contained in:
@ -83,7 +83,7 @@ class BedreNetflix():
|
||||
await channel.send(postData["title"]+" successfully added to Bedre Netflix")
|
||||
logThis("Added "+postData["title"]+" to Bedre Netflix")
|
||||
elif r.status_code == 400:
|
||||
await channel.send("The movie is already requested for Bedre Netflix")
|
||||
await channel.send("The movie is already requested for or added to Bedre Netflix")
|
||||
else:
|
||||
await channel.send("Something went wrong")
|
||||
logThis(str(r.status_code)+" "+r.reason)
|
||||
@ -159,7 +159,7 @@ class BedreNetflix():
|
||||
await channel.send(postData["title"]+" successfully added to Bedre Netflix")
|
||||
logThis("Added a "+postData["title"]+" to Bedre Netflix")
|
||||
elif r.status_code == 400:
|
||||
await channel.send("The show is already requested for Bedre Netflix")
|
||||
await channel.send("The show is already requested for or added to Bedre Netflix")
|
||||
else:
|
||||
await channel.send("Something went wrong")
|
||||
logThis(str(r.status_code)+" "+r.reason)
|
||||
|
@ -9,73 +9,74 @@ class NerdShit():
|
||||
|
||||
async def wolfSearch(self,ctx,content):
|
||||
fnt = ImageFont.truetype('resources/times-new-roman.ttf', 20)
|
||||
async with ctx.message.channel.typing():
|
||||
logThis("Requesting data")
|
||||
client = wolframalpha.Client(self.client.credentials.wolfKey)
|
||||
res = client.query(content)
|
||||
await ctx.defer()
|
||||
logThis("Requesting data")
|
||||
client = wolframalpha.Client(self.client.credentials.wolfKey)
|
||||
res = client.query(content)
|
||||
|
||||
logThis("Processing data")
|
||||
titles = []
|
||||
pods = []
|
||||
if int(res.numpods) > 0:
|
||||
for pod in res.pods:
|
||||
titles += [pod.title]
|
||||
for x, sub in enumerate(pod.subpods):
|
||||
pods += [sub]
|
||||
if x > 0:
|
||||
titles += [""]
|
||||
logThis("Processing data")
|
||||
titles = []
|
||||
pods = []
|
||||
if int(res.numpods) > 0:
|
||||
for pod in res.pods:
|
||||
titles += [pod.title]
|
||||
for x, sub in enumerate(pod.subpods):
|
||||
pods += [sub]
|
||||
if x > 0:
|
||||
titles += [""]
|
||||
|
||||
podChunks = [pods[x:x+2] for x in range(0, len(pods), 2)]
|
||||
titleChucks = [titles[x:x+2] for x in range(0, len(titles), 2)]
|
||||
podChunks = [pods[x:x+2] for x in range(0, len(pods), 2)]
|
||||
titleChucks = [titles[x:x+2] for x in range(0, len(titles), 2)]
|
||||
await ctx.send(f"Response for \"{content}\"")
|
||||
|
||||
for x, chunk in enumerate(podChunks):
|
||||
width = 0
|
||||
for title in titleChucks[x]:
|
||||
width = max(width,fnt.getsize(title)[0])
|
||||
height = 5
|
||||
heights = []
|
||||
for count, pod in enumerate(chunk):
|
||||
heights += [height]
|
||||
width = max(width,int(list(pod.img)[0]["@width"]))
|
||||
if titleChucks[x][count] == "":
|
||||
placeForText = 0
|
||||
else:
|
||||
placeForText = 30
|
||||
height += int(list(pod.img)[0]["@height"]) + 10 + placeForText
|
||||
for x, chunk in enumerate(podChunks):
|
||||
width = 0
|
||||
for title in titleChucks[x]:
|
||||
width = max(width,fnt.getsize(title)[0])
|
||||
height = 5
|
||||
heights = []
|
||||
for count, pod in enumerate(chunk):
|
||||
heights += [height]
|
||||
width = max(width,int(list(pod.img)[0]["@width"]))
|
||||
if titleChucks[x][count] == "":
|
||||
placeForText = 0
|
||||
else:
|
||||
placeForText = 30
|
||||
height += int(list(pod.img)[0]["@height"]) + 10 + placeForText
|
||||
|
||||
width += 10
|
||||
height += 5
|
||||
wolfImage = Image.new("RGB",(width,height),color=(255,255,255))
|
||||
width += 10
|
||||
height += 5
|
||||
wolfImage = Image.new("RGB",(width,height),color=(255,255,255))
|
||||
|
||||
for count, pod in enumerate(chunk):
|
||||
response = requests.get(list(pod.img)[0]["@src"])
|
||||
file = open("resources/wolfTemp.png", "wb")
|
||||
file.write(response.content)
|
||||
file.close()
|
||||
oldImage = Image.open("resources/wolfTemp.png")
|
||||
oldSize = oldImage.size
|
||||
if titleChucks[x][count] == "":
|
||||
placeForText = 0
|
||||
else:
|
||||
placeForText = 30
|
||||
newSize = (width,int(oldSize[1]+10+placeForText))
|
||||
newImage = Image.new("RGB",newSize,color=(255,255,255))
|
||||
newImage.paste(oldImage, (int((int(oldSize[0]+10)-oldSize[0])/2),int(((newSize[1]-placeForText)-oldSize[1])/2)+placeForText))
|
||||
if titleChucks[x][count] != "":
|
||||
d = ImageDraw.Draw(newImage,"RGB")
|
||||
d.text((5,7),titleChucks[x][count],font=fnt,fill=(150,150,150))
|
||||
for count, pod in enumerate(chunk):
|
||||
response = requests.get(list(pod.img)[0]["@src"])
|
||||
file = open("resources/wolfTemp.png", "wb")
|
||||
file.write(response.content)
|
||||
file.close()
|
||||
oldImage = Image.open("resources/wolfTemp.png")
|
||||
oldSize = oldImage.size
|
||||
if titleChucks[x][count] == "":
|
||||
placeForText = 0
|
||||
else:
|
||||
placeForText = 30
|
||||
newSize = (width,int(oldSize[1]+10+placeForText))
|
||||
newImage = Image.new("RGB",newSize,color=(255,255,255))
|
||||
newImage.paste(oldImage, (int((int(oldSize[0]+10)-oldSize[0])/2),int(((newSize[1]-placeForText)-oldSize[1])/2)+placeForText))
|
||||
if titleChucks[x][count] != "":
|
||||
d = ImageDraw.Draw(newImage,"RGB")
|
||||
d.text((5,7),titleChucks[x][count],font=fnt,fill=(150,150,150))
|
||||
|
||||
wolfImage.paste(newImage,(0,heights[count]))
|
||||
newImage.close()
|
||||
oldImage.close()
|
||||
count += 1
|
||||
wolfImage.paste(newImage,(0,heights[count]))
|
||||
newImage.close()
|
||||
oldImage.close()
|
||||
count += 1
|
||||
|
||||
wolfImage.save("resources/wolf.png")
|
||||
wolfImage.close()
|
||||
await ctx.message.channel.send(file = discord.File("resources/wolf.png"))
|
||||
wolfImage.save("resources/wolf.png")
|
||||
wolfImage.close()
|
||||
await ctx.send(file = discord.File("resources/wolf.png"))
|
||||
|
||||
os.remove("resources/wolf.png")
|
||||
os.remove("resources/wolfTemp.png")
|
||||
else:
|
||||
logThis("No returned data")
|
||||
await ctx.message.channel.send("Could not find anything relating to your search")
|
||||
os.remove("resources/wolf.png")
|
||||
os.remove("resources/wolfTemp.png")
|
||||
else:
|
||||
logThis("No returned data")
|
||||
await ctx.send("Could not find anything relating to your search")
|
Reference in New Issue
Block a user