Ejemplo n.º 1
0
def _bot_output(
        message: Dict[Text, Any],
        color=cli_utils.bcolors.OKBLUE) -> Optional[questionary.Question]:
    from sagas.nlu.tts_utils import say_lang
    # from sagas.kit.analysis_kit import AnalysisKit

    if ("text" in message) and not ("buttons" in message):
        text = message.get("text")
        cli_utils.print_color(text, color=color)
        say_lang(text, sett.lang, False)
        # AnalysisKit().console_vis(text, sett.lang)

    if "image" in message:
        cli_utils.print_color("Image: " + message.get("image"), color=color)

    if "attachment" in message:
        cli_utils.print_color("Attachment: " + message.get("attachment"),
                              color=color)

    if "buttons" in message:
        choices = cli_utils.button_choices_from_message_data(
            message, allow_free_text_input=True)

        question = questionary.select(
            message.get("text"),
            choices,
            style=Style([("qmark", "#6d91d3"), ("", "#6d91d3"),
                         ("answer", "#b373d6")]),
        )
        return question

    if "elements" in message:
        cli_utils.print_color("Elements:", color=color)
        for idx, element in enumerate(message.get("elements")):
            cli_utils.print_color(cli_utils.element_to_string(element, idx),
                                  color=color)

    if "quick_replies" in message:
        cli_utils.print_color("Quick Replies:", color=color)
        for idx, element in enumerate(message.get("quick_replies")):
            cli_utils.print_color(cli_utils.button_to_string(element, idx),
                                  color=color)

    if "custom" in message:
        cli_utils.print_color("Custom json:", color=color)
        cli_utils.print_color(json.dumps(message.get("custom"), indent=2),
                              color=color)
Ejemplo n.º 2
0
def print_buttons(
    message: Dict[Text, Any],
    is_latest_message: bool = False,
    color=cli_utils.bcolors.OKBLUE,
) -> Optional[questionary.Question]:
    if is_latest_message:
        choices = cli_utils.button_choices_from_message_data(
            message, allow_free_text_input=True
        )
        question = questionary.select(
            message.get("text"),
            choices,
            style=Style([("qmark", "#6d91d3"), ("", "#6d91d3"), ("answer", "#b373d6")]),
        )
        return question
    else:
        cli_utils.print_color("Buttons:", color=color)
        for idx, button in enumerate(message.get("buttons")):
            cli_utils.print_color(cli_utils.button_to_string(button, idx), color=color)
Ejemplo n.º 3
0
def print_bot_output(
        message: Dict[Text, Any],
        color=cli_utils.bcolors.OKBLUE) -> Optional[questionary.Question]:
    if ("text" in message) and not ("buttons" in message):
        cli_utils.print_color(message.get("text"), color=color)

    if "image" in message:
        cli_utils.print_color("Image: " + message.get("image"), color=color)

    if "attachment" in message:
        cli_utils.print_color("Attachment: " + message.get("attachment"),
                              color=color)

    if "buttons" in message:
        choices = cli_utils.button_choices_from_message_data(
            message, allow_free_text_input=True)

        question = questionary.select(
            message.get("text"),
            choices,
            style=Style([("qmark", "#6d91d3"), ("", "#6d91d3"),
                         ("answer", "#b373d6")]),
        )
        return question

    if "elements" in message:
        cli_utils.print_color("Elements:", color=color)
        for idx, element in enumerate(message.get("elements")):
            cli_utils.print_color(cli_utils.element_to_string(element, idx),
                                  color=color)

    if "quick_replies" in message:
        cli_utils.print_color("Quick Replies:", color=color)
        for idx, element in enumerate(message.get("quick_replies")):
            cli_utils.print_color(cli_utils.button_to_string(element, idx),
                                  color=color)

    if "custom" in message:
        cli_utils.print_color("Custom json:", color=color)
        cli_utils.print_color(json.dumps(message.get("custom"), indent=2),
                              color=color)