1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-30 15:04:18 +00:00
royalnet/bot.py

83 lines
4 KiB
Python
Raw Normal View History

2015-10-07 08:49:14 +00:00
# -*- coding: utf-8 -*-
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-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-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-11-13 17:15:27 +00:00
cmd = msg['text'].split(' ', 1)
sby = msg['chat']['id']
if cmd[0].startswith('/ahnonlosoio'):
print(str(sby) + ": /ahnonlosoio")
2015-11-15 15:58:07 +00:00
telegram.sendmessage("Ah, non lo so nemmeno io!", sby)
2015-11-13 17:15:27 +00:00
elif cmd[0].startswith('/ehoh'):
print(str(sby) + ": /ehoh")
2015-11-15 15:58:07 +00:00
telegram.sendmessage("Eh, oh. Sono cose che capitano.", sby)
2015-11-13 17:15:27 +00:00
elif cmd[0].startswith('/start'):
print(str(sby) + ": /start")
2015-11-15 15:58:07 +00:00
telegram.sendmessage('Ascolta, io mi starto quando mi pare. Anzi, quando Steffo ha voglia di aprirmi.', sby)
2015-11-13 17:15:27 +00:00
elif cmd[0].startswith('/playing'):
print(str(sby) + ": /playing")
if len(cmd) >= 2:
n = steam.getnumberofcurrentplayers(cmd[1])
2015-11-13 17:15:27 +00:00
if n is None:
2015-11-15 15:58:07 +00:00
telegram.sendmessage(chr(9888) + " L'app specificata non esiste!", sby)
2015-11-13 17:15:27 +00:00
else:
2015-11-15 15:58:07 +00:00
telegram.sendmessage('In questo momento, ' + str(n) + ' persone stanno giocando a [' + cmd[1] +
2015-11-15 15:13:53 +00:00
'](https://steamdb.info/app/' + cmd[1] + '/graphs/)', sby)
2015-11-13 17:15:27 +00:00
else:
2015-11-15 15:58:07 +00:00
telegram.sendmessage(chr(9888) + ' Non hai specificato un AppID!\nLa sintassi corretta è /playing <AppID>.',
2015-11-13 17:15:27 +00:00
sby)
elif cmd[0].startswith('/saldistim'):
print(str(sby) + ": /saldistim")
2015-11-15 15:58:07 +00:00
if len(cmd) >= 2:
telegram.sendmessage(
2015-11-15 15:13:53 +00:00
'Ricerca di offerte di ' +
'[' + cmd[1] + '](https://isthereanydeal.com/#/search:' + cmd[1].replace(' ', '%20') +
";/scroll:%23gamelist) completata.", sby)
2015-11-13 17:15:27 +00:00
else:
2015-11-15 15:58:07 +00:00
telegram.sendmessage(chr(9888) +
' Non hai specificato un gioco!' +
'[Visualizza tutto](https://isthereanydeal.com/#/search:.;/scroll:%23gamelist).', sby)
2015-11-13 17:15:27 +00:00
elif cmd[0].startswith('/rage'):
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',
2015-11-15 15:13:53 +00:00
'BQADAgADMwIAAh8GgAFffavzkvOkKAI', 'BQADAgADTAIAAh8GgAEgantYpHT5IwI']
2015-11-13 17:15:27 +00:00
random.shuffle(rage)
ragesend = rage.pop()
print(str(sby) + ": /rage " + ragesend)
2015-11-15 15:58:07 +00:00
telegram.senddocument(ragesend, sby)
elif cmd[0].startswith('/sbam'):
print(str(sby) + ": /sbam ")
2015-11-16 21:56:33 +00:00
telegram.senddocument('BQADAgADTQIAAh8GgAGj0jKIrpTgvQI', sby)
2015-11-16 21:55:47 +00:00
elif cmd[0].startswith('/osunow'):
print(str(sby) + ": /osunow ")
2015-11-16 21:59:19 +00:00
if len(cmd) >= 2:
if len(cmd) >= 3:
2015-11-16 21:55:47 +00:00
r = osu.getuserrecent(cmd[1], cmd[2])
else:
r = osu.getuserrecent(cmd[1])
link = "https://osu.ppy.sh/s/" + r['beatmap_id']
telegram.sendmessage("[Beatmap](" + link + ")\n*" +
r['rank'] + "*: " + r['score'] + "\n" +
"Combo x" + r['max_combo'] + "\n" +
"300: " + r['count300'] + "\n" +
"100: " + r['count100'] + "\n" +
"50: " + r['count50'] + "\n" +
"Miss: " + r['countmiss'], sby)
else:
# In futuro, il nome utente deve trovarlo da solo in base all'username di provenienza.
telegram.sendmessage(chr(9888) + " Non hai specificato un nome utente!", sby)