2015-10-07 08:49:14 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2015-10-03 16:41:34 +00:00
|
|
|
import telegram
|
|
|
|
import steam
|
2015-10-08 16:39:56 +00:00
|
|
|
import random
|
2015-11-16 21:55:47 +00:00
|
|
|
import osu
|
2015-12-20 19:05:13 +00:00
|
|
|
import hearthstone
|
|
|
|
import sys
|
2015-10-08 16:39:56 +00:00
|
|
|
|
2015-11-13 17:15:27 +00:00
|
|
|
# Playlist di /rage, si riempie quando è vuota
|
2015-10-08 16:39:56 +00:00
|
|
|
rage = []
|
2015-10-03 16:41:34 +00:00
|
|
|
|
2015-11-20 15:31:46 +00:00
|
|
|
# Elenco degli audio di /wololo
|
|
|
|
wololo = ['BQADAgADWAIAAh8GgAGP53EPnRyiYwI', 'BQADAgADWQIAAh8GgAHIF861pVS1aAI', 'BQADAgADWgIAAh8GgAHdq5n4ZJwVBQI',
|
|
|
|
'BQADAgADWwIAAh8GgAFBI_HmkOU-PgI', 'BQADAgADXAIAAh8GgAFjAmhg3-IOIQI', 'BQADAgADXQIAAh8GgAFf8P21MBzx3gI',
|
|
|
|
'BQADAgADXgIAAh8GgAE5LOgedb-1RQI', 'BQADAgADYAIAAh8GgAFiAcVphkyzRQI', 'BQADAgADYQIAAh8GgAFnZa5sWEQv6QI',
|
|
|
|
'BQADAgADYgIAAh8GgAHdnlwB6ATJogI', 'BQADAgADYwIAAh8GgAGMuHLrY94CXwI', 'BQADAgADZAIAAh8GgAE7SxHEvU6pLAI',
|
|
|
|
'BQADAgADZQIAAh8GgAFfUK7GPQHLhgI', 'BQADAgADZgIAAh8GgAGDx56hsKHh0wI', 'BQADAgADZwIAAh8GgAF3etjqkzFDxAI',
|
|
|
|
'BQADAgADaAIAAh8GgAHCsHs0NNMnAwI', 'BQADAgADaQIAAh8GgAGEQP7WW-gVhAI', 'BQADAgADagIAAh8GgAHrOerh1qI1jgI',
|
|
|
|
'BQADAgADawIAAh8GgAFR8ckrXWOw6gI', 'BQADAgADbAIAAh8GgAFaQm4cTda94AI', 'BQADAgADbQIAAh8GgAG2X-qRdGpmewI',
|
|
|
|
'BQADAgADbgIAAh8GgAHzrM2auYrj-AI', 'BQADAgADbwIAAh8GgAFq5jafCpl8PAI', 'BQADAgADcAIAAh8GgAGY69r5eir53QI',
|
|
|
|
'BQADAgADcQIAAh8GgAH2Uj-JSM-4BwI', 'BQADAgADcgIAAh8GgAFGt6FRsV9kmAI', 'BQADAgADcwIAAh8GgAHSw9dKaqbZjgI',
|
|
|
|
'BQADAgADdAIAAh8GgAF0IeDeuxaQ-AI', 'BQADAgADdQIAAh8GgAHJRO6c5-bodwI', 'BQADAgADdgIAAh8GgAEyyCSLdV_dMgI',
|
|
|
|
'BQADAgADdwIAAh8GgAHrLJKjv16lWwI', 'BQADAgADeAIAAh8GgAFkaz8qZREelQI', 'BQADAgADeQIAAh8GgAG1rPQHEIjf6AI']
|
|
|
|
|
2015-12-15 18:23:12 +00:00
|
|
|
# Dizionario con i nomi utenti di osu!
|
|
|
|
# Se qualcuno cambia nome utente di Telegram, lo cambi anche QUI.
|
|
|
|
osunames = {
|
|
|
|
'steffo': 'SteffoRYG',
|
|
|
|
'evilbalu': 'NemesisRYG',
|
|
|
|
'fultz': 'ftz99',
|
|
|
|
'ilgattopardo': 'gattopardo',
|
|
|
|
'frankfrankfrank': 'FrankezRYG',
|
|
|
|
'fedyal': 'fedececco',
|
|
|
|
'acterryg': 'Acter1',
|
|
|
|
'maxsensei': 'MaxSensei',
|
|
|
|
'heisendoc': 'ImHeisenberg',
|
|
|
|
'thevagginadestroyer': 'barboll',
|
|
|
|
'cosimo03': 'Cosimo03',
|
|
|
|
'albertino04': 'Alby1',
|
|
|
|
'voltaggio': 'voltaggio',
|
|
|
|
'tauei': 'tauei',
|
|
|
|
'boni3099': 'boni3099',
|
|
|
|
'mrdima98': 'MRdima98',
|
|
|
|
}
|
|
|
|
|
2015-11-23 16:18:08 +00:00
|
|
|
random.seed()
|
|
|
|
|
2015-12-15 18:23:12 +00:00
|
|
|
# Ciclo principale del bot! Mettete qui la roba che deve fare.
|
2015-10-04 17:48:45 +00:00
|
|
|
print("Bot avviato!")
|
2015-11-13 17:15:27 +00:00
|
|
|
while True:
|
|
|
|
# Guarda il comando ricevuto.
|
2015-11-15 15:58:07 +00:00
|
|
|
msg = telegram.getupdates()
|
2015-12-15 18:23:12 +00:00
|
|
|
# Se il messaggio è un comando...
|
2015-11-20 15:34:54 +00:00
|
|
|
if 'text' in msg:
|
2015-12-15 18:23:12 +00:00
|
|
|
# Dividilo con degli spazi e metti il comando in cmd[0] e gli argomenti in cmd[1]
|
2015-11-20 15:34:54 +00:00
|
|
|
cmd = msg['text'].split(' ', 1)
|
2015-12-15 18:23:12 +00:00
|
|
|
# Guarda l'ID della chat in cui è stato inviato
|
2015-11-20 15:34:54 +00:00
|
|
|
sby = msg['chat']['id']
|
2015-12-15 18:23:12 +00:00
|
|
|
# Nome da visualizzare nella console per capire chi accidenti è che invia messaggi strani
|
|
|
|
if 'username' in msg['from']:
|
|
|
|
# Visualizza l'username se esiste
|
|
|
|
unm = '@' + msg['from']['username']
|
|
|
|
else:
|
|
|
|
# Altrimenti, visualizza l'userID
|
|
|
|
unm = str(msg['from']['id'])
|
|
|
|
# Riconosci il comando.
|
|
|
|
# Viene usato startswith perchè il comando potrebbe anche essere inviato in forma /ciao@RoyalBot.
|
2015-11-20 15:34:54 +00:00
|
|
|
if cmd[0].startswith('/ahnonlosoio'):
|
2015-12-15 18:23:12 +00:00
|
|
|
print(unm + ": /ahnonlosoio")
|
2015-11-20 15:34:54 +00:00
|
|
|
telegram.sendmessage("Ah, non lo so nemmeno io!", sby)
|
|
|
|
elif cmd[0].startswith('/ehoh'):
|
2015-12-15 18:23:12 +00:00
|
|
|
print(unm + ": /ehoh")
|
2015-11-20 15:34:54 +00:00
|
|
|
telegram.sendmessage("Eh, oh. Sono cose che capitano.", sby)
|
|
|
|
elif cmd[0].startswith('/start'):
|
2015-12-15 18:23:12 +00:00
|
|
|
print(unm + ": /start")
|
2015-11-20 15:34:54 +00:00
|
|
|
telegram.sendmessage('Ascolta, io mi starto quando mi pare. Anzi, quando Steffo ha voglia di aprirmi.', sby)
|
|
|
|
elif cmd[0].startswith('/playing'):
|
2015-12-15 18:23:12 +00:00
|
|
|
print(unm + ": /playing")
|
2015-11-20 15:34:54 +00:00
|
|
|
if len(cmd) >= 2:
|
|
|
|
n = steam.getnumberofcurrentplayers(cmd[1])
|
|
|
|
if n is None:
|
|
|
|
telegram.sendmessage(chr(9888) + " L'app specificata non esiste!", sby)
|
|
|
|
else:
|
|
|
|
telegram.sendmessage('In questo momento, ' + str(n) + ' persone stanno giocando a [' + cmd[1] +
|
|
|
|
'](https://steamdb.info/app/' + cmd[1] + '/graphs/)', sby)
|
2015-11-13 17:15:27 +00:00
|
|
|
else:
|
2015-11-23 16:18:08 +00:00
|
|
|
telegram.sendmessage(chr(9888) + ' Non hai specificato un AppID!\n' +
|
|
|
|
'La sintassi corretta è /playing <AppID>.', sby)
|
2015-11-20 15:34:54 +00:00
|
|
|
elif cmd[0].startswith('/saldistim'):
|
2015-12-15 18:23:12 +00:00
|
|
|
print(unm + ": /saldistim")
|
2015-11-20 15:34:54 +00:00
|
|
|
if len(cmd) >= 2:
|
|
|
|
telegram.sendmessage(
|
2015-12-15 18:23:12 +00:00
|
|
|
'Visualizza le offerte di ' +
|
2015-11-20 15:34:54 +00:00
|
|
|
'[' + cmd[1] + '](https://isthereanydeal.com/#/search:' + cmd[1].replace(' ', '%20') +
|
2015-12-15 18:23:12 +00:00
|
|
|
";/scroll:%23gamelist).", sby)
|
2015-11-16 21:55:47 +00:00
|
|
|
else:
|
2015-11-20 15:34:54 +00:00
|
|
|
telegram.sendmessage(chr(9888) +
|
2015-11-24 15:07:10 +00:00
|
|
|
' Non hai specificato un gioco! ' +
|
2015-11-24 15:01:50 +00:00
|
|
|
'[Visualizza tutto](https://isthereanydeal.com/#/search:.;/scroll:%23gamelist).',
|
|
|
|
sby)
|
2015-11-20 15:34:54 +00:00
|
|
|
elif cmd[0].startswith('/rage'):
|
2015-12-15 18:23:12 +00:00
|
|
|
# Se qualcuno ne ha voglia, qui si potrebbe aggiungere la selezione degli audio come argomento,
|
|
|
|
# invece che fare una playlist casuale...
|
|
|
|
# Se non ci sono rage nella playlist, riempila e mescolala!
|
2015-11-20 15:34:54 +00:00
|
|
|
if len(rage) <= 0:
|
|
|
|
# Elenco degli audio disponibili
|
|
|
|
rage = ['BQADAgADEgIAAh8GgAGyLs6mbzxpVAI', 'BQADAgADEwIAAh8GgAGrT-MlTymm5gI',
|
|
|
|
'BQADAgADEQIAAh8GgAH62SrNqgXB6AI', 'BQADAgADEAIAAh8GgAHTLEngwtqr_QI',
|
|
|
|
'BQADAgAD3wEAAh8GgAE6ZnLP5_gFMwI', 'BQADAgAD5AEAAh8GgAGu0FpK_X2DuQI',
|
|
|
|
'BQADAgAD5gEAAh8GgAGvUTJ9meZixwI', 'BQADAgAD5wEAAh8GgAHJSoUnCr9WxwI',
|
|
|
|
'BQADAgAD6QEAAh8GgAExL8N1AWkDjgI', 'BQADAgAD6wEAAh8GgAFtkzazUqUEtwI',
|
|
|
|
'BQADAgAD9AEAAh8GgAE427GcA8FCqQI', 'BQADAgADMgIAAh8GgAEpusE7OCOXYgI',
|
|
|
|
'BQADAgADMwIAAh8GgAFffavzkvOkKAI', 'BQADAgADTAIAAh8GgAEgantYpHT5IwI']
|
|
|
|
random.shuffle(rage)
|
2015-12-15 18:23:12 +00:00
|
|
|
# Estrai un audio a caso tra quelli nella playlist e rimuovilo.
|
2015-11-20 15:34:54 +00:00
|
|
|
ragesend = rage.pop()
|
2015-12-15 18:23:12 +00:00
|
|
|
print(unm + ": /rage")
|
2015-11-20 15:34:54 +00:00
|
|
|
telegram.senddocument(ragesend, sby)
|
|
|
|
elif cmd[0].startswith('/sbam'):
|
2015-12-15 18:23:12 +00:00
|
|
|
print(unm + ": /sbam")
|
2015-11-20 15:34:54 +00:00
|
|
|
telegram.senddocument('BQADAgADTQIAAh8GgAGj0jKIrpTgvQI', sby)
|
|
|
|
elif cmd[0].startswith('/wololo'):
|
2015-12-15 18:23:12 +00:00
|
|
|
print(unm + ": /wololo")
|
2015-11-20 15:34:54 +00:00
|
|
|
if len(cmd) >= 2:
|
|
|
|
telegram.senddocument(wololo[int(cmd[1]) - 1], sby)
|
|
|
|
else:
|
|
|
|
telegram.senddocument('BQADAgADZwIAAh8GgAF3etjqkzFDxAI', sby)
|
|
|
|
elif cmd[0].startswith('/osunow'):
|
2015-12-15 18:23:12 +00:00
|
|
|
print(unm + ": /osunow")
|
2015-11-20 15:34:54 +00:00
|
|
|
if len(cmd) >= 2:
|
|
|
|
cmd = msg['text'].split(' ', 2)
|
|
|
|
if len(cmd) >= 3:
|
2015-11-24 15:01:50 +00:00
|
|
|
mode = int(cmd[2])
|
2015-11-20 15:34:54 +00:00
|
|
|
else:
|
2015-11-24 15:01:50 +00:00
|
|
|
mode = 0
|
|
|
|
r = osu.getuserrecent(cmd[1], mode)
|
|
|
|
if mode == 0:
|
|
|
|
telegram.sendmessage("*Osu!*\n" +
|
2015-12-15 18:23:12 +00:00
|
|
|
"[Beatmap " + r['beatmap_id'] + "](" + 'https://osu.ppy.sh/b/' + r[
|
|
|
|
'beatmap_id'] +
|
2015-11-24 15:01:50 +00:00
|
|
|
")\n*" + r['rank'] + "*\n*Punti*: " + r['score'] + "\n" +
|
|
|
|
"*Combo* x" + r['maxcombo'] + "\n" +
|
|
|
|
"*300*: " + r['count300'] + "\n" +
|
|
|
|
"*100*: " + r['count100'] + "\n" +
|
|
|
|
"*50*: " + r['count50'] + "\n" +
|
|
|
|
"*Awesome*: " + r['countkatu'] + "\n" +
|
|
|
|
"*Good*: " + r['countgeki'] + "\n" +
|
|
|
|
"*Miss*: " + r['countmiss'], sby)
|
|
|
|
elif mode == 1:
|
|
|
|
telegram.sendmessage("*Taiko*\n" +
|
2015-12-15 18:23:12 +00:00
|
|
|
"[Beatmap " + r['beatmap_id'] + "](" + 'https://osu.ppy.sh/b/' + r[
|
|
|
|
'beatmap_id'] +
|
2015-11-24 15:01:50 +00:00
|
|
|
")\n*" + r['rank'] + "*\n*Punti*: " + r['score'] + "\n" +
|
|
|
|
"*Combo* x" + r['maxcombo'] + "\n" +
|
|
|
|
"*Great*: " + r['count300'] + "\n" +
|
|
|
|
"*Good*: " + r['count100'] + "\n" +
|
|
|
|
"_Large_ *Great*: " + r['countkatu'] + "\n" +
|
|
|
|
"_Large_ *Good*: " + r['countgeki'] + "\n" +
|
|
|
|
"*Bad*: " + r['countmiss'], sby)
|
|
|
|
elif mode == 2:
|
|
|
|
telegram.sendmessage("*Catch the Beat*\n" +
|
2015-12-15 18:23:12 +00:00
|
|
|
"[Beatmap " + r['beatmap_id'] + "](" + 'https://osu.ppy.sh/b/' + r[
|
|
|
|
'beatmap_id'] +
|
2015-11-24 15:01:50 +00:00
|
|
|
")\n*" + r['rank'] + "*\n*Punti*: " + r['score'] + "\n" +
|
|
|
|
"*Combo* x" + r['maxcombo'] + "\n" +
|
|
|
|
"*Fruit*: " + r['count300'] + "\n" +
|
|
|
|
"*Droplet* _tick_: " + r['count100'] + "\n" +
|
|
|
|
"*Droplet* _trail_: " + r['count50'] + "\n" +
|
|
|
|
"*Miss*: " + r['countmiss'], sby)
|
|
|
|
elif mode == 3:
|
|
|
|
telegram.sendmessage("*Osu!mania*\n" +
|
2015-12-15 18:23:12 +00:00
|
|
|
"[Beatmap " + r['beatmap_id'] + "](" + 'https://osu.ppy.sh/b/' + r[
|
|
|
|
'beatmap_id'] +
|
2015-11-24 15:01:50 +00:00
|
|
|
")\n*" + r['rank'] + "*\n*Punti*: " + r['score'] + "\n" +
|
|
|
|
"*Combo* x" + r['maxcombo'] + "\n" +
|
|
|
|
"_Rainbow_ *300*: " + r['countgeki'] + "\n" +
|
|
|
|
"*300*: " + r['count300'] + "\n" +
|
|
|
|
"*100*: " + r['count100'] + "\n" +
|
|
|
|
"*200*: " + r['countkatu'] + "\n" +
|
|
|
|
"*50*: " + r['count50'] + "\n" +
|
|
|
|
"*Miss*: " + r['countmiss'], sby)
|
2015-11-20 15:34:54 +00:00
|
|
|
else:
|
2015-12-15 18:23:12 +00:00
|
|
|
# E' un po' una scorciatoia eh, peeerò...
|
2015-12-20 17:40:54 +00:00
|
|
|
if unm[1:].lower() in osunames:
|
|
|
|
r = osu.getuserrecent(osunames[unm[1:].lower()], 0)
|
2015-12-15 18:23:12 +00:00
|
|
|
telegram.sendmessage("*Osu!*\n" +
|
|
|
|
"[Beatmap " + r['beatmap_id'] + "](" + 'https://osu.ppy.sh/b/' + r[
|
|
|
|
'beatmap_id'] +
|
|
|
|
")\n*" + r['rank'] + "*\n*Punti*: " + r['score'] + "\n" +
|
|
|
|
"*Combo* x" + r['maxcombo'] + "\n" +
|
|
|
|
"*300*: " + r['count300'] + "\n" +
|
|
|
|
"*100*: " + r['count100'] + "\n" +
|
|
|
|
"*50*: " + r['count50'] + "\n" +
|
|
|
|
"*Awesome*: " + r['countkatu'] + "\n" +
|
|
|
|
"*Good*: " + r['countgeki'] + "\n" +
|
|
|
|
"*Miss*: " + r['countmiss'], sby)
|
2015-12-20 17:40:54 +00:00
|
|
|
else:
|
|
|
|
print("nope")
|
2015-11-23 16:18:08 +00:00
|
|
|
elif cmd[0].startswith('/roll'):
|
|
|
|
if len(cmd) >= 2:
|
|
|
|
m = int(cmd[1])
|
|
|
|
else:
|
|
|
|
m = 100
|
|
|
|
n = random.randrange(m)
|
2015-11-23 16:21:38 +00:00
|
|
|
telegram.sendmessage("Roll da 1 a " + str(m) + ": *" + str(n) + "*", sby)
|
2015-12-01 16:59:05 +00:00
|
|
|
elif cmd[0].startswith('/automah'):
|
2015-12-15 18:23:12 +00:00
|
|
|
print(unm + ": /automah")
|
2015-12-01 16:59:05 +00:00
|
|
|
telegram.sendmessage("Automaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", sby)
|
2015-12-20 19:05:13 +00:00
|
|
|
elif cmd[0].startswith('/hs'):
|
|
|
|
print(unm + ": /hs")
|
2015-12-20 20:06:17 +00:00
|
|
|
r = None
|
2015-12-20 19:05:13 +00:00
|
|
|
try:
|
|
|
|
r = hearthstone.card(cmd[1])[0]
|
|
|
|
except ValueError:
|
|
|
|
telegram.sendmessage(chr(9888) + "La carta specificata non esiste!", sby)
|
|
|
|
else:
|
|
|
|
# Si trova nelle bustine
|
|
|
|
if 'howToGet' not in r:
|
|
|
|
if 'cardSet' in r:
|
|
|
|
r['howToGet'] = "Trovala nelle bustine " + r['cardSet'] + "."
|
|
|
|
else:
|
|
|
|
r['howToGet'] = "Inottenibile."
|
|
|
|
# Nessuna classe
|
|
|
|
if 'playerClass' not in r:
|
|
|
|
r['playerClass'] = "Neutral"
|
2015-12-20 20:06:17 +00:00
|
|
|
# Nessun effetto
|
|
|
|
if 'text' not in r:
|
|
|
|
r['text'] = "_Nessun effetto._"
|
|
|
|
# Nessuna rarità
|
|
|
|
if 'rarity' not in r:
|
|
|
|
r['rarity'] = "None"
|
|
|
|
# Nessuna descrizione
|
|
|
|
if 'flavor' not in r:
|
|
|
|
r['flavor'] = "Nessuna descrizione."
|
2015-12-20 19:05:13 +00:00
|
|
|
# Testo principale
|
2015-12-21 15:52:06 +00:00
|
|
|
text = None
|
2015-12-20 19:05:13 +00:00
|
|
|
if r['type'] == "Spell":
|
|
|
|
text = str("[" + r['name'] + "](" + r['img'] + ") "
|
|
|
|
"(" + r['rarity'] + ")\n" +
|
|
|
|
r['playerClass'] + "\n" +
|
|
|
|
str(r['cost']) + " mana\n" +
|
|
|
|
r['text'] + "\n" +
|
|
|
|
r['howToGet'] + "\n\n_" +
|
|
|
|
r['flavor'] + "_\n")
|
|
|
|
elif r['type'] == "Minion":
|
|
|
|
text = str("[" + r['name'] + "](" + r['img'] + ") "
|
|
|
|
"(" + r['rarity'] + ")\n" +
|
|
|
|
r['playerClass'] + "\n" +
|
|
|
|
str(r['cost']) + " mana\n" +
|
|
|
|
str(r['attack']) + " attacco\n" +
|
|
|
|
str(r['health']) + " salute\n" +
|
|
|
|
r['text'] + "\n" +
|
|
|
|
r['howToGet'] + "\n\n_" +
|
|
|
|
r['flavor'] + "_\n")
|
2015-12-20 20:06:17 +00:00
|
|
|
elif r['type'] == "Weapon":
|
|
|
|
text = str("[" + r['name'] + "](" + r['img'] + ") "
|
|
|
|
"(" + r['rarity'] + ")\n" +
|
|
|
|
r['playerClass'] + "\n" +
|
|
|
|
str(r['cost']) + " mana\n" +
|
|
|
|
str(r['attack']) + " attacco\n" +
|
|
|
|
str(r['durability']) + " integrita'\n" +
|
|
|
|
r['text'] + "\n" +
|
|
|
|
r['howToGet'] + "\n\n_" +
|
|
|
|
r['flavor'] + "_\n")
|
|
|
|
elif r['type'] == "Hero Power":
|
|
|
|
text = str("[" + r['name'] + "](" + r['img'] + ")\n" +
|
|
|
|
r['playerClass'] + "\n" +
|
|
|
|
str(r['cost']) + " mana\n" +
|
|
|
|
r['text'] + "\n")
|
|
|
|
elif r['type'] == "Hero":
|
|
|
|
text = str("[" + r['name'] + "](" + r['img'] + ")\n" +
|
|
|
|
str(r['health']) + " salute\n")
|
2015-12-20 19:05:13 +00:00
|
|
|
telegram.sendmessage(text, sby)
|
|
|
|
elif cmd[0].startswith('/restart'):
|
|
|
|
if unm == "@Steffo":
|
|
|
|
telegram.sendmessage("Riavvio confermato.", sby)
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
|