From dfa73147aa5ab106949ce972abfdc879da2bd471 Mon Sep 17 00:00:00 2001 From: Kubbo <390378816@qq.com> Date: Fri, 30 Aug 2024 11:47:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E5=8F=96=E5=8F=AF=E7=94=A8=E9=85=8D?= =?UTF-8?q?=E7=BD=AE,=E4=B8=8D=E7=94=A8=E5=86=8D=E9=87=8D=E5=90=AFdow?= =?UTF-8?q?=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.json | 3 +++ dowmd.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 config.json 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