-
Notifications
You must be signed in to change notification settings - Fork 7
/
mmr.py
39 lines (34 loc) · 1.4 KB
/
mmr.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import aiohttp
import discord
from mogi_objects import Player
headers = {'Content-type': 'application/json'}
async def mk8dx_150cc_mmr(config, members):
base_url = config["url"] + '/api/player?'
players = []
async with aiohttp.ClientSession() as session:
for member in members:
request_text = f"discordId={member.id}"
request_url = base_url + request_text
async with session.get(request_url,headers=headers) as resp:
if resp.status != 200:
players.append(None)
continue
player_data = await resp.json()
if 'mmr' not in player_data.keys():
players.append(None)
continue
players.append(Player(member, player_data['name'], player_data['mmr']))
return players
async def get_mmr(config, members):
return await mk8dx_150cc_mmr(config, members)
async def mk8dx_150cc_fc(config, name):
base_url = config["url"] + '/api/player?'
request_url = base_url + f'name={name}'
async with aiohttp.ClientSession() as session:
async with session.get(request_url, headers=headers) as resp:
if resp.status != 200:
return None
player_data = await resp.json()
if 'switchFc' not in player_data.keys():
return None
return player_data['switchFc']