예제 #1
0
def arriscarPalavra2(chat_id, u_id, u_name, message_id, text):
    l = c.getLanguage(chat_id)
    bds.setArriscarBlock(chat_id, False)
    rpl = []
    palavra = bds.getPalavra(chat_id)
    if bds.checkPalavra(chat_id, u_id, text): #Jogador acertou o chute e venceu. O jogo acaba.
        keyboard = c.makeKb(c.getKb(chat_id, 'main')[0], resize_keyboard = True)
        rpl.append(c.toDict(chat_id, l.venceu(u_name) + '\n' + l.googleMsg(palavra), replyMarkup = keyboard))
        #rpl.append(c.toDict(chat_id, l.googleMsg(palavra)))
        return rpl
    else: #Jogador errou o chute
        rm = bds.rmPlayer(chat_id, u_id, message_id)
        if rm == True: #Jogador não era Adm, nada acontece.
            rpl.append(c.toDict(chat_id, l.perdeu(u_name), replyTo = message_id, replyMarkup = c.makeKbh(True, selective = True)))
            rpl.append(nextRound(chat_id))
            return rpl
        elif rm == 'setAdm': #Jogador era Adm e o Adm será passado para outro
            adm = bds.getAdm(chat_id)
            rpl.append(c.toDict(chat_id, l.perdeu(u_name) + '\n' + l.novoAdmMsg(adm[1]), replyTo = message_id, replyMarkup = c.makeKbh(True, selective = True)))
            #rpl.append(c.toDict(chat_id, l.novoAdmMsg(adm[1])))
            rpl.append(nextRound(chat_id))
            return rpl
        else: #O jogo acaba
            keyboard = c.makeKb(c.getKb(chat_id, 'main')[0], resize_keyboard = True)
            return [c.toDict(chat_id, l.perdeu(u_name)+'\n'+ l.gameover_msg, replyMarkup = keyboard)]
예제 #2
0
def cancelarJogo(chat_id, u_id):
    l = c.getLanguage(chat_id)
    if bds.checkAdm(chat_id, u_id):
        bds.delGame(chat_id)
        keyboard = c.makeKb(c.getKb(chat_id, 'main')[0], resize_keyboard = True)
        return [c.toDict(chat_id, l.cancelar_jogo_msg, replyMarkup = keyboard)]
    return [c.toDict(chat_id, l.cantdo_msg)]
예제 #3
0
def chutarLetra(chat_id, u_id, u_name, message_id, letra):
    l = c.getLanguage(chat_id)
    r = bds.checkLetra(chat_id, u_id, letra)
    #print r
    rpl = []
    if r == True:  #Se acertou a letra
        rpl.append(
            c.toDict(chat_id,
                     l.acertou_letra_msg,
                     replyTo=message_id,
                     replyMarkup=c.makeKbh(True, selective=True)))
        rpl.append(nextRound(chat_id))
    elif r == 2:  #Se a letra já foi chutada
        rpl.append(c.toDict(chat_id, l.jachutada_msg))
    elif type(r) == type("str"):
        rpl = arriscarPalavra2(chat_id, u_id, u_name, message_id, r)
    else:  #Se errou a letra
        rpl.append(
            c.toDict(chat_id,
                     l.errou_letra_msg,
                     replyTo=message_id,
                     replyMarkup=c.makeKbh(True, selective=True)))
        vida = bds.menosVida(chat_id)
        if vida == True:  #Se acabou as vidas
            keyboard = c.makeKb(c.getKb(chat_id, 'main')[0],
                                resize_keyboard=True)
            rpl.append(c.toDict(chat_id, l.gameover_msg, replyMarkup=keyboard))
        elif vida == 2:  #Se resta somente uma vida
            rpl.append(c.toDict(chat_id, l.umavida_msg))
            rpl.append(nextRound(chat_id))
        else:
            rpl.append(nextRound(chat_id))
    return rpl
