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:
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):
#delete old cache
c.execute("DELETE FROM soulscreams WHERE name=?", (username,))

View File

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

View File

@ -35,7 +35,6 @@ async def on_message(msg):
if msg.content.startswith(prefix):
command_b = True
command = msg.content.split(prefix, 1)[1]
print(command)
if not command_b:
return
@ -45,7 +44,7 @@ async def on_message(msg):
elif msg.channel.id == config()["soulscream channel id"]:
try:
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))
elif command == "credit":