From 4ee9662c95c2a4db43d0a75462589154a4e40692 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 4 Mar 2016 20:16:53 +0100 Subject: [PATCH] Aggiunto /lolhistory --- bot.py | 20 ++++++++++++++++++++ lol.py | 5 +++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/bot.py b/bot.py index 92e6a24d..7fe93788 100644 --- a/bot.py +++ b/bot.py @@ -621,6 +621,26 @@ while True: lolfreestring += "*" + staticdata['name'] + "* " + staticdata['title'] + '\n' print("Completato.") telegram.sendmessage(lolfreestring, sentin, source) + elif text.startswith('/lolhistory'): + # Visualizza le tue partite recenti di LoL + print("@" + username + ": /lolhistory") + # Informa Telegram che il messaggio รจ stato ricevuto. + telegram.sendchataction(sentin) + sendme = "*Ultime 5 ranked giocate:*\n" + cmd = text.split(" ", 1) + if "lol" in royalgames[username.lower()]: + r = lol.getmatchlist(royalgames[username.lower()]['lol']) + if len(match) > 0: + for match in r[:5]: + sd = lol.getchampionstaticdata(match['champion']) + sendme += "`{0}` {1} ({2})\n".format(str(match['matchId']), + sd['name'], + match['lane']) + telegram.sendmessage(sendme, sentin, source) + else: + telegram.sendmessage(chr(9888) + " Non hai mai giocato ranked.", sentin, source) + else: + telegram.sendmessage(chr(9888) + " Non hai un account di LoL nel database.", sentin, source) elif text.startswith('/crash'): # Crasha il bot. Mi sembra geniale. if username == 'Steffo': diff --git a/lol.py b/lol.py index 481ca365..8d2fbb26 100644 --- a/lol.py +++ b/lol.py @@ -32,5 +32,6 @@ def getmatchlist(sid): 'region': "euw", 'api_key': lolkey, } - r = requests.get("https://euw.api.pvp.net/api/lol/euw/v2.2/matchlist/by-summoner/" + sid, params=parametri).json() - return r['matches'] + r = requests.get("https://euw.api.pvp.net/api/lol/euw/v2.2/matchlist/by-summoner/" + str(sid), params=parametri)\ + .json() + return r