예제 #1
0
파일: bot.py 프로젝트: Steffo99/royal-bot
def share():
    # Visualizza detutti i giochi condivisi tra x persone.
    print("@" + username + ": /share")
    # Informa Telegram che il messaggio è stato ricevuto.
    telegram.sendchataction(sentin)
    tobematched = list()
    if len(cmd) > 2:
        del cmd[0]
        for name in cmd:
            userdata = db.findbyname(name.lower())
            if userdata is not None and 'steam' in userdata:
                if userdata['steam'] not in tobematched:
                    tobematched.append(userdata['steam'])
    if len(tobematched) == 2:
        tosend = str()
        # Giochi che ha il primo ma non il secondo
        d = list(steammatch.diff_games(tobematched[0], tobematched[1]))
        if len(d) > 0:
            # Prepara il messaggio
            tosend += "*Giochi che ha @{primo} ma non @{secondo}:*\n".format(primo=cmd[0], secondo=cmd[1])
            for game in d:
                tosend += "- {game}\n".format(game=game)
        else:
            tosend += "_@{secondo} ha tutti i giochi che ha @{primo}_.\n"
        telegram.sendmessage(tosend, sentin, source)
    else:
        telegram.sendmessage(chr(9888) + "Non è stato specificato un numero adeguato di utenti per eseguire l'azione.",
                             sentin, source)
예제 #2
0
def vita(var):
    global hp
    hp = hp + var
    sendmessage(chr(10084) + ' ' + str(var) + "\n" + "Ora avete " + str(hp) + " punti vita.", target_group)
    if hp <= 0:
        sendmessage("Hai finito la vita! Game over!", target_group)
        sys.exit()
예제 #3
0
def lolfree():
    # Visualizza i campioni gratuiti di LoL di questa settimana
    print("@" + username + ": /lolfree")
    # Informa Telegram che il messaggio è stato ricevuto.
    telegram.sendchataction(sentin)
    ora = time.gmtime()
    cmd = text.split(" ", 1)
    if len(cmd) > 1:
        refresh_requested = cmd[1].startswith("refresh")
    else:
        refresh_requested = False
    # Controlla se i dati sono già stati scaricati.
    global lolfreestring
    if lolfreestring == "" or refresh_requested:
        # Crea un nuovo set di dati.
        print("Aggiornamento champ gratuiti di League of Legends...")
        lolfreestring = "Champion gratuiti del `" + str(ora.tm_mday) + "/" + str(ora.tm_mon) + "/" + \
                        str(ora.tm_year) + " " + str(ora.tm_hour) + ":" + str(ora.tm_min) + "`\n"
        r = lol.getfreerotation()
        for champion in r:
            staticdata = lol.getchampionstaticdata(champion['id'])
            lolfreestring += "*" + staticdata['name'] + "* " + staticdata[
                'title'] + '\n'
        print("Completato.")
    telegram.sendmessage(lolfreestring, sentin, source)
예제 #4
0
def ciaoruozi():
    print("@" + username + ": /ciaoruozi")
    # Ciao Ruozi.
    if username.lower() == "ruozir":
        telegram.sendmessage("Ciao me", sentin, source)
    else:
        telegram.sendmessage("Ciao Ruozi", sentin, source)
예제 #5
0
 def showresults(self):
     lista = str()
     si = 0
     no = 0
     astenuti = 0
     for persona in self.voto:
         if self.voto[persona] == 0:
             lista += chr(9898)
         elif self.voto[persona] == 1:
             si += 1
             lista += chr(128309)
         elif self.voto[persona] == 2:
             no += 1
             lista += chr(128308)
         elif self.voto[persona] == 3:
             astenuti += 1
             lista += chr(9899)
         lista += " @" + persona + "\n"
     if not si and not no and not astenuti:
         telegram.sendmessage(chr(9888) + " Nessuno ha ancora votato!", self.chat)
     else:
         telegram.sendmessage(self.domanda + "\n"
                              "*Risultati:*\n"
                              "Sì: " + str(si) + " (" + str(round(si / (si + no + astenuti) * 100, 2)) + "%)\n"
                              "No: " + str(no) + " (" + str(round(no / (si + no + astenuti) * 100, 2)) + "%)\n"
                              "Astenuti: " + str(astenuti) + "\n\n" + lista, self.chat)
예제 #6
0
 def showresults(self):
     lista = str()
     si = 0
     no = 0
     astenuti = 0
     for persona in self.voto:
         if self.voto[persona] == 0:
             lista += chr(9898)
         elif self.voto[persona] == 1:
             si += 1
             lista += chr(128309)
         elif self.voto[persona] == 2:
             no += 1
             lista += chr(128308)
         elif self.voto[persona] == 3:
             astenuti += 1
             lista += chr(9899)
         lista += " @" + persona + "\n"
     if not si and not no and not astenuti:
         telegram.sendmessage(
             chr(9888) + " Nessuno ha ancora votato!", self.chat)
     else:
         telegram.sendmessage(
             self.domanda + "\n"
             "*Risultati:*\n"
             "Sì: " + str(si) + " (" +
             str(round(si / (si + no + astenuti) * 100, 2)) + "%)\n"
             "No: " + str(no) + " (" +
             str(round(no / (si + no + astenuti) * 100, 2)) + "%)\n"
             "Astenuti: " + str(astenuti) + "\n\n" + lista, self.chat)
예제 #7
0
파일: bot.py 프로젝트: Steffo99/royal-bot
def roll():
    print("@" + username + ": /roll")
    # Se è stato specificato un numero
    if len(cmd) >= 2:
        if cmd[1] == "tm":
            telegram.sendmessage("TM è così grassa che se la lanci rotola!", sentin, source)
        # Controlla che sia convertibile in un intero.
        try:
            m = int(cmd[1])
        except ValueError:
            telegram.sendmessage(chr(9888) + " Il numero specificato non è un intero.", sentin, source)
            return
    else:
        # Imposta il numero massimo a 100.
        m = 100
    # Prova a generare un numero casuale.
    if m == 34261891881215712181524122318242223183627453833:
        telegram.sendmessage("Numero casuale da 1 a _34261891881215712181524122318242223183627453833_:\n"
                             "*Frank è scarso*", sentin, source)
    else:
        try:
            n = random.randrange(m) + 1
        except ValueError:
            telegram.sendmessage(chr(9888) + " Il numero specificato non è maggiore o uguale a 0.",
                                 sentin, source)
        # Se tutto va bene visualizza il numero generato
        else:
            telegram.sendmessage("Numero casuale da 1 a " + str(m) + ":\n*" + str(n) + "*", sentin,
                                 source)
예제 #8
0
파일: bot.py 프로젝트: Steffo99/royal-bot
def ciaoruozi():
    print("@" + username + ": /ciaoruozi")
    # Ciao Ruozi.
    if username.lower() == "ruozir":
        # Manda un messaggio casuale tra quelli nella lista
        chosen_msg = random.sample(["Ciao me!",
                                    "Ciao ciao ciao!",
                                    "1 ciaoruozi = 1000€ per me",
                                    "Ruozi si dice: #CiaoRuozi",
                                    "Ciao eh me!",
                                    "Ehi me, ma ciao!",
                                    "Ma ciao me stesso!",
                                    "Me me me! Ciao!"], 1)[0]
        telegram.sendmessage(chosen_msg, sentin, source)
    else:
        # Manda un messaggio casuale tra quelli nella lista
        chosen_msg = random.sample(["Ciao Ruozi!",
                                    "Ciao ciao ciao!",
                                    "1 ciaoruozi = 1 prayer",
                                    "La RYG dice: #CiaoRuozi",
                                    "Ciao eh Ruozi!",
                                    "Ehi Ruozi, ma ciao!",
                                    "Ma ciao Ruozi!",
                                    "Ruozi ruozi ruozi! Ciao!"], 1)[0]
        telegram.sendmessage(chosen_msg, sentin, source)
예제 #9
0
def getrygimage():
    # Ricevi il link alla tua immagine del profilo Royal Games.
    print("@" + username + ": /getrygimage")
    telegram.sendmessage(
        "[Scarica](https://dl.dropboxusercontent.com/u/23313381/Logo/Personali/{tag}.png)"
        " la tua immagine del profilo Royal Games!".format(
            tag=royalgames[username.lower()]['icon']), sentin, source)
예제 #10
0
파일: mifia.py 프로젝트: Frankez/royal-bot
 def evilmessage(self, text):
     """Manda un messaggio al team dei nemici del gioco
     :param text: Testo del messaggio
     """
     for player in self.players:
         if player.role == 1:
             telegram.sendmessage("\U0001F608: " + text, player.telegramid)
     telegram.sendmessage("\U0001F608: " + text, self.adminid)
예제 #11
0
 def evilmessage(self, text):
     """Manda un messaggio al team dei nemici del gioco
     :param text: Testo del messaggio
     """
     for player in self.players:
         if player.role == 1:
             telegram.sendmessage("\U0001F608: " + text, player.telegramid)
     telegram.sendmessage("\U0001F608: " + text, self.adminid)
예제 #12
0
def cv():
    print("@" + username + ": /cv")
    # Ottieni i dati dal server della Royal Games
    r = discord.getwidgetdata("176353500710699008")
    # Elenco di tutte le persone online su Discord
    tosend = "*Online su Discord, nel server {servername}:*\n".format(
        servername=r['name'])
    # Qui inizia il codice peggiore di sempre
    for member in r['members']:
        m = dict()
        if 'bot' not in member or not member['bot']:
            # Se una persona è connessa in chat vocale
            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['vemoji'] = chr(128263)
                elif member['mute'] or member['self_mute']:
                    m['vemoji'] = chr(128264)
                else:
                    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)
            elif member['status'] == "idle":
                m['emoji'] = chr(9899)
            elif member['status'] == "dnd":
                m['emoji'] = chr(128308)
            else:
                # Stato sconosciuto. Fallback nel caso in cui vengano aggiunti nuovi stati.
                m['emoji'] = chr(2573)
            # Aggiungi il nome del gioco a destra del nome
            if 'game' in member:
                m['gamename'] = member['game']['name']
            # Visualizza il nickname se presente, altrimenti visualizza l'username
            if 'nick' in m:
                member['username'] = m['nick']
            else:
                m['name'] = member['username']
            tosend += "{emoji} {name}".format(emoji=m['emoji'], name=m['name'])
            if 'channelname' in m:
                tosend += " | {vemoji} *{channelname}*".format(
                    vemoji=m['vemoji'], channelname=m['channelname'])
            if 'gamename' in m:
                tosend += " | _{gamename}_".format(gamename=m['gamename'])
            tosend += "\n"
        # Controlla se l'utente è royal music
        elif member['id'] == "176358898851250176":
            if 'game' in member:
                tosend += "{emoji} *{channelname}* | {songname}\n" \
                    .format(emoji="\U0001F3B5", channelname=discord.getchannelname(r, member['channel_id']),
                            songname=member['game']['name'])
    telegram.sendmessage(tosend, sentin, source)
예제 #13
0
def vita(var):
    global hp
    hp = hp + var
    sendmessage(
        chr(10084) + ' ' + str(var) + "\n" + "Ora avete " + str(hp) +
        " punti vita.", target_group)
    if hp <= 0:
        sendmessage("Hai finito la vita! Game over!", target_group)
        sys.exit()
예제 #14
0
파일: bot.py 프로젝트: Steffo99/royal-bot
def smecds():
    # Secondo me, è colpa...
    print("@" + username + ": /smecds")
    accusato = random.sample(["dello stagista", "degli sposi", "di Santinelli", "di Sensei", "di Steffo", "di Spaggia",
                              "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", "della Supercell",
                              "di Santaclaus", "dei Sims", "dei Santi", "di SES2017", "di Salvini"], 1)[0]
    telegram.sendmessage("Secondo me è colpa {accusato}...".format(accusato=accusato), sentin, source)
예제 #15
0
파일: bot.py 프로젝트: Steffo99/royal-bot
def cv():
    print("@" + username + ": /cv")
    # Ottieni i dati dal server della Royal Games
    r = discord.getwidgetdata("176353500710699008")
    # Elenco di tutte le persone online su Discord
    tosend = "*Online su Discord, nel server {servername}:*\n".format(servername=r['name'])
    # Qui inizia il codice peggiore di sempre
    for member in r['members']:
        m = dict()
        if 'bot' not in member or not member['bot']:
            # Se una persona è connessa in chat vocale
            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['vemoji'] = chr(128263)
                elif member['mute'] or member['self_mute']:
                    m['vemoji'] = chr(128264)
                else:
                    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)
            elif member['status'] == "idle":
                m['emoji'] = chr(9899)
            elif member['status'] == "dnd":
                m['emoji'] = chr(128308)
            else:
                # Stato sconosciuto. Fallback nel caso in cui vengano aggiunti nuovi stati.
                m['emoji'] = chr(2573)
            # Aggiungi il nome del gioco a destra del nome
            if 'game' in member:
                m['gamename'] = member['game']['name']
            # Visualizza il nickname se presente, altrimenti visualizza l'username
            if 'nick' in m:
                member['username'] = m['nick']
            else:
                m['name'] = member['username']
            tosend += "{emoji} {name}".format(emoji=m['emoji'], name=m['name'])
            if 'channelname' in m:
                tosend += " | {vemoji} *{channelname}*".format(vemoji=m['vemoji'], channelname=m['channelname'])
            if 'gamename' in m:
                tosend += " | _{gamename}_".format(gamename=m['gamename'])
            tosend += "\n"
        # Controlla se l'utente è royal music
        elif member['id'] == "176358898851250176":
            if 'game' in member:
                tosend += "{emoji} *{channelname}* | {songname}\n" \
                    .format(emoji="\U0001F3B5", channelname=discord.getchannelname(r, member['channel_id']),
                            songname=member['game']['name'])
    telegram.sendmessage(tosend, sentin, source)
