Пример #1
0
    async def job_claim_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        user_profile: UserProfile = step_context.values[self.USER_INFO]
        # Storing contacts and setting bools
        contact_dates = step_context.result
        user_profile.contact_risk_1_date = contact_dates[0]
        user_profile.contact_risk_2_date = contact_dates[1]
        print("[DEBUG] Current date " + date.today().strftime("%Y%m%d"))
        if contact_dates[0] is not None:
            print("[DEBUG] " + contact_dates[0])
            print("[DEBUG] Time diff risk contact 1: " + str(
                int(date.today().strftime("%Y%m%d")) -
                int(user_profile.contact_risk_1_date.replace("-", ""))))
            if int(date.today().strftime("%Y%m%d")) - int(
                    user_profile.contact_risk_1_date.replace("-", "")) <= 14:
                user_profile.contact_risk_1_bool = True
        if contact_dates[1] is not None:
            print("[DEBUG] " + contact_dates[1])
            print("[DEBUG] Time diff risk contact 2: " + str(
                int(date.today().strftime("%Y%m%d")) -
                int(user_profile.contact_risk_2_date.replace("-", ""))))
            if int(date.today().strftime("%Y%m%d")) - int(
                    user_profile.contact_risk_2_date.replace("-", "")) <= 14:
                user_profile.contact_risk_2_bool = True

        return await step_context.begin_dialog(
            ChoicePrompt.__name__,
            PromptOptions(prompt=MessageFactory.text(
                "Arbeiten Sie in einem systemkritischen Bereich?"),
                          choices=[Choice("Ja"), Choice("Nein")]))
