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 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
|
||||
@client.event
|
||||
@d_client.event
|
||||
async def on_ready():
|
||||
print("Connessione riuscita!")
|
||||
print(client.user.name)
|
||||
print(client.user.id)
|
||||
print(d_client.user.name)
|
||||
print(d_client.user.id)
|
||||
|
||||
|
||||
# Get the discord bot token from "discordtoken.txt"
|
||||
f = open("discordtoken.txt", "r")
|
||||
|
@ -16,4 +24,11 @@ token = f.read()
|
|||
f.close()
|
||||
|
||||
# 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 requests
|
||||
import json
|
||||
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
|
||||
async def get_player_data(platform: str, region: str, battletag: str):
|
||||
# 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:
|
||||
return r.json()
|
||||
elif r.status_code == 404:
|
||||
raise Exception("Player not found.")
|
||||
|
||||
loop.run_until_complete(get_player_data("pc", "eu", "SteffoRYG#2876"))
|
||||
raise Exception("Player not found.")
|
Loading…
Reference in a new issue