예제 #4
0
def fecharJogo(chat_id, u_id, message_id, date):
    l = c.getLanguage(chat_id)
    rpl = []
    if bds.checkAdm(chat_id, u_id):
        bds.setPreGame(chat_id, False)
        bds.setInGame(chat_id, True)
        lista = bds.getCats(chat_id)
        if ((len(lista) == 0) or (0 in lista)):
            categoria = randint(0, (len(l.palavras)-1))
        else:
            cat = randint(0, len(lista)-1)
            categoria = lista[cat]-1
        palavra = randint(1, (len(l.palavras[categoria])-1))
        palavra = l.palavras[categoria][palavra].decode('utf-8')
        categoria = l.palavras[categoria][0]
        mascara = bds.setCP(chat_id, categoria, palavra)
        vidas = bds.setVidas(chat_id)
        bds.shufflePlayers(chat_id, date)
        u_names = bds.getPlayers(chat_id)[1]
        message_ids = bds.getPlayers(chat_id)[2]
        ordem = ''
        for i in range(len(u_names)):
            ordem = ordem+u_names[i]+'\n'
        kb = c.makeKb(c.getKb(chat_id, 'main')[0], resize_keyboard = True, selective = True)
        rpl.append(c.toDict(chat_id, l.close_game_msg, replyMarkup = c.makeKbh(True)))
        rpl.append(c.toDict(chat_id, ordem, replyTo = message_ids[0], replyMarkup = kb))
        rpl.append(c.toDict(chat_id, l.categoria_msg+categoria))
        rpl.append(c.toDict(chat_id, l.palavra_msg+mascara))
        rpl.append(c.toDict(chat_id, l.vidas_msg+g.vidasEmoji(chat_id)))
        return rpl
    return [c.toDict(chat_id, l.cantdo_msg)]
예제 #5
0
def cancelarJogo(chat_id, u_id):
    l = c.getLanguage(chat_id)
    if bds.checkAdm(chat_id, u_id):
        bds.delGame(chat_id)
        keyboard = c.makeKb(c.getKb(chat_id, 'main')[0], resize_keyboard = True)
        return [c.toDict(chat_id, l.cancelar_jogo_msg, replyMarkup = keyboard)]
    return [c.toDict(chat_id, l.cantdo_msg)]
예제 #6
0
def fecharJogo(chat_id, u_id, message_id, date):
    l = c.getLanguage(chat_id)
    rpl = []
    if bds.checkAdm(chat_id, u_id):
        bds.setPreGame(chat_id, False)
        bds.setInGame(chat_id, True)
        lista = bds.getCats(chat_id)
        if ((len(lista) == 0) or (0 in lista)):
            categoria = randint(0, (len(l.palavras)-1))
        else:
            cat = randint(0, len(lista)-1)
            categoria = lista[cat]-1
        palavra = randint(1, (len(l.palavras[categoria])-1))
        palavra = l.palavras[categoria][palavra].decode('utf-8')
        categoria = l.palavras[categoria][0]
        mascara = bds.setCP(chat_id, categoria, palavra)
        vidas = bds.setVidas(chat_id)
        bds.shufflePlayers(chat_id, date)
        u_names = bds.getPlayers(chat_id)[1]
        message_ids = bds.getPlayers(chat_id)[2]
        ordem = ''
        for i in range(len(u_names)):
            ordem = ordem+u_names[i]+'\n'
        kb = c.makeKb(c.getKb(chat_id, 'main')[0], resize_keyboard = True, selective = True)
        rpl.append(c.toDict(chat_id, l.close_game_msg, replyMarkup = c.makeKbh(True)))
        rpl.append(c.toDict(chat_id, ordem + '\n' + l.categoria_msg+categoria +
                                    '\n' + l.palavra_msg+mascara + '\n' +  
                                    l.vidas_msg+g.vidasEmoji(chat_id),
                                    replyTo = message_ids[0], replyMarkup = kb))
        """rpl.append(c.toDict(chat_id, l.categoria_msg+categoria))
        rpl.append(c.toDict(chat_id, l.palavra_msg+mascara))
        rpl.append(c.toDict(chat_id, l.vidas_msg+g.vidasEmoji(chat_id)))"""
        return rpl
    return [c.toDict(chat_id, l.cantdo_msg)]
예제 #7
0
def nextRound(chat_id):
    l = c.getLanguage(chat_id)
    bds.roundPlus(chat_id)
    players = bds.getPlayers(chat_id)
    aRound = bds.getRound(chat_id)
    vidas = vidasEmoji(chat_id)
    categoria = bds.getCategoria(chat_id)
    keyboard = c.makeKb(c.getKb(chat_id, 'main')[0], resize_keyboard = True, selective = True)
    return c.toDict(chat_id, (categoria+'\n\n'+bds.getMascara(chat_id)+'\n\n'+l.vidas_msg+vidas+'\n'+l.nextPlayer(players[1][aRound])), replyTo = players[2][aRound], replyMarkup = keyboard)
