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)]
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)]
def getKb(chat_id, k, u_id = None): l = getLanguage(chat_id) kb = [] if k == 'main': if bds.getEnabled(chat_id): if bds.getInGame(chat_id): if bds.getArriscarBlock(chat_id): kb.append([[l.voltar]]) else: letras = bds.getLetras(chat_id) kb.append([letras[0], letras[1], letras[2], [l.arriscar], [l.comandos]]) elif bds.getPreGame(chat_id): if u_id in bds.getPlayers(chat_id)[0]: kb.append([[l.sair], [l.comandos]]) else: kb.append([[l.entrar], [l.comandos]]) kb.append([[l.cancelar_jogo, l.fechar_jogo], [l.comandos]]) else: kb.append([[l.novojogo], [l.ajuda, l.rank], [l.config], [l.desligar]]) else: kb.append([[l.ligar]]) elif k == 'cmd': if bds.getInGame(chat_id): kb.append([[l.ajuda, l.rank], [l.config], [l.voltar], [l.desligar]]) kb.append([[l.cancelar_jogo], [l.ajuda, l.rank], [l.config, l.voltar], [l.desligar]]) elif bds.getPreGame(chat_id): kb.append([[l.ajuda, l.rank], [l.config, l.voltar], [l.desligar]]) elif k == 'config': kb.append([['Português(BR)' + emoji_br, 'English(US)' + emoji_usa], [l.ajuda], [l.voltar]]) elif k == 'fora': kb.append([[l.esta_fora]]) elif k == 'first': kb.append([['Português(BR)' + emoji_br, 'English(US)' + emoji_usa]]) return kb
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)
def getKb(chat_id, k, u_id=None): l = getLanguage(chat_id) kb = [] if k == 'main': if bds.getEnabled(chat_id): if bds.getInGame(chat_id): if bds.getArriscarBlock(chat_id): kb.append([[l.voltar]]) else: letras = bds.getLetras(chat_id) kb.append([ letras[0], letras[1], letras[2], [l.arriscar], [l.comandos] ]) #letters keyboard elif bds.getPreGame(chat_id): if u_id in bds.getPlayers(chat_id)[0]: kb.append([[l.sair], [l.comandos]]) #Pre-game in else: kb.append([[l.entrar], [l.comandos]]) #Pre-game out kb.append([[l.cancelar_jogo, l.fechar_jogo], [l.categorias_btn], [l.comandos]]) #Pre-game admin else: kb.append([[l.novojogo], [l.ajuda, l.rank], [l.config, l.sobre], [l.desligar]]) #Main else: kb.append([[l.ligar]]) #Off elif k == 'cmd': if bds.getInGame(chat_id): kb.append([[l.ajuda, l.rank], [l.config], [l.voltar], [l.desligar]]) kb.append([[l.cancelar_jogo], [l.ajuda, l.rank], [l.config, l.voltar], [l.desligar]]) elif bds.getPreGame(chat_id): kb.append([[l.ajuda, l.rank], [l.config, l.voltar], [l.desligar]]) elif k == 'config': kb.append([[ 'Português(BR)' + emoji_br, 'English(US)' + emoji_usa, 'עברית (ישראל)' + emoji_hb ], [l.ajuda], [l.voltar]]) elif k == 'fora': kb.append([[l.esta_fora]]) elif k == 'first': kb.append([[ 'Português(BR)' + emoji_br, 'English(US)' + emoji_usa, 'עברית (ישראל)' + emoji_hb ]]) if (len(kb) == 0): kb = [[l.att_kb]] return kb
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)
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)]
def getKb(chat_id, k, u_id = None): l = getLanguage(chat_id) kb = [] if k == 'main': if bds.getEnabled(chat_id): if bds.getInGame(chat_id): if bds.getArriscarBlock(chat_id): kb.append([[l.voltar]]) else: letras = bds.getLetras(chat_id) kb.append([letras[0], letras[1], letras[2], [l.arriscar], [l.comandos]]) #letters keyboard elif bds.getPreGame(chat_id): if u_id in bds.getPlayers(chat_id)[0]: kb.append([[l.sair], [l.comandos]]) #Pre-game in else: kb.append([[l.entrar], [l.comandos]]) #Pre-game out kb.append([[l.cancelar_jogo, l.fechar_jogo],[l.categorias_btn], [l.comandos]]) #Pre-game admin else: kb.append([[l.novojogo], [l.ajuda, l.rank], [l.config, l.sobre], [l.desligar]]) #Main else: kb.append([[l.ligar]]) #Off elif k == 'cmd': if bds.getInGame(chat_id): kb.append([[l.ajuda, l.rank], [l.config], [l.voltar], [l.desligar]]) kb.append([[l.cancelar_jogo], [l.ajuda, l.rank], [l.config, l.voltar], [l.desligar]]) elif bds.getPreGame(chat_id): kb.append([[l.ajuda, l.rank], [l.config, l.voltar], [l.desligar]]) elif k == 'config': kb.append([['Português(BR)' + emoji_br, 'English(US)' + emoji_usa, 'עברית (ישראל)' + emoji_hb], [l.ajuda], [l.voltar]]) elif k == 'fora': kb.append([[l.esta_fora]]) elif k == 'first': kb.append([['Português(BR)' + emoji_br, 'English(US)' + emoji_usa, 'עברית (ישראל)' + emoji_hb]]) if (len(kb) == 0): kb = [[l.att_kb]] return kb
def getPlayers(chat_id): return bds.getPlayers(chat_id)