From 2a0fe821b7f189b6ec6fc73f2d665a2750c1f74c Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 3 Oct 2016 09:24:50 +0200 Subject: [PATCH 01/11] Cosa volevo fare con quello? --- bot.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/bot.py b/bot.py index 88862281..275d25ec 100644 --- a/bot.py +++ b/bot.py @@ -22,9 +22,6 @@ random.seed() # Livello di balurage dall'ultimo riavvio ragelevel = 0 -# Pepperoni secret -secretlevel = 0 - # Spostiamo qui le funzioni del bot, così è un po' più leggibile def wow(): From 72c6a02a67364a89b2fb294a55dc4b90757f7e3c Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 3 Oct 2016 09:27:09 +0200 Subject: [PATCH 02/11] Messo ragelevel in un file a parte ragelevel.txt --- bot.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/bot.py b/bot.py index 275d25ec..2e414834 100644 --- a/bot.py +++ b/bot.py @@ -19,9 +19,6 @@ lolfreestring = str() random.seed() -# Livello di balurage dall'ultimo riavvio -ragelevel = 0 - # Spostiamo qui le funzioni del bot, così è un po' più leggibile def wow(): @@ -440,9 +437,9 @@ def balurage(): print("@" + username + ": /balurage") # Rispondi commentando l'E3. tosend = str() - # TODO: Sostituiscimi con un file! - global ragelevel + ragelevel = filemanager.readfile("ragelevel.txt") ragelevel += 1 + filemanager.writefile("ragelevel.txt", ragelevel) for rage in range(0, ragelevel): tosend += "MADDEN " telegram.sendmessage(tosend, sentin, source) From 990031465d7e6596291f52543346e7499cf2f082 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 3 Oct 2016 09:37:16 +0200 Subject: [PATCH 03/11] Migliorato /cv --- bot.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/bot.py b/bot.py index 2e414834..9e272311 100644 --- a/bot.py +++ b/bot.py @@ -308,14 +308,15 @@ def cv(): if 'channel_id' in member: # Controlla il suo stato (esclusa, mutata, normale) e scegli l'emoji appropriata if member['deaf'] or member['self_deaf']: - m['emoji'] = chr(128263) + m['vemoji'] = chr(128263) elif member['mute'] or member['self_mute']: - m['emoji'] = chr(128264) + m['vemoji'] = chr(128264) else: - m['emoji'] = chr(128266) + m['vemoji'] = chr(128266) m['channelname'] = discord.getchannelname(r, member['channel_id']) # Altrimenti else: + m['vemoji'] = "" # Controlla il suo stato (online, in gioco, afk) e scegli l'emoji appropriata if member['status'] == "online": m['emoji'] = chr(128309) @@ -334,18 +335,16 @@ def cv(): member['username'] = m['nick'] else: m['name'] = member['username'] - if 'gamename' in m and 'channelname' in m: - tosend += "{emoji} *{channelname}* {name} | _{gamename}_\n".format(**m) + tosend += "{emoji} {name}".format(emoji=m['emoji'], name=m['name']) elif 'gamename' in m: - tosend += "{emoji} {name} | _{gamename}_\n".format(**m) + tosend += " | _{gamename}_".format(gamename=m['gamename']) elif 'channelname' in m: - tosend += "{emoji} *{channelname}* {name}\n".format(**m) - else: - tosend += "{emoji} {name}\n".format(**m) + tosend += " | {vemoji} *{channelname}*".format(vemoji=m['vemoji'], channelname=m['channelname']) + tosend += "\n" # Controlla se l'utente è royal music elif member['id'] == "176358898851250176": if 'game' in member: - tosend += "{emoji} *{channelname}* {songname}\n" \ + tosend += "{emoji} Music | {emoji} *{channelname}* | {songname}\n" \ .format(emoji="\U0001F3B5", channelname=discord.getchannelname(r, member['channel_id']), songname=member['game']['name']) telegram.sendmessage(tosend, sentin, source) From fa5bc2ac49f9f748d59d425dc9ba59a56f8fcef4 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 3 Oct 2016 09:37:49 +0200 Subject: [PATCH 04/11] lol? --- bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot.py b/bot.py index 9e272311..3d42f80c 100644 --- a/bot.py +++ b/bot.py @@ -12,7 +12,7 @@ import subprocess import sm.steammatch as steammatch # Elenco di username dei membri della RYG -royalgames = json.loads(filemanager.readfile("db.json")) +royalgames = json.load("db.json") # Stringa dove mettere l'elenco di champion di lol gratuiti lolfreestring = str() From 0694746aa2671ddba501f3e227cc0eb211f6ace9 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 3 Oct 2016 09:41:09 +0200 Subject: [PATCH 05/11] Sistemati casi improbabili in /match --- bot.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/bot.py b/bot.py index 3d42f80c..f42836da 100644 --- a/bot.py +++ b/bot.py @@ -519,14 +519,17 @@ def match(): tobematched.append(royalgames[name.lower()]["steam"]) if len(tobematched) > 1: m = list(steammatch.compare(tobematched)) - # Prepara il messaggio - tosend = str() - for game in m: - tosend += "- {game}\n".format(game=game) - # Manda il messaggio - telegram.sendmessage(tosend, sentin, source) + if len(m) > 0: + # Prepara il messaggio + tosend = "*Giochi in comune tra questi utenti:*\n" + for game in m: + tosend += "- {game}\n".format(game=game) + # Manda il messaggio + telegram.sendmessage(tosend, sentin, source) + else: + telegram.sendmessage("*Giochi in comune tra questi utenti:*\n_nessuno_", sentin, source) else: - telegram.sendmessage(chr(9888) + "Non sono stati specificati abbastanza utenti per eseguire l'intersezione.", + telegram.sendmessage(chr(9888) + "Non sono stati specificati abbastanza utenti per eseguire l'azione.", sentin, source) From 9465fa37555862df3655cc8d92d4c113ee1927e0 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 3 Oct 2016 09:46:58 +0200 Subject: [PATCH 06/11] Nuovi smecds --- bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot.py b/bot.py index f42836da..336b3c28 100644 --- a/bot.py +++ b/bot.py @@ -491,7 +491,7 @@ def smecds(): "della sedia", "di Satana", "del Sangue (degli occhi di Adry)", "del Sale", "del Serpente", "della Samsung", "di /smecds", "della succursale", "di succ", "di Sans", "di [SiivaGunner](https://www.youtube.com/channel/UC9ecwl3FTG66jIKA9JRDtmg)", - "di saaaaaas"], 1)[0] + "di saaaaaas", "del semaforo", "della Seriale", "di Sistemi"], 1)[0] telegram.sendmessage("Secondo me è colpa {accusato}...".format(accusato=accusato), sentin, source) From 3c4cd694f1a0c5cfdd130515c74968c018afc433 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 3 Oct 2016 09:51:12 +0200 Subject: [PATCH 07/11] =?UTF-8?q?Un=20modo=20pi=C3=B9=20veloce=20per=20tro?= =?UTF-8?q?vare=20le=20persone=20nel=20db?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 db.py diff --git a/db.py b/db.py new file mode 100644 index 00000000..683cb1f5 --- /dev/null +++ b/db.py @@ -0,0 +1,17 @@ +import json + +db = json.load("db.json") + +def findname(name: str): + for player in db: + if player == name: + return db[player] + else: + return None + +def findbykey(key, value): + for player in db: + if player[key] == value: + return db[player] + else: + return None From c9f3ecb92dec83577449089c55314f695caf347a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 3 Oct 2016 09:54:00 +0200 Subject: [PATCH 08/11] Usiamo db.py per /match --- bot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index 336b3c28..c1c87ad3 100644 --- a/bot.py +++ b/bot.py @@ -10,6 +10,7 @@ import lol import discord import subprocess import sm.steammatch as steammatch +import db # Elenco di username dei membri della RYG royalgames = json.load("db.json") @@ -514,9 +515,8 @@ def match(): if len(cmd) > 2: del cmd[0] for name in cmd: - if name.lower() in royalgames: - if "steam" in royalgames[name.lower()]: - tobematched.append(royalgames[name.lower()]["steam"]) + userdata = db.findbyname(name) + tobematched += userdata['steam'] if len(tobematched) > 1: m = list(steammatch.compare(tobematched)) if len(m) > 0: From 4eec3cf5052c3013f79197f6ac5200cf78e9a3e9 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 3 Oct 2016 15:49:30 +0200 Subject: [PATCH 09/11] Some fixes --- bot.py | 2 +- db.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bot.py b/bot.py index c1c87ad3..e690fee5 100644 --- a/bot.py +++ b/bot.py @@ -337,7 +337,7 @@ def cv(): else: m['name'] = member['username'] tosend += "{emoji} {name}".format(emoji=m['emoji'], name=m['name']) - elif 'gamename' in m: + if 'gamename' in m: tosend += " | _{gamename}_".format(gamename=m['gamename']) elif 'channelname' in m: tosend += " | {vemoji} *{channelname}*".format(vemoji=m['vemoji'], channelname=m['channelname']) diff --git a/db.py b/db.py index 683cb1f5..537a7718 100644 --- a/db.py +++ b/db.py @@ -2,13 +2,15 @@ import json db = json.load("db.json") -def findname(name: str): + +def findbyname(name: str): for player in db: if player == name: return db[player] else: return None + def findbykey(key, value): for player in db: if player[key] == value: From fd06309d3208b3060f9deba6b64dbab02f0a7d63 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 3 Oct 2016 15:52:05 +0200 Subject: [PATCH 10/11] Fixato /ehoh --- bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot.py b/bot.py index e690fee5..9ba7bd63 100644 --- a/bot.py +++ b/bot.py @@ -100,7 +100,7 @@ def steamplayers(): def ehoh(): print("@" + username + ": /ehoh") # Rispondi con Eh, oh. Sono cose che capitano. - telegram.sendmessage("Eh, oh. Sono cose che capitano. ¯\_(ツ)_/¯", sentin, source) + telegram.sendmessage("Eh, oh. Sono cose che capitano.", sentin, source) def sbam(): From 586b6466b768416f0ae0b7a481398477086b499f Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 3 Oct 2016 15:58:24 +0200 Subject: [PATCH 11/11] Un nuovo smecds --- bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot.py b/bot.py index 9ba7bd63..91c8ec37 100644 --- a/bot.py +++ b/bot.py @@ -492,7 +492,7 @@ def smecds(): "della sedia", "di Satana", "del Sangue (degli occhi di Adry)", "del Sale", "del Serpente", "della Samsung", "di /smecds", "della succursale", "di succ", "di Sans", "di [SiivaGunner](https://www.youtube.com/channel/UC9ecwl3FTG66jIKA9JRDtmg)", - "di saaaaaas", "del semaforo", "della Seriale", "di Sistemi"], 1)[0] + "di saaaaaas", "del semaforo", "della Seriale", "di Sistemi", "della Supercell"], 1)[0] telegram.sendmessage("Secondo me è colpa {accusato}...".format(accusato=accusato), sentin, source)