changed onomancer endpoint to allow for / characters

This commit is contained in:
Sakimori 2020-12-20 01:31:48 -05:00
parent 1be65a16b3
commit 4b9af3a967
3 changed files with 4 additions and 8 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
@ -45,7 +44,7 @@ async def on_message(msg):
elif msg.channel.id == config()["soulscream channel id"]: elif msg.channel.id == config()["soulscream channel id"]:
try: try:
await msg.channel.send(ono.get_stats(msg.author.nick)) await msg.channel.send(ono.get_stats(msg.author.nick))
except TypeError: except TypeError or AttributeError:
await msg.channel.send(ono.get_stats(msg.author.name)) await msg.channel.send(ono.get_stats(msg.author.name))
elif command == "credit": elif command == "credit":