diff --git a/config.json b/config.json new file mode 100644 index 0000000..de9119d --- /dev/null +++ b/config.json @@ -0,0 +1,3 @@ +{ + "regex_pattern":"!\\[([^\\]]*)\\]\\(?([^)\\\\\\s]+)\\)?" +} \ No newline at end of file diff --git a/dowmd.py b/dowmd.py index e50a26f..c1fba12 100644 --- a/dowmd.py +++ b/dowmd.py @@ -21,6 +21,7 @@ class dow_markdown(Plugin): def __init__(self): super().__init__() try: + self.config =super().loading_config() self.handlers[Event.ON_HANDLE_CONTEXT] = self.on_handle_context self.handlers[Event.ON_DECORATE_REPLY] = self.on_decorate_reply logger.info("[dow_markdown] inited.") @@ -108,6 +109,8 @@ class dow_markdown(Plugin): return text def format_content(self, content): - content = re.sub(r"\!\[([^\]]*)\]\(?([^)\\\s]+)\)?", r"&分块&\2&分块&", content) + regex_pattern = self.config.get("regex_pattern",r"\!\[([^\]]*)\]\(?([^)\\\s]+)\)?") + replacement_pattern = self.config.get("replacement_pattern",r"&分块&\2&分块&") + content = re.sub(regex_pattern, replacement_pattern, content) content = re.sub(r"\\n", "\n", content) return content