def ValidateMsg(msg): response = {"r": {"a": None, "at": com.AnswerType.TEXT}, "needWait": False} chat_id = msg["chat"]["id"] author = msg["from"]["id"] answerType = -1 if "text" in msg: answer = msg["text"] if answer.startswith("/cancel"): del WaitingAnswer[chat_id][author] return dao.GetAnswer(dao.CANCEL) elif answer.startswith("/"): response["r"]["a"] = "Eso es un comando, no una respuesta" return response answerType = com.AnswerType.TEXT elif "sticker" in msg: answer = msg["sticker"]['file_id'] answerType = com.AnswerType.STICKER elif "animation" in msg: answer = msg["animation"]['file_id'] answerType = com.AnswerType.GIF if answerType == -1: del WaitingAnswer[chat_id][author] response["r"] = { "a": u'CAADAQAD7wEAAs8UpQABdurS64LRGooC', "at": com.AnswerType.STICKER } return response return AddCustomAnswer(chat_id, author, answerType, answer)
def resetData(user, userSender, chat_id, msg): response = { "r": { "a": None, "at": AnswerType.TEXT }, "needWait": COMMANDS["/reset"][WAIT] } response["r"] = dao.GetAnswer(dao.RESET) return response
def checkWaitingAnswer(msg): chat_id = msg['chat']['id'] user_id = msg["from"]['id'] if not isWaitingAnswer(chat_id, user_id): return False answer = "" answerType = -1 if "text" in msg: answer = msg["text"] if answer.startswith("/cancel"): del answerTransactions[chat_id][user_id] response = dao.GetAnswer(dao.CANCEL) manageResponse(msg, response) return True elif answer.startswith("/"): reply(msg, "Eso es un comando, no una respuesta", False) return True answerType = com.AnswerType.TEXT elif "sticker" in msg: answer = msg["sticker"]['file_id'] answerType = com.AnswerType.STICKER elif "animation" in msg: answer = msg["animation"]['file_id'] answerType = com.AnswerType.GIF if answerType == -1: del answerTransactions[chat_id][user_id] replySticker(msg, dejesedemamadas) reply( msg, "Solo texto, sticker o gif. Ahora por vivo, tienes que volver a empezar", False) return True answerObj = { "t": answerTransactions[chat_id][user_id], "a": answer, "at": answerType } dao.InsertProposal(answerObj) reply( msg, "Listo, la propuesta para respuesta ha sido almacenada!. Usa el comando /voteanswer para votar por las respuestas mas originales." ) del answerTransactions[chat_id][user_id] return True
def cancel(user, userSender, chat_id, msg): response = { "r": { "a": None, "at": AnswerType.TEXT }, "needWait": COMMANDS["/cancel"][WAIT] } if not chat_id in ticketWait: response["r"]["a"] = "que vas a cancelar, no tienes nada" return response del ticketWait[chat_id] response["r"] = dao.GetAnswer(dao.CANCEL) return response
def goToHeaven(user, userSender, chat_id, msg): response = { "r": { "a": None, "at": AnswerType.TEXT }, "needWait": COMMANDS["/heaven"][WAIT] } if user.upper() == userSender.upper(): response["r"]["a"] = u'solo dios puede juzgarte... nah!, los demas lo haran \U0001f602' return response if user == '': response["r"] = getMsgLeeMan() response["needWait"] = False return response if user != "test": dao.Update(user, dao.HEAVEN) response["r"] = dao.GetAnswer(dao.HEAVEN) return response
def getAwnser(type): return dao.GetAnswer(type)
def stop(user, userSender, chat_id, msg): return { "r": dao.GetAnswer(dao.STOP), "needWait": COMMANDS["/stop"][WAIT] }