Exemplo n.º 1
0
def dealWithTokensSelection(p, token_index=None):
    # coming here form 30/31 (via add) or 40 (via /number)
    sentence_word_tokens, sentence_tokens = sentAnno.getCurrentSentenceWordTokensSentenceTokens(
        p)
    #logging.debug('token_index: ' + str(token_index))
    if token_index != None:
        p.selectedTokens[token_index] = not p.selectedTokens[token_index]
    text_msg = renderSentenceWithMweHighlights(p, sentence_word_tokens,
                                               p.selectedTokens,
                                               person.getMarkdownChar(p))
    if sum(p.selectedTokens) < 2:
        text_msg += "\n\n" + "Please select at least 2 tokens you want to include in the MWE."
    kb = segmentTokenButtons(p, sentence_tokens, p.selectedTokens,
                             p.maxCharsPerLine)
    logging.debug('in dealWithTokensSelection state: ' + str(p.state))
    if sum(p.selectedTokens) > 1:
        logging.debug('person.getSelectedTokensIndexTuple(p): ' +
                      str(person.getSelectedTokensIndexTuple(p)))
        logging.debug('p.currentMweTmp: ' + str(p.currentMweTmp))
        if p.currentMweTmp:
            if person.getSelectedTokensIndexTuple(p) != tuple(p.currentMweTmp):
                #via /number press
                kb.append([CONFIRM_CHANNGES])
        else:
            # via + add
            kb.append([CHOOSE_CAT_BUTTON])

    kb.append([BACK_BUTTON])
    tell(p.chat_id, text_msg, kb=kb, markdown=True)
    person.setState(p, 30)
Exemplo n.º 2
0
def restart(p, msg=None):
    reply_txt = msg + "\n" if msg else ''
    reply_txt += "Initial Screen." + '\n\n' + "Choose a language to ANNOTATE, change your SETTINGS or ask for HELP."
    tell(p.chat_id,
         reply_txt,
         kb=[[ANNOTATE_BUTTON_IR, ANNOTATE_BUTTON_EN],
             [SETTINGS_BUTTON, INFO_BUTTON], [HELP_BUTTON]])
    person.setState(p, 0)
Exemplo n.º 3
0
def prepareToSelectTokens(p):
    text_msg = renderSentence(p, False)
    sentence_tokens = sentAnno.getCurrentSentenceTokens(p)
    p.selectedTokens = [False] * len(sentence_tokens)
    kb = segmentTokenButtons(p, sentence_tokens, p.selectedTokens,
                             p.maxCharsPerLine)
    kb.append([BACK_BUTTON])
    tell(p.chat_id, text_msg, kb=kb)
    person.setState(p, 30)
Exemplo n.º 4
0
def askConfidenceLevel(p):
    indexes = person.getSelectedTokensIndexTuple(p)
    sentAnno.getCategoryAndConfidence(p, indexes)
    mwe_flat = renderMwe(p, indexes, True, True)
    text_msg = "You have selected the following MWE:\n" + mwe_flat + "\n\n"
    text_msg += "Which NEW confidence level do you want to assign to it? Please enter a number between 1 and 10"
    kb = util.makeArray2D(NUMBERS_0_10[1:], 5)
    kb.append([BACK_BUTTON])
    tell(p.chat_id, text_msg, kb, markdown=True)
    person.setState(p, 70)
Exemplo n.º 5
0
def restart(p, txt=None):
    reply_txt = (txt + '\n\n') if txt != None else ''
    reply_txt += "Premi su *{0}* o *{1}* se vuoi ascoltare o registrare una frase in un dialetto.".format(
        BOTTONE_ASCOLTA, BOTTONE_REGISTRA)
    second_row_buttons = [BOTTONE_INFO]
    if p.isAdmin():
        second_row_buttons.append(BOTTONE_ADMIN)
    send_message(p.chat_id,
                 reply_txt,
                 kb=[[BOTTONE_ASCOLTA, BOTTONE_REGISTRA], second_row_buttons])
    person.setState(p, -1)
Exemplo n.º 6
0
def goToSettingsHighlightingMode(p):
    text_msg = "Your current highlighting mode is set to: " + \
               person.getHighlightedString(p, p.highlightingMode) + "\n" + "The options are: \n\n"
    options = person.MARKDOWN_OPTIONS.keys()
    for mode in options:
        markdownChar = person.MARKDOWN_OPTIONS[mode]
        text_msg += "   " + mode + ": " + markdownChar + "sample text" + markdownChar + "\n"
    text_msg += "\nSelect an highlighting mode."
    logging.debug('dealWithSettingHighlightingMode: ' + text_msg)
    kb = [options, [BACK_BUTTON]]
    tell(p.chat_id, text_msg, kb=kb, markdown=True)
    person.setState(p, -11)
