def state_call_metodo(user, message): data = get_user_var_value(user, 'DATA', None) ora = get_user_var_value(user, 'ORA_INIZIO', None) oraFine = get_user_var_value(user, 'ORA_FINE', None) dati = asd.ritorna_date(data, ora, oraFine) send_message(user, dati) if len(dati) > 0: direct_user_to_state(user, 'input_scelto') set_user_var_value(user, 'VETTORE_DATI', dati) else: send_message(user, "DATI NON PRESENTI ")
def state_registrazione_nome(user, message): bot_turn = message is None if bot_turn: reply_text = 'Inserisci il tuo Nome e Cognome :' send_message(user, reply_text) else: if message.text: input_text = message.text set_user_var_value(user, 'NOMECOGNOME', input_text) direct_user_to_state(user, 'registrazione_email') else: reply_text = 'Input non riconosciuto, usa la tastiera.' send_message(user, reply_text)
def state_input_scelto(user, message): bot_turn = message is None if bot_turn: reply_text = "Inserisci il numero della struttura che vuoi prenotare:" send_message(user, reply_text) else: if message.text: input_text = int(message.text) set_user_var_value(user, 'POS_SELEZ', input_text) direct_user_to_state(user, 'conferma_input') else: reply_text = 'Input non riconosciuto, usa la tastiera.' send_message(user, reply_text)
def state_prendi_secondo_indice(user, message): bot_turn = message is None if bot_turn: reply_text = "Inserisci indice per la stanza desiderata:" send_message(user, reply_text) else: if message.text: input_text = message.text set_user_var_value(user, 'DATA_INDICE_DUE', input_text) else: reply_text = 'Input non riconosciuto, usa la tastiera.' send_message(user, reply_text)
def state_evento_scelto(user, message): bot_turn = message is None if bot_turn: reply_text = "Che tipo di evento vuoi organizzare? (es. festa privata, assemblea, attività sportiva...)" send_message(user, reply_text) else: if message.text: input_text = message.text set_user_var_value(user, 'TIPO_EVENTO_SCELTO', input_text) direct_user_to_state(user, 'tipo_struttura') else: reply_text = 'Input non riconosciuto, usa la tastiera.' send_message(user, reply_text)
def state_dati_ruolo(user, message): bot_turn = message is None if bot_turn: reply_text = "Inserisci il tuo ruolo : " send_message(user, reply_text) else: if message.text: input_text = message.text set_user_var_value(user, 'RUOLO', input_text) direct_user_to_state(user, 'autorizzazione_dati') else: reply_text = 'Input non riconosciuto, usa la tastiera.' send_message(user, reply_text)
def state_dati_associazione(user, message): bot_turn = message is None if bot_turn: reply_text = "Inserisci il nome dell'associazione : " send_message(user, reply_text) else: if message.text: input_text = message.text set_user_var_value(user, 'NOME_ASSOCIAZIONE', input_text) direct_user_to_state(user, 'dati_ruolo') else: reply_text = 'Input non riconosciuto, usa la tastiera.' send_message(user, reply_text)
def state_registrazione_codice_fiscale(user, message): bot_turn = message is None if bot_turn: reply_text = 'Inserisci il tuo codice fiscale :' send_message(user, reply_text) else: if message.text: input_text = message.text bot_manager.set_user_var_value(user, 'CODF', input_text) set_user_var_value(user, "REGISTRATO", True) direct_user_to_state(user, '0') else: reply_text = 'Input non riconosciuto, usa la tastiera.' send_message(user, reply_text)
def state_ora_fine(user, message): bot_turn = message is None if bot_turn: reply_text = "Inserisci ora di fine [00:00]" send_message(user, reply_text) else: if message.text: input_text = message.text if controllo_ora(user, input_text): set_user_var_value(user, 'ORA_FINE', input_text) direct_user_to_state(user, 'call_metodo') else: direct_user_to_state(user, 'ora_fine') else: reply_text = 'Input non riconosciuto, usa la tastiera.' send_message(user, reply_text)
def state_data(user, message): bot_turn = message is None if bot_turn: reply_text = "Inserisci data [gg-mm-aaaa]" send_message(user, reply_text) else: if message.text: input_text = message.text if controllo_data(user, input_text): set_user_var_value(user, 'DATA', input_text) direct_user_to_state(user, 'ora_inizio') else: direct_user_to_state(user, 'data') else: reply_text = 'Input non riconosciuto, usa la tastiera.' send_message(user, reply_text)
def state_prendi_seconda_data(user, message): bot_turn = message is None if bot_turn: reply_text = "Inserisci data per selezionare la stanza [gg-mm-aaaa]" send_message(user, reply_text) else: if message.text: input_text = message.text if controllo_data(user, input_text): set_user_var_value(user, 'DATA_NUMERO_DUE', input_text) direct_user_to_state(user, 'prendi_secondo_indice') else: direct_user_to_state(user, 'prendi_seconda_data') else: reply_text = 'Input non riconosciuto, usa la tastiera.' send_message(user, reply_text)
def state_lista_strutture_ORE(user, message): bot_turn = message is None if bot_turn: reply_text = "Inserisci ora iniziale per la ricerca [00:00]" send_message(user, reply_text) else: if message.text: input_text = message.text if controllo_ora(user, input_text): set_user_var_value(user, 'DATA_RICERCA_STRUTTURA', input_text) direct_user_to_state(user, 'lista_strutture_ORE_finale') else: direct_user_to_state(user, 'lista_strutture_ORE') else: reply_text = 'Input non riconosciuto, usa la tastiera.' send_message(user, reply_text)
def state_registrazione_email(user, message): bot_turn = message is None if bot_turn: reply_text = 'Inserisci la tua email :' send_message(user, reply_text) else: if message.text: input_text = message.text if validateEmail(input_text): bot_manager.set_user_var_value(user, 'EMAIL', input_text) direct_user_to_state(user, 'registrazione_codice_fiscale') else: reply_text = "Indirizzo email non valido!" send_message(user, reply_text) else: reply_text = 'Input non riconosciuto, usa la tastiera.' send_message(user, reply_text)
def state_preferiti(user, message): bot_turn = message is None if bot_turn: ricette_preferite = get_user_var_value(user, 'RICETTE_PREFERITE') if ricette_preferite: ricette_trovate = [] for r_id in ricette_preferite: r = get_ricetta(r_id) ricette_trovate.append('• /ricetta{} {}'.format( r['RecipeID'], r['Title'])) ricette_trovate_str = '\n'.join(ricette_trovate) reply_text = "Ricette preferite:\n\n{}\n\nPremi su una ricetta per visualizzarla.".format( ricette_trovate_str) keyboard = [['🗑 Reset preferiti'], ['🔙 Indietro']] else: reply_text = 'Nessuna ricetta preferita trovata' keyboard = [['🔙 Indietro']] send_message(user, reply_text, keyboard) else: if message.text: input_text = message.text if input_text == '🔙 Indietro': direct_user_to_state(user, '0') elif input_text == '🗑 Reset preferiti': set_user_var_value(user, 'RICETTE_PREFERITE', []) reply_text = "Ricette preferite eliminate." send_message(user, reply_text) direct_user_to_state(user, '0') elif input_text.startswith('/aggiungiRicettaInPreferiti'): ricetta_id = input_text.split('/aggiungiRicettaInPreferiti')[1] aggiungi_ricetta_in_preferiti(user, ricetta_id) repeatState(user) elif input_text.startswith('/rimuoviRicettaDaPreferiti'): ricetta_id = input_text.split('/rimuoviRicettaDaPreferiti')[1] rimuovi_ricetta_da_preferiti(user, ricetta_id) repeatState(user) elif input_text.startswith('/ricetta'): ricetta_id = input_text.split('/ricetta')[1] send_ricetta(user, ricetta_id) else: reply_text = 'Input non riconosciuto, usa la tastiera.' send_message(user, reply_text) else: reply_text = 'Input non riconosciuto, usa la tastiera.' send_message(user, reply_text)