from bot.action.util.textformat import FormattedText


class CommandUsageMessage:
    @classmethod
    def get_formatted_usage_text(cls, command, args=None, description=""):
        text = FormattedText().bold("Usage").newline()
        if type(args) is list:
            text.concat(FormattedText().newline().join((cls.__get_command_with_args(command, arg) for arg in args)))
        else:
            text.concat(cls.__get_command_with_args(command, args))
        if description:
            if not isinstance(description, FormattedText):
                description = FormattedText().normal(description)
            text.newline().newline().concat(description)
        return text

    @classmethod
    def get_usage_message(cls, command, args=None, description=""):
        return cls.get_formatted_usage_text(command, args, description).build_message()

    @staticmethod
    def __get_command_with_args(command, args):
        text = command
        if args:
            text += " " + args
        return FormattedText().code_inline(text)

@@ -45,16 +45,38 @@
 ttedText
+, FormattedTextFactory
 %0A%0A%0Aclass
@@ -217,16 +217,40 @@
 ttedText
+Factory.get_new_markdown
 ().bold(
@@ -327,39 +327,101 @@
 cat(
-FormattedText().newline().join(
+%0A                FormattedTextFactory.get_new_markdown().newline().join(%0A                    
 (cls
@@ -475,17 +475,47 @@
 in args)
-)
+%0A                )%0A            
 )%0A      
@@ -720,17 +720,38 @@
 Text
-().normal
+Factory.get_new_markdown().raw
 (des
@@ -1177,16 +1177,40 @@
 ttedText
+Factory.get_new_markdown
 ().code_

Fix CommandUsageMessage to allow backward compatibility with already existing raw Markdown formatted text