Exemplo n.º 7
0
def askWhichAnnotationToRemove(p):
    currentMwes = p.selectedMwes
    size = len(currentMwes)
    if size == 1:
        dealWithRemoveMwe(p, 1)
        #state 1
    else:
        text_msg = renderSentenceWithMwesList(p, False)
        text_msg += "\n\n" + "Which MWE do you want to remove? " \
                           "Enter the corresponding index between 1 and " + str(size) + "."
        numberArray = [str(x + 1) for x in range(0, size)]
        kb = util.distributeElementMaxSize(numberArray, 5)
        kb.append([BACK_BUTTON])
        #logging.debug("keyboard: " + str(kb) )
        tell(p.chat_id, text_msg, kb=kb, markdown=True)
        person.setState(p, 60)
Exemplo n.º 8
0
def askAnnotationLabel(p):
    indexes = person.getSelectedTokensIndexTuple(p)
    logging.debug("in askAnnotationLabel. last state: " + str(p.last_state))
    changeCategory = p.state == 40
    mwe_flat = renderMwe(p, indexes, changeCategory, False)
    text_msg = renderSentence(p) + "\n\n"
    text_msg += "You have selected the following MWE:\n" + mwe_flat + "\n\n"
    if changeCategory:
        text_msg += "which NEW category do you want to assign to it?"
    else:
        text_msg += "which category do you want to assign to it?"
    kb = util.segmentArrayOnMaxChars(categories.ANNOTATION_CATS,
                                     p.maxCharsPerLine)
    #kb = categories.ANNOTATION_CATS_SPLIT_ON_CHAR #sentences.ANNOTATION_CATS_3PL
    kb.append([BACK_BUTTON])
    tell(p.chat_id, text_msg, kb=kb, markdown=True)
    person.setState(p, 31)
Exemplo n.º 9
0
def goToSettingsButtonsDensity(p):
    text_msg = "Your current button density is set to: " + person.getHighlightedString(p,str(p.maxCharsPerLine)) + \
               " characters per line. Press on " + BACK_BUTTON +\
               'if you are happy with this choice, otherwise enter a new value between ' + \
               person.getHighlightedString(p, str(MIN_CHARS_PER_LINE)) + ' and ' +\
               person.getHighlightedString(p, str(MAX_CHARS_PER_LINE)) + '.\n\n' +\
               "The buttons below will show you how the density changes according to the value.\n\n"
    sampleSentence = "This is  a sample sentence to show you how the buttons density changes according to your settings"
    sentenceButtons = util.splitTextOnSpaces(sampleSentence)
    sentenceButtonsArrangement = util.segmentArrayOnMaxChars(
        sentenceButtons,
        p.maxCharsPerLine,
    )
    kb = sentenceButtonsArrangement
    kb.insert(0, [BACK_BUTTON])
    tell(p.chat_id, text_msg, kb, markdown=True)
    person.setState(p, -12)
Exemplo n.º 10
0
def dealWithPlaceAndMicInstructions(p):
    lat, lon = p.location.lat, p.location.lon
    luogo = geoUtils.getComuneProvinciaFromCoordinates(lat, lon)
    if luogo == None:
        send_message(p.chat_id,
                     "Il luogo inserito non è stato riconosciuto, riprova.")
        send_message(
            key.FEDE_CHAT_ID,
            "A user inserted a unrecognized location: {},{}".format(lat, lon))
        send_location(key.FEDE_CHAT_ID, lat, lon)
    else:
        luogo = '*{}*'.format(luogo)
        instructions = PLACE_INSTRUCTIONS.format(luogo) + MIC_INSTRUCTIONS
        send_message(p.chat_id,
                     instructions,
                     kb=[[BOTTONE_CAMBIA_LUOGO], [BOTTONE_INDIETRO]])
        person.setState(p, 20)
