示例#1
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)
示例#2
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)
示例#3
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)