functional soulscream retriever

This commit is contained in:
Sakimori 2020-12-19 20:26:05 -05:00
parent 25e16c42c4
commit 30886ce7b9
6 changed files with 39 additions and 13 deletions

1
.gitignore vendored
View File

@ -341,3 +341,4 @@ healthchecksdb
# Personal config file, contains bot token
config.json
ids

View File

@ -2,5 +2,10 @@
"token": "Nzg5OTU2MTY2Nzk2NTc0NzQw.X95mAg.gQBAAQZMy5-a70fVtT50YiYO4oc",
"owners": [
102691114762371072
]
],
"prefix": [
"m;",
"m!"
],
"soulscream channel id": 790005613110493276
}

View File

@ -1,8 +1,3 @@
#handles the database interactions
import sqlite3 as sql

View File

@ -2,11 +2,16 @@
import requests
import json
import database as db
onomancer_url = "https://onomancer.sibr.dev/api/"
name_stats_hook = "generateStats/"
def get_stats(username):
#check database for cached name first
#yell at onomancer
response = requests.get(onomancer_url + name_stats_hook + username)
if response.status_code == 200:
return response.json
return response.json()

View File

@ -41,6 +41,10 @@
<Architecture>X86</Architecture>
</Interpreter>
</ItemGroup>
<ItemGroup>
<Content Include="config.json" />
<Content Include="ids" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
<!-- Uncomment the CoreCompile target to enable the Build command in
Visual Studio and specify your pre- and post-build commands in

View File

@ -2,6 +2,7 @@ import discord
import json
import database as db
import os
import onomancer as ono
client = discord.Client()
@ -12,7 +13,9 @@ def config():
"token" : "",
"owners" : [
0000
]
],
"prefix" : ["m;", "m!"],
"soulscream channel id" : 0
}
with open("config.json", "w") as config_file:
json.dump(config_dic, config_file, indent=4)
@ -28,7 +31,20 @@ async def on_ready():
@client.event
async def on_message(msg):
print(
command = False
for prefix in config()["prefix"]:
if msg.content.startswith(prefix):
command = True
command_s = msg.content.split(prefix, 1)
if not command:
return
if msg.channel.id == config()["soulscream channel id"]:
try:
await msg.channel.send(ono.get_stats(msg.author.nick)["soulscream"])
except TypeError:
await msg.channel.send(ono.get_stats(msg.author.name)["soulscream"])
client.run(config()["token"])