Exemplo n.º 11
0
def jumpToModifySingleMwe(p, mwe_number):
    if mwe_number < 0 or mwe_number > len(p.selectedMwes):
        tell(p.chat_id, EXCLAMATION + " Not a valid MWE index.")
        return
    #logging.log("in jumpToModifySingleMwe: " + str(p.selectedMwes))
    mwe_indexes = sorted(p.selectedMwes)[mwe_number - 1]
    person.setSelectedTokenFromIndexList(p, mwe_indexes)
    mwe_flat = renderMwe(p, mwe_indexes, True, True)
    text_msg = renderSentence(p) + "\n\n"
    text_msg += "You have selected the following MWE:\n" + mwe_flat + \
                "\n\n" + "How do you want to modify it?"
    first_line_kb = [CHANGE_CAT_BUTTON, REMOVE_BUTTON]
    second_line_kb = [CHANGE_MWE_ELEMENTS]
    if sentAnno.CONFIDENCE_ACTIVE:
        second_line_kb.append(CHANGE_MWE_CONFIDENCE)
    kb = [first_line_kb, second_line_kb, [BACK_BUTTON]]
    tell(p.chat_id, text_msg, kb=kb, markdown=True)
    person.setState(p, 40)
Exemplo n.º 12
0
def displayCurrentSentence(p):
    text_msg = renderSentenceWithMwesList(p)

    if p.selectedMwes == None:
        firstButtonLine = [ADD_MWE_BUTTON, NO_MWE_BUTTON]
    elif p.selectedMwes:
        firstButtonLine = [ADD_MWE_BUTTON, MOD_MWE_BUTTON, REMOVE_MWE_BUTTON]
    else:
        firstButtonLine = [ADD_MWE_BUTTON]

    kb = [
        firstButtonLine, [PREV_BUTTON, GO_TO_BUTTON, NEXT_BUTTON],
        [BACK_BUTTON]
    ]

    #logging.debug("again in displayCurrentSentence:text_msg: " + text_msg)
    #logging.debug("again in displayCurrentSentence:kb: " + str(kb))
    tell(p.chat_id, text_msg, kb=kb, markdown=True)
    p.currentMweTmp = []  # reset current mwe var
    person.setState(p, 1)
Exemplo n.º 13
0
def dealWithRandomRecording(p):
    randomRecording = recording.getRandomRecording()
    if not randomRecording:
        send_message(
            p.chat_id,
            "Scusa, non abbiamo altre registrazioni disponibili, chidi ai tuoi amici di inserirne altre",
            kb=[[BOTTONE_ANNULLA]])
        restart(p)
    else:
        send_message(
            p.chat_id,
            "Ascolta l'audio seguente e prova ad indovinare da dove proviene 😀"
        )
        send_voice(p.chat_id, randomRecording)
        person.setLastRecording(p, randomRecording)
        logging.debug("Last recording id: " + str(p.last_recording_file_id))
        send_message(p.chat_id,
                     ISTRUZIONI_POSIZIONE_GUESS,
                     kb=[["ASCOLTA NUOVA REGISTRAZIONE"], [BOTTONE_INDIETRO]])
        person.setState(p, 31)
Exemplo n.º 14
0
def goToSetting(p):
    text_msg = "You are in the settings pane. Plase click in one of the buton to adjust the parameters."
    kb = [[HIGHTLIGHTING_MODE_BUTTON], [BUTTONS_DENSITY_BUTTON], [BACK_BUTTON]]
    tell(p.chat_id, text_msg, kb=kb)
    person.setState(p, -1)
