mirror of
https://github.com/RYGhub/royalnet.git
synced 2025-02-17 10:53:57 +00:00
Il bot manda tutti i messaggi come risposta.
E' una bella idea? Potrei dover annullare questa modifica.
This commit is contained in:
parent
4d9bf424d7
commit
866eb52f4a
1 changed files with 32 additions and 30 deletions
62
bot.py
62
bot.py
|
@ -151,6 +151,8 @@ while True:
|
|||
text = msg['text']
|
||||
# Guarda l'ID della chat in cui è stato inviato
|
||||
sentin = msg['chat']['id']
|
||||
# ID del messaggio ricevuto
|
||||
source = msg['message_id']
|
||||
# Nome da visualizzare nella console per capire chi accidenti è che invia messaggi strani
|
||||
if 'username' in msg['from']:
|
||||
# Salva l'username se esiste
|
||||
|
@ -162,10 +164,10 @@ while True:
|
|||
# Viene usato startswith perchè il comando potrebbe anche essere inviato in forma /ciao@RoyalBot.
|
||||
if text.startswith('/ahnonlosoio'):
|
||||
print("@" + username + ": /ahnonlosoio")
|
||||
telegram.sendmessage("Ah, non lo so nemmeno io!", sentin)
|
||||
telegram.sendmessage("Ah, non lo so nemmeno io!", sentin, source)
|
||||
elif text.startswith('/ehoh'):
|
||||
print("@" + username + ": /ehoh")
|
||||
telegram.sendmessage("Eh, oh. Sono cose che capitano.", sentin)
|
||||
telegram.sendmessage("Eh, oh. Sono cose che capitano.", sentin, source)
|
||||
elif text.startswith('/playing'):
|
||||
print("@" + username + ": /playing")
|
||||
cmd = text.split(" ")
|
||||
|
@ -174,13 +176,13 @@ while True:
|
|||
n = steam.getnumberofcurrentplayers(cmd[1])
|
||||
# Se viene ricevuta una risposta...
|
||||
if n is None:
|
||||
telegram.sendmessage(chr(9888) + " L'app specificata non esiste!", sentin)
|
||||
telegram.sendmessage(chr(9888) + " L'app specificata non esiste!", sentin, source)
|
||||
else:
|
||||
telegram.sendmessage('In questo momento, ' + str(n) + ' persone stanno giocando a [' + cmd[1] +
|
||||
'](https://steamdb.info/app/' + cmd[1] + '/graphs/)', sentin)
|
||||
'](https://steamdb.info/app/' + cmd[1] + '/graphs/)', sentin, source)
|
||||
else:
|
||||
telegram.sendmessage(chr(9888) + ' Non hai specificato un AppID!\n'
|
||||
'La sintassi corretta è /playing <AppID>.', sentin)
|
||||
'La sintassi corretta è /playing <AppID>.', sentin, source)
|
||||
elif text.startswith('/saldi'):
|
||||
print("@" + username + ": /saldi")
|
||||
cmd = text.split(" ", 1)
|
||||
|
@ -188,13 +190,13 @@ while True:
|
|||
telegram.sendmessage(
|
||||
'Visualizza le offerte di '
|
||||
'[' + cmd[1] + '](https://isthereanydeal.com/#/search:' + cmd[1].replace(' ', '%20') +
|
||||
";/scroll:%23gamelist).", sentin)
|
||||
";/scroll:%23gamelist).", sentin, source)
|
||||
else:
|
||||
telegram.sendmessage(chr(9888) +
|
||||
" Non hai specificato un gioco!"
|
||||
"[Visualizza tutte le offerte]"
|
||||
"(https://isthereanydeal.com/#/search:.;/scroll:%23gamelist).",
|
||||
sentin)
|
||||
sentin, source)
|
||||
# elif text.startswith('/audio'):
|
||||
# # Se qualcuno ne ha voglia, qui si potrebbe aggiungere la selezione degli audio come argomento,
|
||||
# # invece che fare una playlist casuale...
|
||||
|
@ -206,16 +208,16 @@ while True:
|
|||
# # Estrai un audio a caso tra quelli nella playlist e rimuovilo.
|
||||
# ragesend = rage.pop()
|
||||
# print("@" + username + ": /audio")
|
||||
# telegram.senddocument(ragesend, sentin)
|
||||
# telegram.senddocument(ragesend, sentin, source)
|
||||
elif text.startswith('/sbam'):
|
||||
print("@" + username + ": /sbam")
|
||||
telegram.senddocument('BQADAgADBwMAAh8GgAGSsR4rwmk_LwI', sentin)
|
||||
# elif text.startswith('/wololo'):
|
||||
# print("@" + username + ": /wololo")
|
||||
# if len(cmd) >= 2:
|
||||
# telegram.senddocument(wololo[int(cmd[1]) - 1], sentin)
|
||||
# telegram.senddocument(wololo[int(cmd[1]) - 1], sentin, source)
|
||||
# else:
|
||||
# telegram.senddocument('BQADAgADZwIAAh8GgAF3etjqkzFDxAI', sentin)
|
||||
# telegram.senddocument('BQADAgADZwIAAh8GgAF3etjqkzFDxAI', sentin, source)
|
||||
elif text.startswith('/osu'):
|
||||
print("@" + username + ": /osu")
|
||||
# Trova il nome utente
|
||||
|
@ -232,7 +234,7 @@ while True:
|
|||
try:
|
||||
r = osu.getuserrecent(cmd[1], mode)
|
||||
except NameError:
|
||||
telegram.sendmessage(chr(9888) + " Errore nella richiesta ai server di Osu!", sentin)
|
||||
telegram.sendmessage(chr(9888) + " Errore nella richiesta ai server di Osu!", sentin, source)
|
||||
else:
|
||||
if "enabled_mods" in r:
|
||||
mods = "*Mod selezionate:"
|
||||
|
@ -257,7 +259,7 @@ while True:
|
|||
"*50*: " + r['count50'] + "\n"
|
||||
"*Awesome*: " + r['countkatu'] + "\n"
|
||||
"*Good*: " + r['countgeki'] + "\n"
|
||||
"*Miss*: " + r['countmiss'], sentin)
|
||||
"*Miss*: " + r['countmiss'], sentin, source)
|
||||
elif mode == 1:
|
||||
telegram.sendmessage("*Taiko*\n"
|
||||
"[Beatmap " + r['beatmap_id'] + "](" + 'https://osu.ppy.sh/b/' + r[
|
||||
|
@ -268,7 +270,7 @@ while True:
|
|||
"*Good*: " + r['count100'] + "\n"
|
||||
"_Large_ *Great*: " + r['countkatu'] + "\n"
|
||||
"_Large_ *Good*: " + r['countgeki'] + "\n"
|
||||
"*Bad*: " + r['countmiss'], sentin)
|
||||
"*Bad*: " + r['countmiss'], sentin, source)
|
||||
elif mode == 2:
|
||||
telegram.sendmessage("*Catch the Beat*\n"
|
||||
"[Beatmap " + r['beatmap_id'] + "](" + 'https://osu.ppy.sh/b/' + r[
|
||||
|
@ -278,7 +280,7 @@ while True:
|
|||
"*Fruit*: " + r['count300'] + "\n"
|
||||
"*Droplet* _tick_: " + r['count100'] + "\n"
|
||||
"*Droplet* _trail_: " + r['count50'] + "\n"
|
||||
"*Miss*: " + r['countmiss'], sentin)
|
||||
"*Miss*: " + r['countmiss'], sentin, source)
|
||||
elif mode == 3:
|
||||
telegram.sendmessage("*Osu!mania*\n" +
|
||||
"[Beatmap " + r['beatmap_id'] + "](" + 'https://osu.ppy.sh/b/' + r[
|
||||
|
@ -290,7 +292,7 @@ while True:
|
|||
"*100*: " + r['count100'] + "\n"
|
||||
"*200*: " + r['countkatu'] + "\n"
|
||||
"*50*: " + r['count50'] + "\n"
|
||||
"*Miss*: " + r['countmiss'], sentin)
|
||||
"*Miss*: " + r['countmiss'], sentin, source)
|
||||
else:
|
||||
# E' un po' una scorciatoia eh, peeerò...
|
||||
if username.lower() in osunames:
|
||||
|
@ -305,7 +307,7 @@ while True:
|
|||
"*50*: " + r['count50'] + "\n"
|
||||
"*Awesome*: " + r['countgeki'] + "\n"
|
||||
"*Good*: " + r['countkatu'] + "\n"
|
||||
"*Miss*: " + r['countmiss'], sentin)
|
||||
"*Miss*: " + r['countmiss'], sentin, source)
|
||||
elif text.startswith('/roll'):
|
||||
print("@" + username + ": /roll")
|
||||
cmd = text.split(' ', 1)
|
||||
|
@ -313,19 +315,19 @@ while True:
|
|||
try:
|
||||
m = int(cmd[1])
|
||||
except ValueError:
|
||||
telegram.sendmessage(chr(9888) + " Il numero specificato non è un intero.", sentin)
|
||||
telegram.sendmessage(chr(9888) + " Il numero specificato non è un intero.", sentin, source)
|
||||
else:
|
||||
m = 100
|
||||
try:
|
||||
n = random.randrange(m) + 1
|
||||
except ValueError:
|
||||
telegram.sendmessage(chr(9888) + " Il numero specificato non è maggiore o uguale a 0.", sentin)
|
||||
telegram.sendmessage(chr(9888) + " Il numero specificato non è maggiore o uguale a 0.", sentin, source)
|
||||
else:
|
||||
telegram.sendmessage("Numero casuale da 1 a " + str(m) + ":\n*" + str(n) + "*", sentin)
|
||||
telegram.sendmessage("Numero casuale da 1 a " + str(m) + ":\n*" + str(n) + "*", sentin, source)
|
||||
elif text.startswith('/automah'):
|
||||
print("@" + username + ": /automah")
|
||||
# TODO: Mettere l'audio di Tobia
|
||||
telegram.sendmessage("Automaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa! Devi funzionare, cavolo!", sentin)
|
||||
telegram.sendmessage("Automaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa! Devi funzionare, cavolo!", sentin, source)
|
||||
elif text.startswith('/hs'):
|
||||
print("@" + username + ": /hs")
|
||||
cmd = text.split(" ", 1)
|
||||
|
@ -336,7 +338,7 @@ while True:
|
|||
# Se ci sono più carte, prendine una a caso!
|
||||
r = r[random.randrange(len(r))]
|
||||
except ValueError:
|
||||
telegram.sendmessage(chr(9888) + " La carta specificata non esiste!", sentin)
|
||||
telegram.sendmessage(chr(9888) + " La carta specificata non esiste!", sentin, source)
|
||||
else:
|
||||
# Si trova nelle bustine
|
||||
if 'howToGet' not in r:
|
||||
|
@ -406,10 +408,10 @@ while True:
|
|||
text = str("[" + r['name'] + "](" + r['img'] + ")\n" +
|
||||
"*Eroe*\n" +
|
||||
str(r['health']) + " salute\n")
|
||||
telegram.sendmessage(text, sentin)
|
||||
telegram.sendmessage(text, sentin, source)
|
||||
else:
|
||||
telegram.sendmessage(chr(9888) + " Non hai specificato nessuna carta!\n"
|
||||
"La sintassi corretta è _/hs nomecarta_ .", sentin)
|
||||
"La sintassi corretta è _/hs nomecarta_ .", sentin, source)
|
||||
elif text.startswith('/online'):
|
||||
# Elenco di tutte le persone online su Steam
|
||||
print("@" + username + ": /online ")
|
||||
|
@ -420,7 +422,7 @@ while True:
|
|||
chr(128308) + " In gioco | Occupato\n" +
|
||||
chr(9899) + " Assente | Inattivo\n" +
|
||||
chr(128310) + " Disponibile per scambiare\n" +
|
||||
chr(128311) + " Disponibile per giocare", sentin)
|
||||
chr(128311) + " Disponibile per giocare", sentin, source)
|
||||
else:
|
||||
# Stringa utilizzata per ottenere informazioni su tutti gli utenti in una sola richiesta a steam
|
||||
userids = str()
|
||||
|
@ -453,13 +455,13 @@ while True:
|
|||
if player['personastate'] != 0:
|
||||
tosend += " " + player['personaname'] + "\n"
|
||||
else:
|
||||
telegram.sendmessage(tosend, sentin)
|
||||
telegram.sendmessage(tosend, sentin, source)
|
||||
elif text.startswith('/shrekt'):
|
||||
print("@" + username + ": /shrekt ")
|
||||
telegram.senddocument("BQADBAADsQADiBjiAqYN-EBXASyhAg", sentin)
|
||||
elif text.startswith('/restart') and username == "Steffo":
|
||||
print("@" + username + ": /restart ")
|
||||
telegram.sendmessage("Riavvio accettato.", sentin)
|
||||
telegram.sendmessage("Riavvio accettato.", sentin, source)
|
||||
sys.exit(0)
|
||||
elif text.startswith('/nuovavotazione') and username == "Steffo":
|
||||
print("@" + username + ": /nuovavotazione ")
|
||||
|
@ -469,17 +471,17 @@ while True:
|
|||
if incorso.chat == sentin:
|
||||
print("@" + username + ": /si ")
|
||||
incorso.register(username.lower(), 1)
|
||||
telegram.sendmessage("Votazione registrata!", sentin)
|
||||
telegram.sendmessage("Votazione registrata!", sentin, source)
|
||||
elif text.startswith('/no') and incorso is not None:
|
||||
if incorso.chat == sentin:
|
||||
print("@" + username + ": /no ")
|
||||
incorso.register(username.lower(), 2)
|
||||
telegram.sendmessage("Votazione registrata!", sentin)
|
||||
telegram.sendmessage("Votazione registrata!", sentin, source)
|
||||
elif text.startswith('/astieniti') and incorso is not None:
|
||||
if incorso.chat == sentin:
|
||||
print("@" + username + ": /astieniti ")
|
||||
incorso.register(username.lower(), 3)
|
||||
telegram.sendmessage("Votazione registrata!", sentin)
|
||||
telegram.sendmessage("Votazione registrata!", sentin, source)
|
||||
elif text.startswith('/domanda') and incorso is not None:
|
||||
if incorso.chat == sentin:
|
||||
print("@" + username + ": /domanda ")
|
||||
|
@ -501,4 +503,4 @@ while True:
|
|||
else:
|
||||
tosend += chr(128266) + " "
|
||||
tosend += u['name'] + "\n"
|
||||
telegram.sendmessage(tosend, sentin)
|
||||
telegram.sendmessage(tosend, sentin, source)
|
||||
|
|
Loading…
Add table
Reference in a new issue