def __solution_messages(self, breadcrumbs): message = ResultMessage() message.embed = Embed(title="Optimization Query") sections = [str(self.__query)] inputs = self.__get_vars(self.__db.items().values(), check_value=lambda val: val < 0, suffix="/m") if len(inputs) > 0: sections.append("**Inputs**\n" + "\n".join(inputs)) outputs = self.__get_vars(self.__db.items().values(), check_value=lambda val: val > 0, suffix="/m") if len(outputs) > 0: sections.append("**Outputs**\n" + "\n".join(outputs)) recipes = self.__get_vars(self.__db.recipes().values()) if len(recipes) > 0: sections.append("**Recipes**\n" + "\n".join(recipes)) buildings = self.__get_vars(self.__db.crafters().values()) buildings.extend(self.__get_vars(self.__db.generators().values())) if len(buildings) > 0: sections.append("**Buildings**\n" + "\n".join(buildings)) descriptions = [] curr_description = "" for section in sections: if len(curr_description) + len(section) >= 4096: descriptions.append(curr_description) curr_description = "" curr_description += section + "\n\n" descriptions.append(curr_description) message.embed.description = descriptions[0] filename = 'output.gv' filepath = 'output/' + filename self.generate_graph_viz(filepath) file = File(filepath + '.png') # The image already shows up from the attached file, so no need to place it in the embed as well. # message.embed.set_image(url="attachment://" + filename + ".png") message.file = file message.content = str(breadcrumbs) messages = [message] if len(descriptions) > 1: for i in range(1, len(descriptions)): next_message = ResultMessage() next_message.embed = Embed() next_message.embed.description = descriptions[i] messages.append(next_message) return messages
def __solution_message(self, breadcrumbs): message = ResultMessage() message.embed = Embed(title="Optimization Query") # We don't include the parsed query in case this puts the embed over the character limit # message.embed.description = str(self.__query) message.embed.description = " " inputs = self.__get_vars(self.__db.items().values(), check_value=lambda val: val < 0, suffix="/m") if len(inputs) > 0: message.embed.add_field(name="Inputs", value="\n".join(inputs), inline=True) outputs = self.__get_vars(self.__db.items().values(), check_value=lambda val: val > 0, suffix="/m") if len(outputs) > 0: message.embed.add_field(name="Outputs", value="\n".join(outputs), inline=True) recipes = self.__get_vars(self.__db.recipes().values()) if len(recipes) > 0: message.embed.add_field(name="Recipes", value="\n".join(recipes), inline=False) buildings = self.__get_vars(self.__db.crafters().values()) buildings.extend(self.__get_vars(self.__db.generators().values())) if len(buildings) > 0: message.embed.add_field(name="Buildings", value="\n".join(buildings), inline=True) filename = 'output.gv' filepath = 'output/' + filename self.generate_graph_viz(filepath) file = File(filepath + '.png') # The image already shows up from the attached file, so no need to place it in the embed as well. # message.embed.set_image(url="attachment://" + filename + ".png") message.file = file message.content = breadcrumbs return message