예제 #8
0
def arriscarPalavra2(chat_id, u_id, u_name, message_id, text):
    l = c.getLanguage(chat_id)
    bds.setArriscarBlock(chat_id, False)
    rpl = []
    palavra = bds.getPalavra(chat_id)
    if bds.checkPalavra(
            chat_id, u_id,
            text):  #Jogador acertou o chute e venceu. O jogo acaba.
        keyboard = c.makeKb(c.getKb(chat_id, 'main')[0], resize_keyboard=True)
        rpl.append(
            c.toDict(chat_id,
                     l.venceu(u_name) + '\n' + l.googleMsg(palavra),
                     replyMarkup=keyboard))
        #rpl.append(c.toDict(chat_id, l.googleMsg(palavra)))
        return rpl
    else:  #Jogador errou o chute
        rm = bds.rmPlayer(chat_id, u_id, message_id)
        if rm == True:  #Jogador não era Adm, nada acontece.
            rpl.append(
                c.toDict(chat_id,
                         l.perdeu(u_name),
                         replyTo=message_id,
                         replyMarkup=c.makeKbh(True, selective=True)))
            rpl.append(nextRound(chat_id))
            return rpl
        elif rm == 'setAdm':  #Jogador era Adm e o Adm será passado para outro
            adm = bds.getAdm(chat_id)
            rpl.append(
                c.toDict(chat_id,
                         l.perdeu(u_name) + '\n' + l.novoAdmMsg(adm[1]),
                         replyTo=message_id,
                         replyMarkup=c.makeKbh(True, selective=True)))
            #rpl.append(c.toDict(chat_id, l.novoAdmMsg(adm[1])))
            rpl.append(nextRound(chat_id))
            return rpl
        else:  #O jogo acaba
            keyboard = c.makeKb(c.getKb(chat_id, 'main')[0],
                                resize_keyboard=True)
            return [
                c.toDict(chat_id,
                         l.perdeu(u_name) + '\n' + l.gameover_msg,
                         replyMarkup=keyboard)
            ]
예제 #9
0
def sair(chat_id, u_id, u_name, message_id):
    aux = bds.rmPlayer(chat_id, u_id, message_id)
    l = c.getLanguage(chat_id)
    if aux == False:
        kb = c.makeKb(c.getKb(chat_id, 'main')[0], resize_keyboard = True)
        return [c.toDict(chat_id, l.sem_jogador_msg, replyMarkup = kb)]
    elif aux == 'setAdm':
        rpl = []
        pl = bds.getPlayers(chat_id)
        kb = c.makeKb(c.getKb(chat_id, 'main', u_id = u_id)[0], selective = True, resize_keyboard = True)
        rpl.append(c.toDict(chat_id, l.playerQuitMsg(u_name), replyTo = message_id, replyMarkup = kb))
        kb = c.makeKb(c.getKb(chat_id,'main')[1], resize_keyboard = True, selective = True)
        rpl.append(c.toDict(chat_id, l.novoAdmMsg(pl[1][0]), replyTo = pl[2][0], replyMarkup = kb))
        return rpl
    elif aux == True:
        kb = c.makeKb(c.getKb(chat_id,'main',u_id = u_id)[0], selective = True, resize_keyboard = True)
        return [c.toDict(chat_id, l.playerQuitMsg(u_name), replyTo = message_id, replyMarkup = kb)]
    elif aux == 'semPlayer':
        return [c.toDict(chat_id, l.is_out_msg)]
예제 #10
0
def sair(chat_id, u_id, u_name, message_id):
    aux = bds.rmPlayer(chat_id, u_id, message_id)
    l = c.getLanguage(chat_id)
    if aux == False:
        kb = c.makeKb(c.getKb(chat_id, 'main')[0], resize_keyboard = True)
        return [c.toDict(chat_id, l.sem_jogador_msg, replyMarkup = kb)]
    elif aux == 'setAdm':
        rpl = []
        pl = bds.getPlayers(chat_id)
        kb = c.makeKb(c.getKb(chat_id, 'main', u_id = u_id)[0], selective = True, resize_keyboard = True)
        rpl.append(c.toDict(chat_id, l.playerQuitMsg(u_name), replyTo = message_id, replyMarkup = kb))
        kb = c.makeKb(c.getKb(chat_id,'main')[1], resize_keyboard = True, selective = True)
        rpl.append(c.toDict(chat_id, l.novoAdmMsg(pl[1][0]), replyTo = pl[2][0], replyMarkup = kb))
        return rpl
    elif aux == True:
        kb = c.makeKb(c.getKb(chat_id,'main',u_id = u_id)[0], selective = True, resize_keyboard = True)
        return [c.toDict(chat_id, l.playerQuitMsg(u_name), replyTo = message_id, replyMarkup = kb)]
    elif aux == 'semPlayer':
        return [c.toDict(chat_id, l.is_out_msg)]
예제 #11
0
def entrar(chat_id, u_id, u_name, message_id):
    l = c.getLanguage(chat_id)
    if bds.addPlayer(chat_id, u_id, u_name, message_id):
        kb = c.makeKb(c.getKb(chat_id, 'main', u_id=u_id)[0],
                      selective=True,
                      resize_keyboard=True)
        return [
            c.toDict(chat_id,
                     l.entrarMsg(u_name),
                     replyTo=message_id,
                     replyMarkup=kb)
        ]
    return [c.toDict(chat_id, l.esta_dentro_msg)]
예제 #12
0
def arriscarPalavra2(chat_id, u_id, u_name, message_id, text):
    l = c.getLanguage(chat_id)
    bds.setArriscarBlock(chat_id, False)
    if bds.checkPalavra(chat_id, u_id, text):
        keyboard = c.makeKb(c.getKb(chat_id, 'main')[0], resize_keyboard = True)
        return [c.toDict(chat_id, l.venceu(u_name), replyMarkup = keyboard)]
    else:
        rm = bds.rmPlayer(chat_id, u_id, message_id)
        if rm == True:
            rpl = []
            rpl.append(c.toDict(chat_id, l.perdeu(u_name), replyTo = message_id, replyMarkup = c.makeKbh(True, selective = True)))
            rpl.append(nextRound(chat_id))
            return rpl
        elif rm == 'setAdm':
            rpl = []
            adm = bds.getAdm(chat_id)
            rpl.append(c.toDict(chat_id, l.perdeu(u_name), replyTo = message_id, replyMarkup = c.makeKbh(True, selective = True)))
            rpl.append(c.toDict(chat_id, l.novoAdmMsg(adm[1])))
            rpl.append(nextRound(chat_id))
            return rpl
        else:
            keyboard = c.makeKb(c.getKb(chat_id, 'main')[0], resize_keyboard = True)
            return [c.toDict(chat_id, l.perdeu(u_name)+'\n'+ l.gameover_msg, replyMarkup = keyboard)]
예제 #13
0
def nextRound(chat_id):
    l = c.getLanguage(chat_id)
    bds.roundPlus(chat_id)
    players = bds.getPlayers(chat_id)
    aRound = bds.getRound(chat_id)
    vidas = vidasEmoji(chat_id)
    categoria = bds.getCategoria(chat_id)
    keyboard = c.makeKb(c.getKb(chat_id, 'main')[0],
                        resize_keyboard=True,
                        selective=True)
    return c.toDict(
        chat_id,
        (categoria + '\n\n' + bds.getMascara(chat_id) + '\n\n' + l.vidas_msg +
         vidas + '\n' + l.nextPlayer(players[1][aRound])),
        replyTo=players[2][aRound],
        replyMarkup=keyboard)
예제 #14
0
def chutarLetra(chat_id, u_id, message_id, letra):
    l = c.getLanguage(chat_id)
    r = bds.checkLetra(chat_id, u_id, letra)
    rpl = []
    if r == True: #Se acertou a letra
        rpl.append(c.toDict(chat_id, l.acertou_letra_msg, replyTo = message_id, replyMarkup = c.makeKbh(True, selective = True)))
        rpl.append(nextRound(chat_id))
    elif r == 2: #Se a letra já foi chutada
        rpl.append(c.toDict(chat_id, l.jachutada_msg))
    else: #Se errou a letra
        rpl.append(c.toDict(chat_id, l.errou_letra_msg, replyTo = message_id, replyMarkup = c.makeKbh(True, selective = True)))
        vida = bds.menosVida(chat_id)
        if vida == True: #Se acabou as vidas
            keyboard = c.makeKb(c.getKb(chat_id, 'main')[0], resize_keyboard = True)
            rpl.append(c.toDict(chat_id, l.gameover_msg, replyMarkup = keyboard))
        elif vida == 2: #Se resta somente uma vida
            rpl.append(c.toDict(chat_id, l.umavida_msg))
            rpl.append(nextRound(chat_id))
        else:
            rpl.append(nextRound(chat_id))
    return rpl
