switch to environment variables

This commit is contained in:
2023-09-05 16:57:38 +02:00
parent a8e7f0c882
commit d04f3b63e3
7 changed files with 12 additions and 11 deletions
+2 -1
View File
@@ -1,3 +1,4 @@
import os
import datetime import datetime
from PIL import Image, ImageDraw, ImageFont from PIL import Image, ImageDraw, ImageFont
import discord import discord
@@ -5,7 +6,7 @@ import requests
def getleaderboard(board:str, weaponid="", server="", mapid = "", gamemodeid = ""): def getleaderboard(board:str, weaponid="", server="", mapid = "", gamemodeid = ""):
payload = {"weapon": weaponid, "server": server, "map": mapid, "gamemode": gamemodeid} payload = {"weapon": weaponid, "server": server, "map": mapid, "gamemode": gamemodeid}
response = requests.get('https://tone.sleepycat.date/v2/client/players', params=payload).json() response = requests.get(os.environ.get("TONE_ENDPOINT") + '/v2/client/players', params=payload).json()
players = response.keys() players = response.keys()
if(board.lower() == "totald"): if(board.lower() == "totald"):
board = "total_distance" board = "total_distance"
+2 -1
View File
@@ -1,6 +1,7 @@
import os
async def getserver(s,snippet): async def getserver(s,snippet):
server = "" server = ""
async with s.get('https://tone.sleepycat.date/v2/client/servers') as r: async with s.get(os.environ.get("TONE_ENDPOINT") + '/v2/client/servers') as r:
response = await r.json() response = await r.json()
servers = response.keys() servers = response.keys()
for i in servers: for i in servers:
+2 -2
View File
@@ -1,5 +1,5 @@
import asyncio import asyncio
import os
import discord import discord
import requests import requests
@@ -46,7 +46,7 @@ async def get_allplayer_stats(s, playerids, weaponid = "", weaponname= "",server
async def getstats(s, playerid, weaponid = "", server = "", mapid = "" , gamemodeid = ""): async def getstats(s, playerid, weaponid = "", server = "", mapid = "" , gamemodeid = ""):
payload = {'player': playerid, 'weapon': weaponid, 'server': server, 'gamemode': gamemodeid, 'map' : mapid} payload = {'player': playerid, 'weapon': weaponid, 'server': server, 'gamemode': gamemodeid, 'map' : mapid}
async with s.get('https://tone.sleepycat.date/v2/client/players', params=payload) as r: async with s.get(os.environ.get("TONE_ENDPOINT") + '/v2/client/players', params=payload) as r:
response = await r.json() response = await r.json()
if(response == {}): if(response == {}):
async with s.get("https://northstar.tf/accounts/get_username", params={"uid": playerid}) as Er: async with s.get("https://northstar.tf/accounts/get_username", params={"uid": playerid}) as Er:
+1 -1
View File
@@ -3,7 +3,7 @@ import requests
def valueschartgamemode(playerid, weaponid): def valueschartgamemode(playerid, weaponid):
payload = {'player': playerid, 'weapon': weaponid} payload = {'player': playerid, 'weapon': weaponid}
response = requests.get('https://tone.sleepycat.date/v2/client/gamemodes', params=payload).json() response = requests.get(os.environ.get("TONE_ENDPOINT") + '/v2/client/gamemodes', params=payload).json()
gamemode_color = {'aitdm':(1, 0.0, 0.0),'at':(1, 0.375, 0.0),'chamber':(1, 0.75, 0.0),'cp':(0.875, 1, 0.0),'ctf':(0.5, 1, 0.0),'fd':(0.125, 1, 0.0),'ffa':(0.0, 1, 0.25),'fw':(0.0, 1, 0.625),'gg':(0.0, 1.0, 1),'inf':(0.0, 0.625, 1),'lts':(0.0, 0.25, 1),'mfd':(0.125, 0.0, 1),'ps':(0.5, 0.0, 1),'sns':(0.875, 0.0, 1), 'tdm':(1, 0.0, 0.75),'ttdm':(1, 0.0, 0.375), 'other': (1, 0.0, 1)} gamemode_color = {'aitdm':(1, 0.0, 0.0),'at':(1, 0.375, 0.0),'chamber':(1, 0.75, 0.0),'cp':(0.875, 1, 0.0),'ctf':(0.5, 1, 0.0),'fd':(0.125, 1, 0.0),'ffa':(0.0, 1, 0.25),'fw':(0.0, 1, 0.625),'gg':(0.0, 1.0, 1),'inf':(0.0, 0.625, 1),'lts':(0.0, 0.25, 1),'mfd':(0.125, 0.0, 1),'ps':(0.5, 0.0, 1),'sns':(0.875, 0.0, 1), 'tdm':(1, 0.0, 0.75),'ttdm':(1, 0.0, 0.375), 'other': (1, 0.0, 1)}
gamemode_dict = {'aitdm':'Attrition','at':'Bounty Hunt','chamber':'One in the Chamber','cp':'Amped Hardpoint','ctf':'Capture the Flag','fd':'Frontier Defense','ffa':'Free for All','fw':'Frontier War','gg':'GunGame','inf':'Infection','lts':'Last Titan Standing','mfd':'Marked for Death','ps':'Pilots Vs. Pilots','sns':'Sticks and Stones','tdm':'Skirmish','ttdm':'Titan Brawl'} gamemode_dict = {'aitdm':'Attrition','at':'Bounty Hunt','chamber':'One in the Chamber','cp':'Amped Hardpoint','ctf':'Capture the Flag','fd':'Frontier Defense','ffa':'Free for All','fw':'Frontier War','gg':'GunGame','inf':'Infection','lts':'Last Titan Standing','mfd':'Marked for Death','ps':'Pilots Vs. Pilots','sns':'Sticks and Stones','tdm':'Skirmish','ttdm':'Titan Brawl'}
File diff suppressed because one or more lines are too long
+1 -2
View File
@@ -3,7 +3,6 @@ from discord import app_commands
import discord import discord
import os import os
import asyncio import asyncio
from discordtoken import discordtoken
client = commands.Bot(command_prefix="!", intents=discord.Intents.all()) client = commands.Bot(command_prefix="!", intents=discord.Intents.all())
client.remove_command('help') client.remove_command('help')
@@ -38,6 +37,6 @@ async def main():
async with client: async with client:
await load() await load()
await slashload() await slashload()
await client.start(discordtoken.get()) await client.start(os.environ.get("DISCORD_TOKEN"))
asyncio.run(main()) asyncio.run(main())
+2 -2
View File
@@ -65,7 +65,7 @@ class SlashStats(commands.Cog):
async def autocomplete_player(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice[str]]: async def autocomplete_player(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice[str]]:
data = [] data = []
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
async with session.get('https://tone.sleepycat.date/v2/client/players') as r: async with session.get(os.environ.get("TONE_ENDPOINT") + '/v2/client/players') as r:
players = await r.json() players = await r.json()
for player_choice in players.keys(): for player_choice in players.keys():
@@ -89,7 +89,7 @@ class SlashStats(commands.Cog):
async def autocomplete_server(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice[str]]: async def autocomplete_server(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice[str]]:
data = [] data = []
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
async with session.get('https://tone.sleepycat.date/v2/client/servers') as r: async with session.get(os.environ.get("TONE_ENDPOINT") + '/v2/client/servers') as r:
servers = await r.json() servers = await r.json()
for server_choice in servers.keys(): for server_choice in servers.keys():