functional soulscream retriever
This commit is contained in:
parent
25e16c42c4
commit
30886ce7b9
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -341,3 +341,4 @@ healthchecksdb
|
||||||
|
|
||||||
# Personal config file, contains bot token
|
# Personal config file, contains bot token
|
||||||
config.json
|
config.json
|
||||||
|
ids
|
13
config.json
13
config.json
|
@ -1,6 +1,11 @@
|
||||||
{
|
{
|
||||||
"token": "Nzg5OTU2MTY2Nzk2NTc0NzQw.X95mAg.gQBAAQZMy5-a70fVtT50YiYO4oc",
|
"token": "Nzg5OTU2MTY2Nzk2NTc0NzQw.X95mAg.gQBAAQZMy5-a70fVtT50YiYO4oc",
|
||||||
"owners": [
|
"owners": [
|
||||||
102691114762371072
|
102691114762371072
|
||||||
]
|
],
|
||||||
|
"prefix": [
|
||||||
|
"m;",
|
||||||
|
"m!"
|
||||||
|
],
|
||||||
|
"soulscream channel id": 790005613110493276
|
||||||
}
|
}
|
|
@ -1,8 +1,3 @@
|
||||||
#handles the database interactions
|
#handles the database interactions
|
||||||
|
|
||||||
import sqlite3 as sql
|
import sqlite3 as sql
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,16 @@
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
|
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 = "generateStats/"
|
||||||
|
|
||||||
def get_stats(username):
|
def get_stats(username):
|
||||||
|
#check database for cached name first
|
||||||
|
|
||||||
|
#yell at onomancer
|
||||||
response = requests.get(onomancer_url + name_stats_hook + username)
|
response = requests.get(onomancer_url + name_stats_hook + username)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
return response.json
|
return response.json()
|
|
@ -41,6 +41,10 @@
|
||||||
<Architecture>X86</Architecture>
|
<Architecture>X86</Architecture>
|
||||||
</Interpreter>
|
</Interpreter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="config.json" />
|
||||||
|
<Content Include="ids" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
|
||||||
<!-- Uncomment the CoreCompile target to enable the Build command in
|
<!-- Uncomment the CoreCompile target to enable the Build command in
|
||||||
Visual Studio and specify your pre- and post-build commands in
|
Visual Studio and specify your pre- and post-build commands in
|
||||||
|
|
|
@ -2,6 +2,7 @@ import discord
|
||||||
import json
|
import json
|
||||||
import database as db
|
import database as db
|
||||||
import os
|
import os
|
||||||
|
import onomancer as ono
|
||||||
|
|
||||||
client = discord.Client()
|
client = discord.Client()
|
||||||
|
|
||||||
|
@ -12,7 +13,9 @@ def config():
|
||||||
"token" : "",
|
"token" : "",
|
||||||
"owners" : [
|
"owners" : [
|
||||||
0000
|
0000
|
||||||
]
|
],
|
||||||
|
"prefix" : ["m;", "m!"],
|
||||||
|
"soulscream channel id" : 0
|
||||||
}
|
}
|
||||||
with open("config.json", "w") as config_file:
|
with open("config.json", "w") as config_file:
|
||||||
json.dump(config_dic, config_file, indent=4)
|
json.dump(config_dic, config_file, indent=4)
|
||||||
|
@ -28,7 +31,20 @@ async def on_ready():
|
||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
async def on_message(msg):
|
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"])
|
client.run(config()["token"])
|
Loading…
Reference in New Issue
Block a user