From c74dc6a2adf64fd4a3eca6914c579c33d06b021c Mon Sep 17 00:00:00 2001 From: Kubbo <390378816@qq.com> Date: Sat, 3 Aug 2024 17:42:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=98=E8=AE=B0=E5=A4=84=E7=90=86dify?= =?UTF-8?q?=E8=BF=87=E6=9D=A5=E7=9A=84=E5=9C=B0=E5=9D=80=E4=BC=9A=E5=A4=9A?= =?UTF-8?q?=E4=B8=80=E6=AE=B5/v1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dowmd.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/dowmd.py b/dowmd.py index 4f5c22b..07c92ec 100644 --- a/dowmd.py +++ b/dowmd.py @@ -50,18 +50,13 @@ class dow_markdown(Plugin): has_md = re.search(r'\!\[[^\]]+\]\(?',content) if has_md: host = os.environ.get('DIFY_API_BASE', 'http://121.37.155.68:35801') + if host.endswith('/v1'): + host = host[:-3] image_path = re.search(r'!\[.*\]\((.*?)\)',content).group(1) logger.info(f"提取到的数据==>host:{host},url:{image_path}") reply = Reply(ReplyType.IMAGE_URL, f"{host}{image_path}") e_context["reply"] = reply e_context.action = EventAction.BREAK_PASS - # 去掉每行结尾的Markdown链接中网址部分的小括号,避免微信误以为“)”是网址的一部分导致微信中无法打开该页面 - content_list = content.split('\n') - new_content_list = [re.sub(r'\((https?://[^\s]+)\)$', r' \1', line) for line in content_list] - if new_content_list != content_list: - logger.info(f"[dow_markdown] parenthesis in the url has been removed, content={content}") - reply = Reply(ReplyType.TEXT, '\n'.join(new_content_list).strip()) - e_context["reply"] = reply except Exception as e: logger.warn(f"[dow_markdown] on_decorate_reply failed, content={content}, error={e}") finally: