- Introducing the new command $lol_lastgame !

This commit is contained in:
Florian SYLVAIN
2021-03-08 02:06:31 +01:00
parent 5f25e3f820
commit 502f5b4fe7
4 changed files with 79 additions and 2 deletions
+27
View File
@@ -1,5 +1,6 @@
from riotwatcher import LolWatcher, ApiError
from private import TOKEN_RIOT
from datetime import datetime, timedelta
WATCHER = LolWatcher(TOKEN_RIOT)
REGION = 'EUW1'
@@ -10,6 +11,7 @@ def what_player(name):
except ApiError:
return 0
def rank_track(player):
ranked_stats = WATCHER.league.by_summoner(REGION, player['id'])
if not ranked_stats:
@@ -22,3 +24,28 @@ def rank_track(player):
what_rank = 'Flexible'
liste.append([what_rank, infos['tier'], infos['rank'], infos['leaguePoints'], infos['wins'], infos['losses']])
return liste
def last_match(player):
matches = WATCHER.match.matchlist_by_account('EUW1', player['accountId'])
recent_match = matches['matches'][0]
match_detail = WATCHER.match.by_id('EUW1', recent_match['gameId'])
lst = [[],[[],[]]]
for x, y in zip(match_detail['participants'], match_detail['participantIdentities']):
lst[0].append([y['player']['summonerName'],
x['stats']['totalDamageDealtToChampions'],
x['stats']['kills'],
x['stats']['deaths'],
x['stats']['assists']])
for team in match_detail['teams']:
lst[1][0].append(team['win'])
lst[1][1].append(team['firstBlood'])
ts = str(match_detail['gameCreation'])[:-3]
dt = datetime.fromtimestamp(int(ts)).date()
lst.append(str(dt))
lst.append(str(timedelta(seconds=match_detail['gameDuration'])))
return lst