Exemplo n.º 15
0
    def post(self):
        body = jsonUtil.json_loads_byteified(self.request.body)
        logging.info('request body:')
        logging.info(body)
        self.response.write(json.dumps(body))

        # update_id = body['update_id']
        if 'message' not in body:
            return
        message = body['message']
        #message_id = message.get('message_id')
        # date = message.get('date')
        if "chat" not in message:
            return
        # fr = message.get('from')
        chat = message['chat']
        chat_id = chat['id']
        if "first_name" not in chat:
            return
        text = message.get('text', "")
        name = chat["first_name"]
        last_name = chat.get("last_name", "-")
        username = chat.get("username", "-")
        location = message.get("location", None)
        voice = message.get("voice", None)
        #audio = message.get("audio", None)
        #document = message.get("document", None)

        logging.debug("Received input from {}. Text={} Location={}".format(
            chat_id, text, location))

        def reply(msg=None, kb=None, markdown=True, inline_keyboard=False):
            send_message(chat_id,
                         msg,
                         kb=kb,
                         markdown=markdown,
                         inline_keyboard=inline_keyboard)

        p = person.getPersonByChatId(chat_id)

        if p is None:
            # new user
            logging.info("Text: " + text)
            if text == '/help':
                reply(ISTRUZIONI)
            if text.startswith("/start"):
                p = person.addPerson(chat_id, name)
                reply("Ciao " + p.getFirstName() + ", " + "benvenuta/o!")
                init_user(p, name, last_name, username)
                restart(p)
                # state = -1 or -2
                tell_masters("New user: "******"Premi su /start se vuoi iniziare. "
                    "Se hai qualche domanda o suggerimento non esitare di contattarmi cliccando su @kercos"
                )
        else:
            # known user
            person.updateUsername(p, username)
            if text.startswith("/start"):
                reply("Ciao " + p.getFirstName() + ", " + "ben ritrovata/o!")
                init_user(p, name, last_name, username)
                restart(p)
                # state = -1 or -2
            elif text == '/state':
                if p.state in STATES:
                    reply("You are in state " + str(p.state) + ": " +
                          STATES[p.state])
                else:
                    reply("You are in state " + str(p.state))
            elif WORK_IN_PROGRESS and not p.isAdmin():
                reply(UNDER_CONSTRUCTION +
                      " Il sistema è in aggiornamento, riprova più tardi.")
            elif text.startswith('/rec_'):
                send_voiceLocationTranslationFromCommand(p,
                                                         text,
                                                         userInfo=p.isAdmin())
            elif text.startswith('/sendText') and p.isAdmin():
                dealWithsendTextCommand(p, text, markdown=False)
            elif p.state == -1:
                # INITIAL STATE
                if text in ['/help', BOTTONE_INFO]:
                    redirectToState(p, 8)
                elif text == BOTTONE_REGISTRA:
                    if p.location:
                        dealWithPlaceAndMicInstructions(p)
                    else:
                        reply(
                            "Questa è la tua prima registrazione: "
                            "è necessario che tu inserisca il luogo del dialetto che vuoi registrare.\n"
                            + ISTRUZIONI_POSIZIONE,
                            kb=[[BOTTONE_ANNULLA]])
                        person.setState(p, -2)
                elif text == BOTTONE_ASCOLTA:
                    goToAscolta(p)
                    # state 30
                elif p.isAdmin():
                    if text == BOTTONE_ADMIN:
                        redirectToState(p, 9)
                    elif text == '/test':
                        reply('test')
                        #reply(geoUtils.getLocationTest())
                        #taskqueue.add(url='/worker', params={'key': key})
                        #geoUtils.test_Google_Map_Api()
                    elif text == '/infoCounts':
                        c = person.getPeopleCount()
                        reply("Number of users: " + str(c))
                    elif text == '/restartUsers':
                        text = "Nuova interfaccia e nuove funzionalità :)\n" \
                               "Ora puoi inserire le località digitando il nome del posto (e.g, Perugia).\n" \
                               "Inoltre puoi cercare registrazioni in prossimità di un luogo.\n" \
                               "Buon ascolto e buona registrazione!"
                        deferred.defer(restartAllUsers,
                                       text)  #'New interface :)')
                        #deferred.defer(restartTest, text) #'New interface :)')
                        logging.debug('restarted users')
                    elif text == '/importVivaldi':
                        #logging.debug('nothing')
                        recording.importVivaldi()
                    elif text == '/countVivaldi':
                        c = recording.countVivaldi()
                        reply('Vivaldi recs: ' + str(c))
                    elif text == '/deleteVivaldi':
                        recording.deleteVivaldi()
                        reply('Deleted Vivaldi recs.')
                    elif text == '/remFormatVoice':
                        c = recording.removeFormatVoice()
                        reply("removed rec format voice: " + str(c))
                    elif text == '/stats':
                        msg = recording.getRecodingsStats()
                        send_message(p.chat_id, msg, markdown=False)
                        msg = "People count: {}".format(
                            person.getPeopleCount())
                        send_message(p.chat_id, msg, markdown=False)
                    elif text.startswith('/echo ') and len(text) > 6:
                        msg = text[6:]
                        reply(msg)
                    elif text.startswith('/broadcast ') and len(text) > 11:
                        msg = text[11:]
                        deferred.defer(broadcast,
                                       p.chat_id,
                                       msg,
                                       restart_user=False)
                    elif text.startswith(
                            '/restartBroadcast ') and len(text) > 18:
                        msg = text[18:]
                        deferred.defer(broadcast,
                                       p.chat_id,
                                       msg,
                                       restart_user=True)
                    elif text.startswith('/self ') and len(text) > 6:
                        msg = text[6:]
                        reply(msg)
                    elif text == '/lastContributors':
                        count, namesString, recCommandsString = getLastContibutors(
                            300)
                        msg = "Contributors: " + str(
                            count) + "\nNames: " + namesString
                        reply(msg)
                    elif text == '/testMonthlyMessage':
                        msg = getMonthlyMessage()
                        reply(msg)
                    else:
                        reply('Scusa, capisco solo /help /start '
                              'e altri comandi segreti...')
                    #setLanguage(d.language)
                else:
                    reply(
                        "Scusa non capisco quello che hai detto.\n"
                        "Usa i pulsanti sotto o premi {} per avere informazioni."
                        .format(BOTTONE_INFO))
            elif p.state == -2:
                # POSIZIONE
                if text == BOTTONE_ANNULLA:
                    restart(p, "Operazione annullata.")
                elif location != None:
                    logging.debug('User sending location: {}, {}'.format(
                        location['latitude'], location['longitude']))
                    luogo = geoUtils.getComuneProvinciaFromCoordinates(
                        location['latitude'], location['longitude'])
                    logging.debug('Detected luogo: {}'.format(luogo))
                    if luogo:
                        person.setLocation(p, location['latitude'],
                                           location['longitude'])
                        dealWithPlaceAndMicInstructions(p)
                    else:
                        reply(
                            "Non conosco la località inserita, prova ad essere più precisa/o.\n"
                            + ISTRUZIONI_POSIZIONE,
                            kb=[[BOTTONE_INVIA_LOCATION], [BOTTONE_ANNULLA]])
                        logging.debug(
                            'Problem finding comune and provincia from coordinates {} {}'
                            .format(location['latitude'],
                                    location['longitude']))
                    #state 20
                elif text.startswith('('):
                    text_split = text[1:-1].split(",")
                    latitude = float(text_split[0])
                    longitude = float(text_split[1])
                    person.setLocation(p, latitude, longitude)
                    send_location(p.chat_id, latitude, longitude)
                    dealWithPlaceAndMicInstructions(p)
                    #state 20
                else:
                    place = geoUtils.getLocationFromName(text)
                    if place:
                        person.setLocation(p, place.latitude, place.longitude)
                        dealWithPlaceAndMicInstructions(p)
                        #state 20
                    else:
                        reply(
                            "Non conosco la località inserita, prova ad essere più precisa/o.\n"
                            + ISTRUZIONI_POSIZIONE,
                            kb=[[BOTTONE_INVIA_LOCATION], [BOTTONE_ANNULLA]])
            elif p.state == 20:
                # REGISTRA
                if text == BOTTONE_INDIETRO:
                    restart(p, "Operazione annullata.")
                    # state = -1
                elif text == BOTTONE_CAMBIA_LUOGO:
                    reply("Ok, cambiamo il luogo.\n" + ISTRUZIONI_POSIZIONE,
                          kb=[[BOTTONE_INVIA_LOCATION], [BOTTONE_ANNULLA]])
                    person.setState(p, -2)
                    # state -2
                elif voice != None:
                    reply(
                        "Bene! 😉\n"
                        "Ora riascolta la registrazione e conferma su ✅ OK "
                        "se la registrazione è ben riuscita o premi su 🎙 REGISTRA DI NUOVO per"
                        "effettuare un'altra registrazione.",
                        kb=[['✅ OK'], ['🎙 REGISTRA DI NUOVO'],
                            [BOTTONE_ANNULLA]])
                    file_id = voice['file_id']
                    #send_voice(p.chat_id, file_id)
                    rec = recording.addRecording(p, file_id)
                    person.setLastRecording(p, rec)
                    person.setState(p, 21)
                else:
                    reply(
                        FROWNING_FACE +
                        " Scusa non capisco quello che hai detto, devi inserire la registrazione tenendo premuto il microfono."
                    )
            elif p.state == 21:
                # CONFIRM RECORDING
                if text == BOTTONE_ANNULLA:
                    person.removeLastRecording(p)
                    restart(p, "Operazione annullata.")
                    # state = -1
                elif text == '✅ OK':
                    msg = utility.unindent('''
                        Riteniamo utile avere una traduzione in italiano delle registrazione \
                        in modo da essere comprensibili da tutti gli utenti.\n
                        *Scrivi qua sotto* la traduzione della registrazione \
                        (in aggiunta puoi inserire la trascrizione in dialetto e il significato in caso si tratti di un proverbio)
                        ''')
                    reply(msg, kb=[['Salta Traduzione']])
                    person.setState(p, 22)
                elif text == '🎙 REGISTRA DI NUOVO':
                    person.removeLastRecording(p)
                    reply(MIC_INSTRUCTIONS,
                          kb=[[BOTTONE_CAMBIA_LUOGO], [BOTTONE_ANNULLA]])
                    person.setState(p, 20)
                else:
                    reply(
                        FROWNING_FACE +
                        "Scusa non capisco quello che hai detto, premi *OK* per confermare la registrazione."
                    )
            elif p.state == 22:
                # CHECK IF AVAILABLE FOR TRANSLATION
                if text == 'Salta Traduzione':
                    msg = "👍😀 Grazie per il tuo contributo!\n" \
                          "La registrazione è in attesa di approvazione, riceverai un messaggio a breve."
                    reply(msg)
                    sendNewRecordingNotice(p)
                    restart(p)
                elif text == '':
                    msg = "Input non valido. *Scrivi* qua sotto la traduzione in italiano della registrazione"
                    reply(msg, kb=[['Salta Traduzione']])
                    return
                else:
                    recording.addTranslation(p.last_recording_file_id, text)
                    msg = "👍😀 Grazie per il tuo contributo!\n" \
                          "La registrazione è in attesa di approvazione, riceverai un messaggio a breve."
                    reply(msg)
                    sendNewRecordingNotice(p)
                    restart(p)
            elif p.state == 30:
                if text == BOTTONE_INDIETRO:
                    restart(p)
                    # state = -1
                elif text == BOTTONE_INDOVINA_LUOGO:
                    dealWithRandomRecording(p)
                    # state 31
                elif text == BOTTONE_CERCA_LUOGO:
                    reply(ISTRUZIONI_POSIZIONE_SEARCH, kb=[[BOTTONE_INDIETRO]])
                    person.setState(p, 32)
                    # state 32
                elif text == BOTTONE_RECENTI:
                    getRecentRecordings(p)
                    person.setState(p, 33)
                    # state 33
                elif text == BOTTONE_TUTTE:
                    getAllRecordings(p)
                    person.setState(p, 33)
                    # state 33
                else:
                    msg = "Input non valido. Usa i pulsanti qua sotto."
                    reply(msg)
                    return
            elif p.state == 31:
                # ASCOLTA - INDOVINA LUOGO
                if text in [BOTTONE_INDIETRO, BOTTONE_ANNULLA]:
                    restart(p)
                    # state = -1
                elif text == "ASCOLTA NUOVA REGISTRAZIONE":
                    dealWithRandomRecording(p)
                    # state 31
                elif location != None:
                    dealWithGuessedLocation(p, location)
                else:
                    place = geoUtils.getLocationFromName(text)
                    if place:
                        guessed_loc = {
                            'latitude': place.latitude,
                            'longitude': place.longitude
                        }
                        dealWithGuessedLocation(p, guessed_loc)
                    else:
                        reply(
                            "Non conosco la località inserita, prova ad essere più precisa/o.\n"
                            + ISTRUZIONI_POSIZIONE_GUESS,
                            kb=[[BOTTONE_ANNULLA]])
            elif p.state == 32:
                #ASCOLTA - RICERCA LUOGO
                sendWaitingAction(p.chat_id)
                if location != None:
                    dealWithFindClosestRecording(p, location)
                elif text == BOTTONE_INDIETRO:
                    restart(p)
                else:
                    place = geoUtils.getLocationFromName(text)
                    if place:
                        loc = {
                            'latitude': place.latitude,
                            'longitude': place.longitude
                        }
                        dealWithFindClosestRecording(p, loc)
                    else:
                        reply(
                            "Non conosco la località inserita, prova ad essere più precisa/o.\n"
                            + ISTRUZIONI_POSIZIONE_SEARCH,
                            kb=[[BOTTONE_INDIETRO]])
            elif p.state == 33:
                # REGISTRAZIONI RECENTI
                if text == BOTTONE_INDIETRO:
                    goToAscolta(p)
                else:
                    reply(FROWNING_FACE +
                          "Scusa non capisco quello che hai detto.")
            else:
                logging.debug("Sending {0} to state {1}".format(
                    p.getFirstName(), str(p.state)))
                repeatState(p, input=text)
Exemplo n.º 16
0
def goToAscolta(p):
    send_message(p.chat_id,
                 ASCOLTA_MSG,
                 kb=[[BOTTONE_INDOVINA_LUOGO, BOTTONE_CERCA_LUOGO],
                     [BOTTONE_RECENTI], [BOTTONE_INDIETRO]])
    person.setState(p, 30)