1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Aggiunto /lolhistory

This commit is contained in:
Steffo 2016-03-04 20:16:53 +01:00
parent 6675d6db18
commit 4ee9662c95
2 changed files with 23 additions and 2 deletions

20
bot.py
View file

@ -621,6 +621,26 @@ while True:
lolfreestring += "*" + staticdata['name'] + "* " + staticdata['title'] + '\n' lolfreestring += "*" + staticdata['name'] + "* " + staticdata['title'] + '\n'
print("Completato.") print("Completato.")
telegram.sendmessage(lolfreestring, sentin, source) 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'): elif text.startswith('/crash'):
# Crasha il bot. Mi sembra geniale. # Crasha il bot. Mi sembra geniale.
if username == 'Steffo': if username == 'Steffo':

5
lol.py
View file

@ -32,5 +32,6 @@ def getmatchlist(sid):
'region': "euw", 'region': "euw",
'api_key': lolkey, 'api_key': lolkey,
} }
r = requests.get("https://euw.api.pvp.net/api/lol/euw/v2.2/matchlist/by-summoner/" + sid, params=parametri).json() r = requests.get("https://euw.api.pvp.net/api/lol/euw/v2.2/matchlist/by-summoner/" + str(sid), params=parametri)\
return r['matches'] .json()
return r