예제 #16
0
def trescelte(puno, pdue, ptre):
    time.sleep(4)
    sendmessage(chr(10067) + " Cosa volete fare?\n/1: " + puno + "\n/2: " + pdue + "\n/3: " + ptre, target_group)
    # Aspetta una risposta...
    while True:
        msg = getupdates()
        if 'text' in msg:
            if msg['text'] == "/1":
                return 1
            elif msg['text'] == "/2":
                return 2
            elif msg['text'] == "/3":
                return 3
예제 #17
0
def balurage():
    print("@" + username + ": /balurage")
    # Rispondi commentando l'E3.
    tosend = str()
    try:
        ragelevel = int(filemanager.readfile("ragelevel.txt"))
    except ValueError:
        ragelevel = 0
    ragelevel += 1
    filemanager.writefile("ragelevel.txt", str(ragelevel))
    for rage in range(0, ragelevel):
        tosend += "MADDEN "
    telegram.sendmessage(tosend, sentin, source)
예제 #18
0
파일: bot.py 프로젝트: Steffo99/royal-bot
def balurage():
    print("@" + username + ": /balurage")
    # Rispondi commentando l'E3.
    tosend = str()
    try:
        ragelevel = int(filemanager.readfile("ragelevel.txt"))
    except ValueError:
        ragelevel = 0
    ragelevel += 1
    filemanager.writefile("ragelevel.txt", str(ragelevel))
    for rage in range(0, ragelevel):
        tosend += "MADDEN "
    telegram.sendmessage(tosend, sentin, source)
예제 #19
0
def roll():
    print("@" + username + ": /roll")
    cmd = text.split(' ', 1)
    # Se è stato specificato un numero
    if len(cmd) >= 2:
        # Controlla che sia convertibile in un intero.
        try:
            m = int(cmd[1])
        except ValueError:
            telegram.sendmessage(
                chr(9888) + " Il numero specificato non è un intero.", sentin,
                source)
            return
    else:
        # Imposta il numero massimo a 100.
        m = 100
    # Prova a generare un numero casuale.
    if m == 34261891881215712181524122318242223183627453833:
        telegram.sendmessage(
            "Numero casuale da 1 a _get rekt_:\n*@FrankRekt è scarso*", sentin,
            source)
    else:
        try:
            n = random.randrange(m) + 1
        except ValueError:
            telegram.sendmessage(
                chr(9888) +
                " Il numero specificato non è maggiore o uguale a 0.", sentin,
                source)
        # Se tutto va bene visualizza il numero generato
        else:
            telegram.sendmessage(
                "Numero casuale da 1 a " + str(m) + ":\n*" + str(n) + "*",
                sentin, source)
예제 #20
0
def trescelte(puno, pdue, ptre):
    time.sleep(4)
    sendmessage(
        chr(10067) + " Cosa volete fare?\n/1: " + puno + "\n/2: " + pdue +
        "\n/3: " + ptre, target_group)
    # Aspetta una risposta...
    while True:
        msg = getupdates()
        if 'text' in msg:
            if msg['text'] == "/1":
                return 1
            elif msg['text'] == "/2":
                return 2
            elif msg['text'] == "/3":
                return 3
예제 #21
0
def cv():
    print("@" + username + ": /cv")
    # Elenco di tutte le persone online su Discord
    tosend = "*Su Discord ora:*\n"
    r = discord.getwidgetdata("176353500710699008")
    musicstatus = str()
    for member in r['members']:
        m = dict()
        if 'bot' not in member or not member['bot']:
            # Credo di aver scritto il peggior algoritmo di sempre. gg me
            if 'channel_id' in member:
                if member['deaf'] or member['self_deaf']:
                    m['emoji'] = chr(128263)
                elif member['mute'] or member['self_mute']:
                    m['emoji'] = chr(128264)
                else:
                    m['emoji'] = chr(128266)
                m['channelname'] = discord.getchannelname(
                    r, member['channel_id'])
            else:
                if member['status'] == "online":
                    if 'game' in member:
                        m['emoji'] = chr(128308)
                    else:
                        m['emoji'] = chr(128309)
                elif member['status'] == "idle":
                    m['emoji'] = chr(9899)
            if 'game' in member:
                m['gamename'] = member['game']['name']
            m['name'] = member['username']
            if 'gamename' in m and 'channelname' in m:
                tosend += "{emoji} *{channelname}* {name} | _{gamename}_\n".format(
                    **m)
            elif 'gamename' in m:
                tosend += "{emoji} {name} | _{gamename}_\n".format(**m)
            elif 'channelname' in m:
                tosend += "{emoji} *{channelname}* {name}\n".format(**m)
            else:
                tosend += "{emoji} {name}\n".format(**m)
        # Controlla se l'utente è royal music
        elif member['id'] == "176358898851250176":
            if 'game' in member:
                musicstatus = "{emoji} *{channelname}* {songname}\n" \
                    .format(emoji="\U0001F3B5", channelname=discord.getchannelname(r, member['channel_id']),
                            songname=member['game']['name'])
    if musicstatus != "":
        tosend += musicstatus
    telegram.sendmessage(tosend, sentin, source)
