feat: add Markdown-to-image for notification channels (Fixes #289) (#315)

* feat: add Markdown-to-image for notification channels (Fixes #289)

- Add MARKDOWN_TO_IMAGE_CHANNELS config for telegram, wechat, custom, email
- New src/md2img.py: markdown_to_image() via imgkit/wkhtmltoimage
- Extract markdown_to_html_document to src/formatters.py for reuse
- Implement image sending: Telegram sendPhoto, WeChat base64+md5,
  Discord webhook multipart, email inline attachment
- Add imgkit to requirements, wkhtmltopdf to Dockerfile
- Graceful fallback to text when imgkit/wkhtmltopdf unavailable

* fix(docker): pin to bookworm for wkhtmltopdf, add runtime deps

wkhtmltopdf was removed from Debian testing (2025). Pin base image to
python:3.11-slim-bookworm. Add fontconfig, libjpeg62-turbo, libxrender1,
libxext6 for headless wkhtmltopdf.

* docs(md2img): add security note on command injection and XSS

* refactor(md2img): extract _should_use_image_for_channel, document Fallback rules

* docs: add Markdown-to-image dependency install guide (imgkit, wkhtmltopdf)
This commit is contained in:
Alfred
2026-02-13 21:16:22 +08:00
committed by GitHub
parent 184084e415
commit 5883dc41bd
9 changed files with 512 additions and 147 deletions

View File

@@ -35,6 +35,7 @@ google-search-results>=2.4.0 # SerpAPI每月 100 次免费)
# 网络请求
requests>=2.31.0 # HTTP 请求
markdown2>=2.4.0 # Markdown 转 HTML
imgkit>=1.2.0 # Markdown 转图片(需安装 wkhtmltopdf
fake-useragent>=1.4.0 # 随机 User-Agent 防封禁
httpx[socks] # HTTP 客户端 + SOCKS 代理支持OpenAI 可选依赖)
dingtalk-stream >= 0.24.3 # 钉钉 Stream SDK