mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Moved some things around
This commit is contained in:
parent
e1dafb9528
commit
43d5bec4b7
2 changed files with 21 additions and 20 deletions
25
main.py
25
main.py
|
@ -1,14 +1,22 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import discord
|
import discord
|
||||||
client = discord.Client()
|
import json
|
||||||
|
import overwatch
|
||||||
|
d_client = discord.Client()
|
||||||
|
|
||||||
|
# Get player database from the db.json file
|
||||||
|
file = open("db.json")
|
||||||
|
db = json.load(file)
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
|
||||||
# When the discord client is ready, print something
|
# When the discord client is ready, print something
|
||||||
@client.event
|
@d_client.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
print("Connessione riuscita!")
|
print("Connessione riuscita!")
|
||||||
print(client.user.name)
|
print(d_client.user.name)
|
||||||
print(client.user.id)
|
print(d_client.user.id)
|
||||||
|
|
||||||
|
|
||||||
# Get the discord bot token from "discordtoken.txt"
|
# Get the discord bot token from "discordtoken.txt"
|
||||||
f = open("discordtoken.txt", "r")
|
f = open("discordtoken.txt", "r")
|
||||||
|
@ -16,4 +24,11 @@ token = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
# Start discord bot client but ignore events
|
# Start discord bot client but ignore events
|
||||||
client.start(token)
|
d_client.start(token)
|
||||||
|
|
||||||
|
# List overwatch players
|
||||||
|
ow_players = list()
|
||||||
|
for player in db:
|
||||||
|
if db[player]["overwatch"] is not None:
|
||||||
|
ow_players.append(db[player]["overwatch"])
|
||||||
|
|
||||||
|
|
16
overwatch.py
16
overwatch.py
|
@ -1,19 +1,7 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import requests
|
import requests
|
||||||
import json
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
|
|
||||||
# Get player database from the db.json file
|
|
||||||
file = open("db.json")
|
|
||||||
db = json.load(file)
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
# List overwatch players
|
|
||||||
players = list()
|
|
||||||
for player in db:
|
|
||||||
if db[player]["overwatch"] is not None:
|
|
||||||
players.append(db[player]["overwatch"])
|
|
||||||
|
|
||||||
# Get player data
|
# Get player data
|
||||||
async def get_player_data(platform: str, region: str, battletag: str):
|
async def get_player_data(platform: str, region: str, battletag: str):
|
||||||
# Unofficial API requires - for discriminator numbers
|
# Unofficial API requires - for discriminator numbers
|
||||||
|
@ -25,6 +13,4 @@ async def get_player_data(platform: str, region: str, battletag: str):
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
return r.json()
|
return r.json()
|
||||||
elif r.status_code == 404:
|
elif r.status_code == 404:
|
||||||
raise Exception("Player not found.")
|
raise Exception("Player not found.")
|
||||||
|
|
||||||
loop.run_until_complete(get_player_data("pc", "eu", "SteffoRYG#2876"))
|
|
Loading…
Reference in a new issue