예제 #22
0
def online():
    # Elenco di tutte le persone online su Steam
    print("@" + username + ": /online ")
    # Informa Telegram che il messaggio è stato ricevuto.
    telegram.sendchataction(sentin)
    cmd = text.split(" ")
    if len(cmd) >= 2:
        if cmd[1].lower() == "help":
            telegram.sendmessage(
                chr(128309) + " Online\n" + chr(128308) +
                " In gioco | Occupato\n" + chr(9899) +
                " Assente | Inattivo\n" + chr(128310) +
                " Disponibile per scambiare\n" + 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()
        for membro in royalgames:
            if "steam" in royalgames[membro]:
                userids += str(royalgames[membro]["steam"]) + ','
        tosend = "*Su Steam ora:*\n"
        r = steam.getplayersummaries(userids)
        for player in r:
            # In gioco
            if 'gameextrainfo' in player:
                tosend += chr(128308) + " _" + player['gameextrainfo'] + "_ |"
            elif 'gameid' in player:
                tosend += chr(128308) + " _" + player['gameid'] + "_ |"
            # Online
            elif player['personastate'] == 1:
                tosend += chr(128309)
            # Occupato
            elif player['personastate'] == 2:
                tosend += chr(128308)
            # Assente o Inattivo
            elif player['personastate'] == 3 or player['personastate'] == 4:
                tosend += chr(9899)
            # Disponibile per scambiare
            elif player['personastate'] == 5:
                tosend += chr(128310)
            # Disponibile per giocare
            elif player['personastate'] == 6:
                tosend += chr(128311)
            if player['personastate'] != 0:
                tosend += " " + player['personaname'] + "\n"
        else:
            telegram.sendmessage(tosend, sentin, source)
예제 #23
0
def smecds():
    # Secondo me, è colpa...
    print("@" + username + ": /smecds")
    accusato = random.sample([
        "dello stagista", "degli sposi", "di Santinelli", "di Sensei",
        "di Steffo", "di Spaggia", "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",
        "della Supercell", "di Santaclaus", "dei Sims", "dei Santi",
        "di SES2017", "di Salvini"
    ], 1)[0]
    telegram.sendmessage(
        "Secondo me è colpa {accusato}...".format(accusato=accusato), sentin,
        source)
예제 #24
0
파일: bot.py 프로젝트: Steffo99/royal-bot
def online():
    # Elenco di tutte le persone online su Steam
    print("@" + username + ": /online ")
    # Informa Telegram che il messaggio è stato ricevuto.
    telegram.sendchataction(sentin)
    if len(cmd) >= 2:
        if cmd[1].lower() == "help":
            telegram.sendmessage(chr(128309) + " Online\n" +
                                 chr(128308) + " In gioco | Occupato\n" +
                                 chr(9899) + " Assente | Inattivo\n" +
                                 chr(128310) + " Disponibile per scambiare\n" +
                                 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()
        for membro in royalgames:
            if "steam" in royalgames[membro]:
                userids += str(royalgames[membro]["steam"]) + ','
        tosend = "*Su Steam ora:*\n"
        r = steam.getplayersummaries(userids)
        for player in r:
            # In gioco
            if 'gameextrainfo' in player:
                tosend += chr(128308) + " _" + player['gameextrainfo'] + "_ |"
            elif 'gameid' in player:
                tosend += chr(128308) + " _" + player['gameid'] + "_ |"
            # Online
            elif player['personastate'] == 1:
                tosend += chr(128309)
            # Occupato
            elif player['personastate'] == 2:
                tosend += chr(128308)
            # Assente o Inattivo
            elif player['personastate'] == 3 or player['personastate'] == 4:
                tosend += chr(9899)
            # Disponibile per scambiare
            elif player['personastate'] == 5:
                tosend += chr(128310)
            # Disponibile per giocare
            elif player['personastate'] == 6:
                tosend += chr(128311)
            if player['personastate'] != 0:
                tosend += " " + player['personaname'] + "\n"
        else:
            telegram.sendmessage(tosend, sentin, source)
예제 #25
0
def saldi():
    print("@" + username + ": /saldi")
    # Visualizza il link di isthereanydeal con i saldi di un gioco.
    # Informa Telegram che il messaggio è stato ricevuto e visualizza Royal Bot sta scrivendo.
    telegram.sendchataction(sentin)
    cmd = text.split(" ", 1)
    if len(cmd) == 2:
        telegram.sendmessage(
            'Visualizza le offerte di '
            '[' + cmd[1] + '](https://isthereanydeal.com/#/search:' +
            cmd[1].replace(' ', '%20') + ";/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, source)
예제 #26
0
def ciaoruozi():
    print("@" + username + ": /ciaoruozi")
    # Ciao Ruozi.
    if username.lower() == "ruozir":
        # Manda un messaggio casuale tra quelli nella lista
        chosen_msg = random.sample([
            "Ciao me!", "Ciao ciao ciao!", "1 ciaoruozi = 1000€ per me",
            "Ruozi si dice: #CiaoRuozi", "Ciao eh me!", "Ehi me, ma ciao!",
            "Ma ciao me stesso!", "Me me me! Ciao!"
        ], 1)[0]
        telegram.sendmessage(chosen_msg, sentin, source)
    else:
        # Manda un messaggio casuale tra quelli nella lista
        chosen_msg = random.sample([
            "Ciao Ruozi!", "Ciao ciao ciao!", "1 ciaoruozi = 1 prayer",
            "La RYG dice: #CiaoRuozi", "Ciao eh Ruozi!", "Ehi Ruozi, ma ciao!",
            "Ma ciao Ruozi!", "Ruozi ruozi ruozi! Ciao!"
        ], 1)[0]
        telegram.sendmessage(chosen_msg, sentin, source)
예제 #27
0
def match():
    # Visualizza detutti i giochi condivisi tra x persone.
    print("@" + username + ": /match")
    # Informa Telegram che il messaggio è stato ricevuto.
    telegram.sendchataction(sentin)
    tobematched = list()
    if len(cmd) > 2:
        del cmd[0]
        for name in cmd:
            userdata = db.findbyname(name.lower())
            if userdata is not None and 'steam' in userdata:
                if userdata['steam'] not in tobematched:
                    tobematched.append(userdata['steam'])
    if len(tobematched) > 1:
        m = list(steammatch.compare(tobematched))
        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'azione.",
            sentin, source)
예제 #28
0
파일: bot.py 프로젝트: Steffo99/royal-bot
def match():
    # Visualizza detutti i giochi condivisi tra x persone.
    print("@" + username + ": /match")
    # Informa Telegram che il messaggio è stato ricevuto.
    telegram.sendchataction(sentin)
    tobematched = list()
    if len(cmd) > 2:
        del cmd[0]
        for name in cmd:
            userdata = db.findbyname(name.lower())
            if userdata is not None and 'steam' in userdata:
                if userdata['steam'] not in tobematched:
                    tobematched.append(userdata['steam'])
    if len(tobematched) > 1:
        m = list(steammatch.and_games(tobematched))
        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'azione.",
                             sentin, source)
예제 #29
0
파일: bot.py 프로젝트: Steffo99/royal-bot
def ciaostefanino():
    print("@" + username + ": /ciaostefanino")
    # Rispondi salutando Stefanino.
    telegram.sendmessage("Ciao Stefanino!", sentin, source)
    if username != "Steffo":
        telegram.sendmessage("Steffo dice:\n\"Me la pagherai!\"", fromuser, source)
    else:
        telegram.sendmessage("Sei improvvisamente impazzito o cosa?", fromuser, source)
예제 #30
0
파일: bot.py 프로젝트: Steffo99/royal-bot
def lolfree():
    # Visualizza i campioni gratuiti di LoL di questa settimana
    print("@" + username + ": /lolfree")
    # Informa Telegram che il messaggio è stato ricevuto.
    telegram.sendchataction(sentin)
    ora = time.gmtime()
    if len(cmd) > 1:
        refresh_requested = cmd[1].startswith("refresh")
    else:
        refresh_requested = False
    # Controlla se i dati sono già stati scaricati.
    global lolfreestring
    if lolfreestring == "" or refresh_requested:
        # Crea un nuovo set di dati.
        print("Aggiornamento champ gratuiti di League of Legends...")
        lolfreestring = "Champion gratuiti del `" + str(ora.tm_mday) + "/" + str(ora.tm_mon) + "/" + \
                        str(ora.tm_year) + " " + str(ora.tm_hour) + ":" + str(ora.tm_min) + "`\n"
        r = lol.getfreerotation()
        for champion in r:
            staticdata = lol.getchampionstaticdata(champion['id'])
            lolfreestring += "*" + staticdata['name'] + "* " + staticdata['title'] + '\n'
        print("Completato.")
    telegram.sendmessage(lolfreestring, sentin, source)
예제 #31
0
def ciaostefanino():
    print("@" + username + ": /ciaostefanino")
    # Rispondi salutando Stefanino.
    telegram.sendmessage("Ciao Stefanino!", sentin, source)
    if username != "Steffo":
        telegram.sendmessage("Steffo dice:\n\"Me la pagherai!\"", fromuser,
                             source)
    else:
        telegram.sendmessage("Sei improvvisamente impazzito o cosa?", fromuser,
                             source)
예제 #32
0
파일: bot.py 프로젝트: Steffo99/royal-bot
def steamplayers():
    print("@" + username + ": /steamplayers")
    # Informa Telegram che il messaggio è stato ricevuto e visualizza Royal Bot sta scrivendo.
    telegram.sendchataction(sentin)
    # Se è stato specificato un AppID...
    if len(cmd) >= 2:
        n = steam.getnumberofcurrentplayers(cmd[1])
        # Se viene ricevuta una risposta...
        if n is None:
            telegram.sendmessage(chr(9888) + " L'app specificata non esiste!", sentin, source)
        else:
            name = steam.getschemaforgame(cmd[1])['game']['gameName']
            telegram.sendmessage("In questo momento, *{n}* persone stanno giocando a "
                                 "[{name}](https://steamdb.info/app/{id}/graphs/)."
                                 .format(n=str(n), name=name, id=cmd[1]), sentin, source)
    else:
        telegram.sendmessage(chr(9888) + ' Non hai specificato un AppID!\n'
                                         'La sintassi corretta è /playing <AppID>.', sentin, source)
예제 #33
0
파일: bot.py 프로젝트: Steffo99/royal-bot
def diario():
    # Aggiungi una riga al diario Royal Games
    print("@" + username + ": /diario ")
    if len(cmd) > 1:
        if cmd[1].isprintable():
            cmd[1] = cmd[1].replace("\n", " ")
            fdiario = filemanager.readfile("diario.txt")
            fdiario += str(int(time.time())) + "|" + cmd[1] + "\n"
            filemanager.writefile("diario.txt", fdiario)
            telegram.sendmessage("Aggiunto al diario RYG.", sentin, source)
        else:
            telegram.sendmessage(chr(9888) + " Errore nella scrittura del messaggio.\n"
                                             "Il messaggio non è compatibile con il diario.\n"
                                             "Probabilmente contiene emoji o caratteri speciali non visualizzabili.",
                                 sentin, source)
    else:
        telegram.sendmessage(chr(9888) + " Non hai scritto niente sul diario!\n"
                                         "Sintassi corretta: /diario _quello che vuoi scrivere_",
                             sentin, source)
예제 #34
0
def diario():
    # Aggiungi una riga al diario Royal Games
    print("@" + username + ": /diario ")
    if len(cmd) > 1:
        if cmd[1].isprintable():
            cmd[1] = cmd[1].replace("\n", " ")
            fdiario = filemanager.readfile("diario.txt")
            fdiario += str(int(time.time())) + "|" + cmd[1] + "\n"
            filemanager.writefile("diario.txt", fdiario)
            telegram.sendmessage("Aggiunto al diario RYG.", sentin, source)
        else:
            telegram.sendmessage(
                chr(9888) + " Errore nella scrittura del messaggio.\n"
                "Il messaggio non è compatibile con il diario.\n"
                "Probabilmente contiene emoji o caratteri speciali non visualizzabili.",
                sentin, source)
    else:
        telegram.sendmessage(
            chr(9888) + " Non hai scritto niente sul diario!\n"
            "Sintassi corretta: /diario _quello che vuoi scrivere_", sentin,
            source)
예제 #35
0
def diario():
    # Aggiungi una riga al diario Royal Games
    print("@" + username + ": /diario ")
    cmd = text.split(" ", 1)
    if len(cmd) > 1:
        if cmd[1].isprintable():
            cmd[1] = cmd[1].replace("\n", " ")
            fdiario = filemanager.readfile("diario.txt")
            fdiario += str(int(time.time())) + "|" + cmd[1] + "\n"
            filemanager.writefile("diario.txt", fdiario)
            telegram.sendmessage("Aggiunto al diario RYG.", sentin, source)
        else:
            telegram.sendmessage(
                chr(9888) + " Errore nella scrittura del messaggio.\n"
                "Visto che non ho la minima idea delle assurdita che ho scritto qui, "
                "potresti provare a togliere le emoji.", sentin, source)
    else:
        telegram.sendmessage(
            chr(9888) + " Non hai scritto niente sul diario!\n"
            "Sintassi corretta: /diario _quello che vuoi scrivere_", sentin,
            source)
예제 #36
0
def steamplayers():
    print("@" + username + ": /steamplayers")
    # Informa Telegram che il messaggio è stato ricevuto e visualizza Royal Bot sta scrivendo.
    telegram.sendchataction(sentin)
    # Se è stato specificato un AppID...
    if len(cmd) >= 2:
        n = steam.getnumberofcurrentplayers(cmd[1])
        # Se viene ricevuta una risposta...
        if n is None:
            telegram.sendmessage(
                chr(9888) + " L'app specificata non esiste!", sentin, source)
        else:
            name = steam.getschemaforgame(cmd[1])['game']['gameName']
            telegram.sendmessage(
                "In questo momento, *{n}* persone stanno giocando a "
                "[{name}](https://steamdb.info/app/{id}/graphs/).".format(
                    n=str(n), name=name, id=cmd[1]), sentin, source)
    else:
        telegram.sendmessage(
            chr(9888) + ' Non hai specificato un AppID!\n'
            'La sintassi corretta è /playing <AppID>.', sentin, source)
예제 #37
0
def playing():
    print("@" + username + ": /playing")
    # Informa Telegram che il messaggio è stato ricevuto e visualizza Royal Bot sta scrivendo.
    telegram.sendchataction(sentin)
    cmd = text.split(" ")
    # Se è stato specificato un AppID...
    if len(cmd) >= 2:
        n = steam.getnumberofcurrentplayers(cmd[1])
        # Se viene ricevuta una risposta...
        if n is None:
            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,
                source)
    else:
        telegram.sendmessage(
            chr(9888) + ' Non hai specificato un AppID!\n'
            'La sintassi corretta è /playing <AppID>.', sentin, source)
