def format_bot_output( message: Dict[Text, Any] ) -> Text: """Format a bot response to be displayed in the history table.""" # First, add text to output output = message.get("text") or "" # Then, append all additional items data = message.get("data", {}) if not data: return output if data.get("image"): output += "\nImage: " + data.get("image") if data.get("attachment"): output += "\nAttachment: " + data.get("attachment") if data.get("buttons"): output += "\nButtons:" for idx, button in enumerate(data.get("buttons")): button_str = button_to_string(button, idx) output += "\n" + button_str if data.get("elements"): output += "\nElements:" for idx, element in enumerate(data.get("elements")): element_str = element_to_string(element, idx) output += "\n" + element_str return output
def print_bot_output(message, color=utils.bcolors.OKBLUE): if "text" in message: utils.print_color(message.get("text"), color) if "image" in message: utils.print_color("Image: " + message.get("image"), color) if "attachment" in message: utils.print_color("Attachment: " + message.get("attachment"), color) if "buttons" in message: utils.print_color("Buttons:", color) for idx, button in enumerate(message.get("buttons")): utils.print_color(button_to_string(button, idx), color) if "elements" in message: for idx, element in enumerate(message.get("elements")): element_str = "Elements:\n" + element_to_string(element, idx) utils.print_color(element_str, color)