changed onomancer endpoint to allow for / characters

This commit is contained in:
Sakimori 2020-12-20 01:31:48 -05:00
parent 1be65a16b3
commit 6fd4120b8f
3 changed files with 5 additions and 7 deletions

View File

@ -42,7 +42,6 @@ def get_soulscream(username):
try: try:
cachetime = datetime.datetime.fromisoformat(scream[3]) cachetime = datetime.datetime.fromisoformat(scream[3])
print(datetime.datetime.now(datetime.timezone.utc) - cachetime)
if datetime.datetime.now(datetime.timezone.utc) - cachetime >= datetime.timedelta(days = 7): if datetime.datetime.now(datetime.timezone.utc) - cachetime >= datetime.timedelta(days = 7):
#delete old cache #delete old cache
c.execute("DELETE FROM soulscreams WHERE name=?", (username,)) c.execute("DELETE FROM soulscreams WHERE name=?", (username,))

View File

@ -1,12 +1,11 @@
#interfaces with onomancer #interfaces with onomancer
import requests import requests, json, urllib
import json
import database as db import database as db
onomancer_url = "https://onomancer.sibr.dev/api/" onomancer_url = "https://onomancer.sibr.dev/api/"
name_stats_hook = "generateStats/" name_stats_hook = "generateStats2?name="
def get_stats(username): def get_stats(username):
#check database for cached name first #check database for cached name first
@ -15,8 +14,7 @@ def get_stats(username):
return scream return scream
#yell at onomancer if not in cache or too old #yell at onomancer if not in cache or too old
response = requests.get(onomancer_url + name_stats_hook + username) response = requests.get(onomancer_url + name_stats_hook + urllib.parse.quote_plus(username))
print("yelled at onomancer")
if response.status_code == 200: if response.status_code == 200:
db.cache_soulscream(username, response.json()["soulscream"]) db.cache_soulscream(username, response.json()["soulscream"])
return response.json()["soulscream"] return response.json()["soulscream"]

View File

@ -35,7 +35,6 @@ async def on_message(msg):
if msg.content.startswith(prefix): if msg.content.startswith(prefix):
command_b = True command_b = True
command = msg.content.split(prefix, 1)[1] command = msg.content.split(prefix, 1)[1]
print(command)
if not command_b: if not command_b:
return return
@ -47,6 +46,8 @@ async def on_message(msg):
await msg.channel.send(ono.get_stats(msg.author.nick)) await msg.channel.send(ono.get_stats(msg.author.nick))
except TypeError: except TypeError:
await msg.channel.send(ono.get_stats(msg.author.name)) await msg.channel.send(ono.get_stats(msg.author.name))
except AttributeError:
await msg.channel.send(ono.get_stats(msg.author.name))
elif command == "credit": elif command == "credit":
await msg.channel.send("Our avatar was graciously provided to us, with permission, by @HetreaSky on Twitter.") await msg.channel.send("Our avatar was graciously provided to us, with permission, by @HetreaSky on Twitter.")