Пример #2
0
    async def _select_picture(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        if step_context.result:
            if 'image' not in step_context.result[
                    0].content_type:  # check if there is an image
                await step_context.context.send_activity(
                    "Tipo di file non valido. Cancello tutte le operazioni in corso."
                )
                return await step_context.cancel_all_dialogs()

            step_context.values['image_url'] = step_context.result[
                0].content_url
            return await step_context.prompt(
                ChoicePrompt.__name__,
                PromptOptions(prompt=MessageFactory.text(
                    "Vuoi aggiungere un nuovo utente, o aggiornarne uno già presente?"
                ),
                              retry_prompt=MessageFactory.text(
                                  "Per favore seleziona un'opzione dalla lista."
                              ),
                              choices=[Choice('Nuovo'),
                                       Choice('Esistente')]))

        await step_context.context.send_activity('Operazione annullata.')
        return await step_context.cancel_all_dialogs()
Пример #3
0
    async def confirm_riskcountry_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        user_profile: UserProfile = step_context.values[self.USER_INFO]
        user_profile.age = int(step_context.result)

        prompt_options = PromptOptions(
            choices=[Choice("Ja"), Choice("Nein")],
            prompt=MessageFactory.text(
                "Waren Sie dieses Jahr bereits im Ausland?"))

        return await step_context.begin_dialog(ChoicePrompt.__name__,
                                               prompt_options)
Пример #4
0
    async def choose_cloud_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        choices = []
        if self.azure_dialog:
            choices.append(Choice(Cloud.azure.value))
        if self.gcp_dialog:
            choices.append(Choice(Cloud.gcp.value))

        return await step_context.prompt(
            ChoicePrompt.__name__,
            PromptOptions(
                prompt=MessageFactory.text(
                    "Please choose the cloud you want me to have a look at"),
                choices=choices,
            ))
Пример #5
0
    async def get_prompt_choices(self, step_context: WaterfallStepContext):
        choices = list()
        token = await step_context.context.adapter.get_user_token(
            step_context.context, self.connection_name)

        if token is None:
            choices.append(Choice("Login"))

        else:
            choices.append(Choice("Logout"))
            choices.append(Choice("Show token"))

        choices.append(Choice("End"))

        return choices
Пример #6
0
    async def _select_from_db(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        step_context.values.update(step_context.options)
        user_info = await self.user_profile_accessor.get(
            step_context.context, UserProfile)
        try:
            user = user_dao.get_user_by_id(user_info.id)
            people = people_dao.retrive_people(user.person_group_id)
            people_list = [
                Choice(f'{person.id}) {person.name}  {person.surname}')
                for person in people
            ]
            if not people_list:
                raise Exception('No people in Database')
        except:
            await step_context.context.send_activity(
                'Non sono riuscito ad ottenere le informazioni. '
                'Assicurati di aver aggiunto almeno una persona nel Database.')
            return await step_context.cancel_all_dialogs()

        return await step_context.prompt(
            ChoicePrompt.__name__,
            PromptOptions(prompt=MessageFactory.text(
                'Seleziona la persona a cui associare la foto. '),
                          retry_prompt=MessageFactory.text(
                              "Per favore seleziona un'opzione dalla lista."),
                          style=ListStyle.hero_card,
                          choices=people_list))
Пример #7
0
    async def _choose_person(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        user_profile: UserProfile = await self.user_profile_accessor.get(
            step_context.context, UserProfile)

        user = user_dao.get_user_by_id(user_profile.id)
        if not user:
            await step_context.context.send_activity(
                "Devi aggiungere almeno una persona nel Database per inizializzare il tuo account."
            )
            return await step_context.end_dialog()
        step_context.values['person_group_id'] = user.person_group_id

        people = people_dao.retrive_people(user.person_group_id)
        if not people:
            await step_context.context.send_activity(
                "Non è presente alcuna persona nel Database.")
            return await step_context.end_dialog()

        people_list = [
            Choice(f'{person.id}) {person.name}  {person.surname}')
            for person in people
        ]

        return await step_context.prompt(
            ChoicePrompt.__name__,
            PromptOptions(prompt=MessageFactory.text(
                'Seleziona il profilo della persona da eliminare. '),
                          retry_prompt=MessageFactory.text(
                              "Per favore seleziona un'opzione dalla lista."),
                          style=ListStyle.hero_card,
                          choices=people_list))
Пример #8
0
    async def _confirm_name_surname(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        if step_context.result:
            step_context.values['surname'] = step_context.result
            return await step_context.prompt(
                ChoicePrompt.__name__,
                PromptOptions(prompt=MessageFactory.text(
                    f'Desideri inserire {step_context.values["name"]} {step_context.values["surname"]} nel database?'
                ),
                              retry_prompt=MessageFactory.text(
                                  "Per favore seleziona un'opzione dalla lista."
                              ),
                              choices=[Choice('Si'),
                                       Choice('No')]))

        await step_context.context.send_activity("Operazione cancellata.")
        return await step_context.cancel_all_dialogs()
Пример #9
0
    async def intro_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        LOGGER.debug(msg=f"Main dialog intro step")

        prompt_options = PromptOptions(
            prompt=MessageFactory.text(""),
            choices=[
                Choice(Action.SCHEDULE_DELIVERY.value),
                Choice(Action.LIST_DELIVERIES.value),
                Choice(Action.EXIT.value)
            ])

        if not self.luis_recognizer.is_configured or self.luis_recognizer.luis_is_disabled:
            return await self._handle_luis_not_configured(
                step_context, prompt_options)

        return await step_context.prompt(TextPrompt.__name__, prompt_options)
Пример #10
0
    async def select_attachment_type_step(self,
                                          step_context: WaterfallStepContext):
        # Create the PromptOptions from the skill configuration which contain the list of configured skills.
        message_text = "What attachment type do you want?"
        reprompt_message_text = (
            "That was not a valid choice, please select a valid card type.")

        options = PromptOptions(
            prompt=MessageFactory.text(message_text, message_text,
                                       InputHints.expecting_input),
            retry_prompt=MessageFactory.text(reprompt_message_text,
                                             reprompt_message_text,
                                             InputHints.expecting_input),
            choices=[Choice("Inline"), Choice("Internet")],
        )

        return await step_context.prompt(ChoicePrompt.__name__, options)
Пример #11
0
    async def _confirm_choice(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        if step_context.result:
            string = step_context.result.value
            id, namesurname = string.split(') ')
            name, surname = namesurname.split('  ')

            step_context.values['id'] = id

            return await step_context.prompt(
                ChoicePrompt.__name__,
                PromptOptions(prompt=MessageFactory.text(
                    f'Desideri aggiornare il profilo di {name} {surname} nel database?'
                ),
                              retry_prompt=MessageFactory.text(
                                  "Per favore seleziona un'opzione dalla lista."
                              ),
                              choices=[Choice('Si'),
                                       Choice('No')]))

        await step_context.context.send_activity("Operazione cancellata.")
        return await step_context.cancel_all_dialogs()
    async def select_card_step(self, step_context: WaterfallStepContext):
        # Create the PromptOptions from the skill configuration which contain the list of configured skills.
        message_text = "What card do you want?"
        reprompt_message_text = "This message will be created in the validation code"

        options = PromptOptions(
            prompt=MessageFactory.text(message_text, message_text,
                                       InputHints.expecting_input),
            retry_prompt=MessageFactory.text(reprompt_message_text,
                                             reprompt_message_text,
                                             InputHints.expecting_input),
            choices=[Choice(card.value) for card in CardOptions],
            style=ListStyle.list_style,
        )

        return await step_context.prompt(ChoicePrompt.__name__, options)
Пример #13
0
 async def job_type_step(
         self, step_context: WaterfallStepContext) -> DialogTurnResult:
     if step_context.result.value == "Ja":
         print("[DEBUG] Recognized system cricital job claim")
         return await step_context.begin_dialog(
             ChoicePrompt.__name__,
             PromptOptions(prompt=MessageFactory.text(
                 "Zu welcher systemkritischen Gruppe gehören Sie?"),
                           choices=[
                               "Polizei", "Feuerwehr", "RichterIn",
                               "Staatsanwälte", "Justizvollzug",
                               "Rettungsdienst", "THW",
                               "Katastrophenschutz", "Mediziner", "Pfleger",
                               "Apotheher", "**Keine**"
                           ],
                           style=ListStyle.list_style))
     else:
         return await step_context.next(Choice("**Keine**"))
Пример #14
0
    async def choose_specific_project_step(self, step_context: WaterfallStepContext) -> DialogTurnResult:
        # we need all projects either way (SPECIFIC/ALL)
        projects = await self.gclient.projects.list()
        self.data.projects = await self._filter_out_projects_without_compute_engine_api(projects=projects)

        chosen_project_type = str(step_context.result.value)
        if chosen_project_type == ChosenProjectType.ALL:
            await step_context.context.send_activity("All projects it is!")
            return await step_context.next(result=ChosenProjectType.ALL)

        # specific project selection
        return await step_context.prompt(
            ChoicePrompt.__name__,
            PromptOptions(
                prompt=MessageFactory.text("OK. Which one?"),
                choices=[Choice(project.name) for project in self.data.projects],
            )
        )
Пример #15
0
    async def choose_subscription_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        token = step_context.result.token
        if token:
            await step_context.context.send_activity(
                "You're in! Let's start...")
            self.azclient.set_auth_token(token)
            self.data.subscriptions = await self.azclient.subscriptions.list()
            return await step_context.prompt(
                ChoicePrompt.__name__,
                PromptOptions(
                    prompt=MessageFactory.text("Please choose a subscription"),
                    choices=[
                        Choice(sub.name) for sub in self.data.subscriptions
                    ],
                ))

        await step_context.context.send_activity(
            "Login was not successful please try again.")
        return await step_context.end_dialog()
    async def courses_step(self, step_context: WaterfallStepContext) -> DialogTurnResult:
        step_context.values[StudentProfileAttributes.PICTURE.value] = step_context.result[0]
        name = step_context.values[StudentProfileAttributes.NAME.value]

        await step_context.context.send_activity(
            MessageFactory.text(f"Hello {name}, your profile picture has been uploaded"))

        await step_context.context.send_activity(
            MessageFactory.attachment(
                step_context.result[0], f"Hello {name}, your profile picture has been uploaded"
            )
        )

        return await step_context.prompt(
            ChoicePrompt.__name__,
            PromptOptions(
                prompt=MessageFactory.text("Please select the course you are interested in"),
                choices=list(map(lambda x: Choice(x.code), self.course.course_units))
            )
        )
    async def get_prompt_choices(self, step_context: WaterfallStepContext):
        """
        Create the prompt choices based on the current sign in status
        """

        prompt_choices = list()
        token = await step_context.context.adapter.get_user_token(
            step_context.context, self._connection_name)

        if token is None:
            prompt_choices.append(Choice("Login"))

            # Token exchange will fail when the host is not logged on and the skill should
            # show a regular OAuthPrompt
            prompt_choices.append(Choice("Call Skill (without SSO)"))
        else:
            prompt_choices.append(Choice("Logout"))
            prompt_choices.append(Choice("Show token"))
            prompt_choices.append(Choice("Call Skill (with SSO)"))

        prompt_choices.append(Choice("Back"))

        return prompt_choices