コード例 #1
0
    async def showBooks_step(
            self, step_context: WaterfallStepContext) -> DialogTurnResult:
        iduser = step_context.context.activity.from_property.id
        genres_user = []
        user_with_info = DatabaseManager.find_user_info(iduser)
        genres_user = user_with_info.categories

        index = random.randint(0, len(genres_user) - 1)
        category = genres_user[index]
        code = cat_and_code[category.name]
        books = SuggestBooksDialog.call_amazon(code)
        card = SuggestBooksDialog.create_card(books, category.name)
        step_context.values["books"] = books
        dic[iduser] = books
        await step_context.context.send_activity(card)

        message_text = "Vuoi aggiungere un libro alla tua wishlist?"
        prompt_message = MessageFactory.text(message_text, message_text,
                                             InputHints.expecting_input)
        return await step_context.prompt(
            ConfirmPrompt.__name__,
            PromptOptions(prompt=prompt_message,
                          retry_prompt=MessageFactory.text(
                              '''Vuoi aggiungere un libro alla tua wishlist? 
                Scrivi yes o no''')))
コード例 #2
0
 async def first_step(
         self, step_context: WaterfallStepContext) -> DialogTurnResult:
     iduser = step_context.context.activity.from_property.id
     user = DatabaseManager.find_user_info(iduser)
     step_context.values["user"] = user
     dic[iduser] = user.wishlist
     card, flag = self.create_wishlist_card(user.wishlist)
     await step_context.context.send_activity(card)
     if flag:
         message_text = "Puoi cancellare un libro dalla tua wishlist oppure tornare al menu principale. Cosa desideri fare?"
         prompt_message = MessageFactory.text(message_text, message_text,
                                              InputHints.expecting_input)
         return await step_context.prompt(
             TextPrompt.__name__, PromptOptions(prompt=prompt_message))
     return await step_context.end_dialog()