예제 #15
0
def setCategorias(chat_id, text, message_id, u_id):
    l = c.getLanguage(chat_id)
    cats = []
    text = text.split(' ')
    try:
        for i in range(len(text)):
            if ((int(text[i]) <= len(l.palavras)) and (int(text[i]) >= 0) and (int(text[i]) not in cats)): #Tratamento de macacagem
                cats.append(int(text[i]))
            else:
                int('a') # T_T
    except Exception, e: #Caso existam elementos diferentes de numeros
        return [c.toDict(chat_id, l.cat_erro_msg, replyTo = message_id, replyMarkup = c.makeFr(True, selective = True))]

    bds.setCats(chat_id,cats)
    kb = c.makeKb(c.getKb(chat_id,'main',u_id = u_id)[1], selective = True, resize_keyboard = True)
    return [c.toDict(chat_id, l.categorias_msg, replyTo = message_id, replyMarkup = kb)]



def entrar(chat_id, u_id, u_name, message_id):
    l = c.getLanguage(chat_id)
    if bds.addPlayer(chat_id, u_id, u_name, message_id):
        kb = c.makeKb(c.getKb(chat_id,'main',u_id = u_id)[0], selective = True, resize_keyboard = True)
        return [c.toDict(chat_id, l.entrarMsg(u_name), replyTo = message_id, replyMarkup = kb )]
    return [c.toDict(chat_id, l.esta_dentro_msg)]

def sair(chat_id, u_id, u_name, message_id):
    aux = bds.rmPlayer(chat_id, u_id, message_id)
    l = c.getLanguage(chat_id)
    if aux == False:
예제 #16
0
def entrar(chat_id, u_id, u_name, message_id):
    l = c.getLanguage(chat_id)
    if bds.addPlayer(chat_id, u_id, u_name, message_id):
        kb = c.makeKb(c.getKb(chat_id,'main',u_id = u_id)[0], selective = True, resize_keyboard = True)
        return [c.toDict(chat_id, l.entrarMsg(u_name), replyTo = message_id, replyMarkup = kb )]
    return [c.toDict(chat_id, l.esta_dentro_msg)]
예제 #17
0
def setCategorias(chat_id, text, message_id, u_id):
    l = c.getLanguage(chat_id)
    cats = []
    text = text.split(' ')
    try:
        for i in range(len(text)):
            if ((int(text[i]) <= len(l.palavras)) and (int(text[i]) >= 0) and (int(text[i]) not in cats)): #Tratamento de macacagem
                cats.append(int(text[i]))
            else:
                int('a') # T_T
    except Exception, e: #Caso existam elementos diferentes de numeros
        return [c.toDict(chat_id, l.cat_erro_msg, replyTo = message_id, replyMarkup = c.makeFr(True, selective = True))]

    bds.setCats(chat_id,cats)
    kb = c.makeKb(c.getKb(chat_id,'main',u_id = u_id)[1], selective = True, resize_keyboard = True)
    return [c.toDict(chat_id, l.categorias_msg, replyTo = message_id, replyMarkup = kb)]



def entrar(chat_id, u_id, u_name, message_id):
    l = c.getLanguage(chat_id)
    if bds.addPlayer(chat_id, u_id, u_name, message_id):
        kb = c.makeKb(c.getKb(chat_id,'main',u_id = u_id)[0], selective = True, resize_keyboard = True)
        return [c.toDict(chat_id, l.entrarMsg(u_name), replyTo = message_id, replyMarkup = kb )]
    return [c.toDict(chat_id, l.esta_dentro_msg)]

def sair(chat_id, u_id, u_name, message_id):
    aux = bds.rmPlayer(chat_id, u_id, message_id)
    l = c.getLanguage(chat_id)
    if aux == False:
예제 #18
0
        for i in range(len(text)):
            if ((int(text[i]) <= len(l.palavras)) and (int(text[i]) >= 0)
                    and (int(text[i]) not in cats)):  #Tratamento de macacagem
                cats.append(int(text[i]))
            else:
                int('a')  # T_T
    except Exception, e:  #Caso existam elementos diferentes de numeros
        return [
            c.toDict(chat_id,
                     l.cat_erro_msg,
                     replyTo=message_id,
                     replyMarkup=c.makeFr(True, selective=True))
        ]

    bds.setCats(chat_id, cats)
    kb = c.makeKb(c.getKb(chat_id, 'main', u_id=u_id)[1],
                  selective=True,
                  resize_keyboard=True)
    return [
        c.toDict(chat_id, l.categorias_msg, replyTo=message_id, replyMarkup=kb)
    ]


def entrar(chat_id, u_id, u_name, message_id):
    l = c.getLanguage(chat_id)
    if bds.addPlayer(chat_id, u_id, u_name, message_id):
        kb = c.makeKb(c.getKb(chat_id, 'main', u_id=u_id)[0],
                      selective=True,
                      resize_keyboard=True)
        return [
            c.toDict(chat_id,