def run(self, dispatcher, tracker, domain): print("\nEjecutando acción:\t{}".format( colored(self.name(), 'yellow', attrs=['bold']))) print("Representación de los slots:") color_print_slots(tracker) subject_acro = tracker.get_slot("subject_acronym").upper() chat_id = tracker.sender_id user_lang = Chats().get_chat_lite(chat_id)['language'] teachers_info = API_raco().get_subject_teachers(acronym=subject_acro, language=user_lang) teachers_info = Subject_teachers(subject_acro, teachers_info, user_lang) if teachers_info.amount <= 4: for response in teachers_info.get_offices(): dispatcher.utter_message("{}".format(response)) else: answers = { 'ca': "Aquests són els professors de {}. Qui t'interessa?!\n", 'es': 'Éstos son los profesores de {}. ¿Quién te interesa?\n', 'en': "These are {}'s teachers. Who are you interested in?\n" } answer = answers[user_lang].format(subject_acro) for teacher in teachers_info.get_names(): answer = answer + teacher + '\n' dispatcher.utter_message("{}".format(answer)) return [SlotSet("matches", True)] return [SlotSet("matches", False)]
def run(self, dispatcher, tracker, domain): print("\nEjecutando acción:\t{}".format( colored(self.name(), 'yellow', attrs=['bold']))) print("Representación de los slots:") color_print_slots(tracker) subject_acro = tracker.get_slot("subject_acronym").upper() chat_id = tracker.sender_id user_lang = Chats().get_chat_lite(chat_id)['language'] teachers_info = API_raco().get_subject_teachers(acronym=subject_acro, language=user_lang) teachers_info = Subject_teachers(subject_acro, teachers_info, user_lang) answers = { 'ca': "Aquests són els professors de {}:\n", 'es': 'Éstos son los profesores de {}:\n', 'en': "These are {}'s teachers:\n" } answer = answers[user_lang].format(subject_acro) for teacher in teachers_info.get_names(): answer = answer + teacher + '\n' dispatcher.utter_message("{}".format(answer)) return []