🏗 - Moved Riot's API interaction from main.py to riot_api.py

This commit is contained in:
Florian SYLVAIN
2021-03-06 18:08:18 +01:00
parent dce69e12cd
commit ed9f389bce
2 changed files with 18 additions and 12 deletions
+8 -5
View File
@@ -1,16 +1,19 @@
from riotwatcher import LolWatcher
from riotwatcher import LolWatcher, ApiError
from private import TOKEN_RIOT
WATCHER = LolWatcher(TOKEN_RIOT)
REGION = 'EUW1'
def rank_track(player):
'''function that communicate with Riot API'''
ranked_stats = WATCHER.league.by_summoner(REGION, player['id'])
def what_player(name):
try:
return WATCHER.summoner.by_name(REGION, name)
except ApiError:
return 0
def rank_track(player):
ranked_stats = WATCHER.league.by_summoner(REGION, player['id'])
if not ranked_stats:
return 'Unranked cette saison.'
liste = []
for infos in ranked_stats:
if infos['queueType'] == 'RANKED_SOLO_5x5':