예제 #38
0
def ahnonlosoio():
    print("@" + username + ": /ahnonlosoio")
    # Rispondi con Ah, non lo so nemmeno io.
    telegram.sendmessage("Ah, non lo so nemmeno io!", sentin, source)
예제 #39
0
def racconto(testo):
    sendmessage(chr(128172) + " " + testo, target_group)
예제 #40
0
파일: bot.py 프로젝트: Steffo99/royal-bot
def leggi():
    # Leggi dal diario Royal Games
    print("@" + username + ": /leggi")
    telegram.sendmessage("[Apri il diario RYG](http://royal.steffo.me/diario.htm)!", sentin, source)
예제 #41
0
def wow():
    print("@" + username + ": WOW!")
    telegram.sendmessage("Wow. Impressionante.", sentin, source)
예제 #42
0
def ombromanto():
    print("@" + username + ": /ombromanto")
    # Ma chi è ombromanto?
    telegram.sendmessage("Ombromanto è @Dailir!", sentin, source)
예제 #43
0
파일: bot.py 프로젝트: Steffo99/royal-bot
def version():
    # Visualizza la versione di Royal Bot
    # Solo per UNIX...?
    print("@" + username + ": /version")
    gitmsg = subprocess.check_output(["git", "describe"])
    telegram.sendmessage(gitmsg, sentin, source)
