提取可用配置,不用再重启dow了

This commit is contained in:
2024-08-30 11:47:19 +08:00
committed by GitHub
parent f63fb499b8
commit dfa73147aa
2 changed files with 7 additions and 1 deletions

3
config.json Normal file
View File

@@ -0,0 +1,3 @@
{
"regex_pattern":"!\\[([^\\]]*)\\]\\(?([^)\\\\\\s]+)\\)?"
}

View File

@@ -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