예제 #44
0
파일: bot.py 프로젝트: Steffo99/royal-bot
def ciaospaggia():
    # Buongiorno, stellina!
    print("@" + username + ": /ciaospaggia")
    telegram.sendmessage("Ma buongiorno, [Stellina](https://telegram.me/doom_darth_vader)!", sentin, source)
예제 #45
0
def osucmd():
    print("@" + username + ": /osu")
    # Visualizza il punteggio più recente di osu!
    # Informa Telegram che il messaggio è stato ricevuto.
    telegram.sendchataction(sentin)
    # Trova il nome utente specificato
    # Se è stato specificato un nome utente
    if len(cmd) >= 2:
        # Trova la modalità
        # 0 = osu!
        # 1 = osu!taiko
        # 2 = osu!catch
        # 3 = osu!mania
        # Se è stata specificata una modalità
        if len(cmd) >= 3:
            # Modalità specificata
            mode = int(cmd[2])
        else:
            # Imposta la modalità a osu!
            mode = 0
        # Prova a mandare una richiesta ai server di osu per l'ultima canzone giocata
        try:
            r = osu.getuserrecent(cmd[1], mode)
        # Se la funzione restituisce un errore, riferisci su Telegram l'errore e previeni il crash.
        except NameError:
            telegram.sendmessage(
                chr(9888) + " Errore nella richiesta ai server di Osu!",
                sentin, source)
        # Se tutto va bene, continua!
        else:
            # Se ci sono delle mod attive...
            if "enabled_mods" in r:
                mods = osu.listmods(r['enabled_mods'])
            else:
                mods = ""
            # Specifica cosa vuole dire il grado F e il grado X
            if r['rank'] == 'F':
                r['rank'] = 'Failed'
            elif r['rank'] == 'X':
                r['rank'] = 'Unranked'
            if mode == 0:
                # Visualizza le informazioni relative alla modalità osu!
                telegram.sendmessage(
                    "*osu!*\n"
                    "[Beatmap {0}](https://osu.ppy.sh/b/{0})\n"
                    "*{1}*\n"
                    "{2}\n"
                    "*Punti*: {3}\n"
                    "*Combo* x{4}\n"
                    "*300*: {5}\n"
                    "*100*: {6}\n"
                    "*50*: {7}\n"
                    "*Awesome*: {8}\n"
                    "*Good*: {9}\n"
                    "*Miss*: {10}".format(r['beatmap_id'], r['rank'], mods,
                                          r['score'], r['maxcombo'],
                                          r['count300'], r['count100'],
                                          r['count50'], r['countgeki'],
                                          r['countkatu'], r['countmiss']),
                    sentin, source)
            elif mode == 1:
                # Visualizza le informazioni relative alla modalità osu!taiko
                telegram.sendmessage(
                    "*osu!taiko*\n"
                    "[Beatmap {0}](https://osu.ppy.sh/b/{0})\n"
                    "*{1}*\n"
                    "{2}\n"
                    "*Punti*: {3}\n"
                    "*Combo* x{4}\n"
                    "*Great*: {5}\n"
                    "*Good*: {6}\n"
                    "_Large_ *Great*: {7}\n"
                    "_Large_ *Good*: {8}\n"
                    "*Miss*: {9}".format(r['beatmap_id'], r['rank'], mods,
                                         r['score'], r['maxcombo'],
                                         r['count300'], r['count100'],
                                         r['countgeki'], r['countkatu'],
                                         r['countmiss']), sentin, source)
            elif mode == 2:
                # TODO: Cos'è successo qui?
                # Visualizza le informazioni relative alla modalità osu!catch
                telegram.sendmessage(
                    "*osu!catch*\n"
                    "[Beatmap " + r['beatmap_id'] + "](" +
                    'https://osu.ppy.sh/b/' + r['beatmap_id'] + ")\n*" +
                    r['rank'] + "*\n" + mods + "\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'], sentin, source)
            elif mode == 3:
                # TODO: Cos'è successo qui?
                # Visualizza le informazioni relative alla modalità osu!mania
                telegram.sendmessage(
                    "*osu!mania*\n" + "[Beatmap " + r['beatmap_id'] + "](" +
                    'https://osu.ppy.sh/b/' + r['beatmap_id'] + ")\n*" +
                    r['rank'] + "*\n" + mods + "\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'], sentin, source)
    else:
        # TODO: Mettere a posto sto schifo.
        if "osu" in royalgames[username.lower()]:
            r = osu.getuserrecent(royalgames[username.lower()]['osu'], 0)
            if "enabled_mods" in r:
                mods = osu.listmods(r['enabled_mods'])
            else:
                mods = ""
            telegram.sendmessage(
                "*osu!*\n"
                "[Beatmap {0}](https://osu.ppy.sh/b/{0})\n"
                "*{1}*\n"
                "{2}\n"
                "*Punti*: {3}\n"
                "*Combo* x{4}\n"
                "*300*: {5}\n"
                "*100*: {6}\n"
                "*50*: {7}\n"
                "*Awesome*: {8}\n"
                "*Good*: {9}\n"
                "*Miss*: {10}".format(r['beatmap_id'], r['rank'], mods,
                                      r['score'], r['maxcombo'], r['count300'],
                                      r['count100'], r['count50'],
                                      r['countgeki'], r['countkatu'],
                                      r['countmiss']), sentin, source)
예제 #46
0
파일: bot.py 프로젝트: Steffo99/royal-bot
def wow():
    print("@" + username + ": WOW!")
    telegram.sendmessage("Wow. Impressionante.", sentin, source)
예제 #47
0
파일: bot.py 프로젝트: Steffo99/royal-bot
def osucmd():
    print("@" + username + ": /osu")
    # Visualizza il punteggio più recente di osu!
    # Informa Telegram che il messaggio è stato ricevuto.
    telegram.sendchataction(sentin)
    # Trova il nome utente specificato
    # Se è stato specificato un nome utente
    if len(cmd) >= 2:
        # Trova la modalità
        # 0 = osu!
        # 1 = osu!taiko
        # 2 = osu!catch
        # 3 = osu!mania
        # Se è stata specificata una modalità
        if len(cmd) >= 3:
            # Modalità specificata
            mode = int(cmd[2])
        else:
            # Imposta la modalità a osu!
            mode = 0
        # Prova a mandare una richiesta ai server di osu per l'ultima canzone giocata
        try:
            r = osu.getuserrecent(cmd[1], mode)
        # Se la funzione restituisce un errore, riferisci su Telegram l'errore e previeni il crash.
        except NameError:
            telegram.sendmessage(chr(9888) + " Errore nella richiesta ai server di Osu!", sentin,
                                 source)
        # Se tutto va bene, continua!
        else:
            # Se ci sono delle mod attive...
            if "enabled_mods" in r:
                mods = osu.listmods(r['enabled_mods'])
            else:
                mods = ""
            # Specifica cosa vuole dire il grado F e il grado X
            if r['rank'] == 'F':
                r['rank'] = 'Failed'
            elif r['rank'] == 'X':
                r['rank'] = 'Unranked'
            if mode == 0:
                # Visualizza le informazioni relative alla modalità osu!
                telegram.sendmessage("*osu!*\n"
                                     "[Beatmap {0}](https://osu.ppy.sh/b/{0})\n"
                                     "*{1}*\n"
                                     "{2}\n"
                                     "*Punti*: {3}\n"
                                     "*Combo* x{4}\n"
                                     "*300*: {5}\n"
                                     "*100*: {6}\n"
                                     "*50*: {7}\n"
                                     "*Awesome*: {8}\n"
                                     "*Good*: {9}\n"
                                     "*Miss*: {10}"
                                     .format(r['beatmap_id'],
                                             r['rank'],
                                             mods,
                                             r['score'],
                                             r['maxcombo'],
                                             r['count300'],
                                             r['count100'],
                                             r['count50'],
                                             r['countgeki'],
                                             r['countkatu'],
                                             r['countmiss']), sentin, source)
            elif mode == 1:
                # Visualizza le informazioni relative alla modalità osu!taiko
                telegram.sendmessage("*osu!taiko*\n"
                                     "[Beatmap {0}](https://osu.ppy.sh/b/{0})\n"
                                     "*{1}*\n"
                                     "{2}\n"
                                     "*Punti*: {3}\n"
                                     "*Combo* x{4}\n"
                                     "*Great*: {5}\n"
                                     "*Good*: {6}\n"
                                     "_Large_ *Great*: {7}\n"
                                     "_Large_ *Good*: {8}\n"
                                     "*Miss*: {9}"
                                     .format(r['beatmap_id'],
                                             r['rank'],
                                             mods,
                                             r['score'],
                                             r['maxcombo'],
                                             r['count300'],
                                             r['count100'],
                                             r['countgeki'],
                                             r['countkatu'],
                                             r['countmiss']), sentin, source)
            elif mode == 2:
                # TODO: Cos'è successo qui?
                # Visualizza le informazioni relative alla modalità osu!catch
                telegram.sendmessage("*osu!catch*\n"
                                     "[Beatmap " + r['beatmap_id'] + "](" + 'https://osu.ppy.sh/b/' + r[
                                         'beatmap_id'] +
                                     ")\n*" + r['rank'] + "*\n" + mods +
                                     "\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'], sentin, source)
            elif mode == 3:
                # TODO: Cos'è successo qui?
                # Visualizza le informazioni relative alla modalità osu!mania
                telegram.sendmessage("*osu!mania*\n" +
                                     "[Beatmap " + r['beatmap_id'] + "](" + 'https://osu.ppy.sh/b/' + r[
                                         'beatmap_id'] + ")\n*" + r['rank'] + "*\n" + mods +
                                     "\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'], sentin, source)
    else:
        # TODO: Mettere a posto sto schifo.
        if "osu" in royalgames[username.lower()]:
            r = osu.getuserrecent(royalgames[username.lower()]['osu'], 0)
            if "enabled_mods" in r:
                mods = osu.listmods(r['enabled_mods'])
            else:
                mods = ""
            telegram.sendmessage("*osu!*\n"
                                 "[Beatmap {0}](https://osu.ppy.sh/b/{0})\n"
                                 "*{1}*\n"
                                 "{2}\n"
                                 "*Punti*: {3}\n"
                                 "*Combo* x{4}\n"
                                 "*300*: {5}\n"
                                 "*100*: {6}\n"
                                 "*50*: {7}\n"
                                 "*Awesome*: {8}\n"
                                 "*Good*: {9}\n"
                                 "*Miss*: {10}"
                                 .format(r['beatmap_id'],
                                         r['rank'],
                                         mods,
                                         r['score'],
                                         r['maxcombo'],
                                         r['count300'],
                                         r['count100'],
                                         r['count50'],
                                         r['countgeki'],
                                         r['countkatu'],
                                         r['countmiss']), sentin, source)
예제 #48
0
파일: bot.py 프로젝트: Steffo99/royal-bot
            # Persona che ha inviato il messaggio
            fromuser = msg['from']['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
                username = msg['from']['username']
            else:
                # Altrimenti, salva l'userID
                username = str(msg['from']['id'])
            # Se sei un membro della Royal Games
            if username.lower() in royalgames:
                # Riconosci il comando e dividilo in comando e argomenti.
                cmd = text.lower().split(" ")
                # Togli il @RoyalBot alla fine del comando
                cmd[0] = cmd[0].replace("@royalbot", "").replace("/", "")
                # Prova ad eseguire il comando. Se non è nella lista degli alias, ignoralo.
                try:
                    aliases[cmd[0]]()
                except KeyError:
                    print("@" + username + ": comando inesistente")
            else:
                print("@" + username + " bloccato.")
    except Exception as e:
        telegram.sendmessage(chr(9762) + " *Errore critico:\n*"
                                         "{0}\n\n"
                                         "Secondo me, è colpa dello stagista.".format(repr(e)), -2141322)
        print("\033[1mERRORE CRITICO:\n"
              "{0}\033[0m".format(repr(e)))
예제 #49
0
def ehoh():
    print("@" + username + ": /ehoh")
    # Rispondi con Eh, oh. Sono cose che capitano.
    telegram.sendmessage("Eh, oh. Sono cose che capitano.", sentin, source)
예제 #50
0
                return 3


# Modifica la vita. Mettere valori negativi per ridurla, positivi per aumentarla.
def vita(var):
    global hp
    hp = hp + var
    sendmessage(chr(10084) + ' ' + str(var) + "\n" + "Ora avete " + str(hp) + " punti vita.", target_group)
    if hp <= 0:
        sendmessage("Hai finito la vita! Game over!", target_group)
        sys.exit()


# Qui inizia la storia...
# Copyright @MaxSensei 2015
sendmessage("Benvenuto a Royal Bot Adventures !\nStoria scritta da @MaxSensei", target_group)
racconto("Vi svegliate in un luogo del tutto buio, sentite un flebile respiro da qualche parte nel buio."
         " Tastate la vostra fedelissima spada. Cercate di ricordare qualcosa ma con scarso successo (originale eh?). ")
while True:
    s = trescelte("Brandite la spada verso i respiri nel buio", "Chiedete chi è ad alta voce", "State zitti e immobili")
    if s == 1:
        racconto("Ahia! Tu e la tua compagnia vi colpite a vicenda con le spade.")
        vita(-15)
    elif s == 2:
        racconto("Riconoscete i vostri amici e vi ritenete fortunati di non aver ferito nessuno.")
        break
    elif s == 3:
        racconto("Che codardi, tanto non succede nulla...")
        break
racconto("Siete in un luogo del tutto buio, ma vedete della luce molto lontano.")
while True:
예제 #51
0
파일: bot.py 프로젝트: Steffo99/royal-bot
def getrygimage():
    # Ricevi il link alla tua immagine del profilo Royal Games.
    print("@" + username + ": /getrygimage")
    telegram.sendmessage("[Scarica](https://dl.dropboxusercontent.com/u/23313381/Logo/Personali/{tag}.png)"
                         " la tua immagine del profilo Royal Games!".format(tag=royalgames[username.lower()]['icon']),
                         sentin, source)
예제 #52
0
def leggi():
    # Leggi dal diario Royal Games
    print("@" + username + ": /leggi")
    telegram.sendmessage(
        "[Apri il diario RYG](http://royal.steffo.me/diario.htm)!", sentin,
        source)
예제 #53
0
 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
     username = msg['from']['username']
 else:
     # Altrimenti, salva l'userID
     username = str(msg['from']['id'])
 # Se sei un membro della Royal Games
 if username.lower() in royalgames:
     # Riconosci il comando.
     # Viene usato startswith perchè il comando potrebbe anche essere inviato in forma /ciao@RoyalBot.
     if text.startswith('/ahnonlosoio'):
         print("@" + username + ": /ahnonlosoio")
         # Rispondi con Ah, non lo so nemmeno io.
         telegram.sendmessage("Ah, non lo so nemmeno io!", sentin, source)
     elif text.startswith('/ciaostefanino'):
         print("@" + username + ": /ciaostefanino")
         # Rispondi salutando Stefanino.
         telegram.sendmessage("Ciao Stefanino!!!", sentin, source)
     elif text.startswith('/ciaoruozi'):
         print("@" + username + ": /ciaoruozi")
         # Ciao Ruozi.
         telegram.sendmessage("Ciao Ruozi", sentin, source)
     elif text.startswith('/ehoh'):
         print("@" + username + ": /ehoh")
         # Rispondi con Eh, oh. Sono cose che capitano.
         telegram.sendmessage("Eh, oh. Sono cose che capitano.", sentin, source)
     elif text.startswith('/playing'):
         print("@" + username + ": /playing")
         # Informa Telegram che il messaggio è stato ricevuto e visualizza Royal Bot sta scrivendo.
예제 #54
0
def ciaospaggia():
    # Buongiorno, stellina!
    print("@" + username + ": /ciaospaggia")
    telegram.sendmessage(
        "Ma buongiorno, [Stellina](https://telegram.me/doom_darth_vader)!",
        sentin, source)
예제 #55
0
            # Persona che ha inviato il messaggio
            fromuser = msg['from']['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
                username = msg['from']['username']
            else:
                # Altrimenti, salva l'userID
                username = str(msg['from']['id'])
            # Se sei un membro della Royal Games
            if username.lower() in royalgames:
                # Riconosci il comando e dividilo in comando e argomenti.
                cmd = text.lower().split(" ")
                # Togli il @RoyalBot alla fine del comando
                cmd[0] = cmd[0].replace("@royalbot", "").replace("/", "")
                # Prova ad eseguire il comando. Se non è nella lista degli alias, ignoralo.
                try:
                    aliases[cmd[0]]()
                except KeyError:
                    print("@" + username + ": comando inesistente")
            else:
                print("@" + username + " bloccato.")
    except Exception as e:
        telegram.sendmessage(
            chr(9762) + " *Errore critico:\n*"
            "{0}\n\n"
            "Secondo me, è colpa dello stagista.".format(repr(e)), -2141322)
        print("\033[1mERRORE CRITICO:\n" "{0}\033[0m".format(repr(e)))
예제 #56
0
def version():
    # Visualizza la versione di Royal Bot
    # Solo per UNIX...?
    print("@" + username + ": /version")
    gitmsg = subprocess.check_output(["git", "describe"])
    telegram.sendmessage(gitmsg, sentin, source)
예제 #57
0
파일: bot.py 프로젝트: Steffo99/royal-bot
def ombromanto():
    print("@" + username + ": /ombromanto")
    # Ma chi è ombromanto?
    telegram.sendmessage("Ombromanto è @Dailir!", sentin, source)
예제 #58
0
파일: bot.py 프로젝트: Steffo99/royal-bot
def ahnonlosoio():
    print("@" + username + ": /ahnonlosoio")
    # Rispondi con Ah, non lo so nemmeno io.
    telegram.sendmessage("Ah, non lo so nemmeno io!", sentin, source)
예제 #59
0
파일: bot.py 프로젝트: Steffo99/royal-bot
def ehoh():
    print("@" + username + ": /ehoh")
    # Rispondi con Eh, oh. Sono cose che capitano.
    telegram.sendmessage("Eh, oh. Sono cose che capitano.", sentin, source)
예제 #60
0
 def ask(self):
     telegram.sendmessage(self.domanda, self.chat)