Skip to main content

mktagi-notify

一个消息发多个地方:飞书(自定义机器人 / 应用机器人)、Telegram、Slack、Discord。

核心只有三样东西:一个统一的消息模型、五个纯函数渲染器、五个通道薄壳。

from mktagi_notify import Message, Severity, fanout, from_env

results = await fanout(
    from_env(),
    Message(
        title="Q/USDT:USDT · 5 分钟急拉 3%",
        text="涨跌幅 **+5.39%**",
        fields={"交易所": "binanceusdm", "窗口": "最近 5 分钟"},
        severity=Severity.WARNING,
        url="http://applemini-mac:8848/",
    ),
)

安装

默认依赖只有 httpx。用哪个通道装哪个 extra:

pip install mktagi-notify                      # 只有飞书自定义机器人
pip install "mktagi-notify[feishu-bot]"        # 飞书应用机器人(官方 lark-oapi)
pip install "mktagi-notify[telegram]"          # Telegram(python-telegram-bot)
pip install "mktagi-notify[slack]"             # Slack(官方 slack-sdk)
pip install "mktagi-notify[discord]"           # Discord(discord.py)
pip install "mktagi-notify[all]"               # 全部

五个通道

通道 类 需要什么 卡片 回执
飞书自定义机器人 FeishuWebhook webhook 地址,开了签名校验再加 secret 消息卡片 2.0 无
飞书应用机器人 FeishuBot app_id、app_secret、chat_id 同一份消息卡片 message_id
Telegram Telegram bot token、chat_id(话题再加 thread_id) 无卡片,标题加粗 message_id
Slack Slack Incoming Webhook 地址 Block Kit 无
Discord Discord webhook 地址 embed message_id

每个通道的凭据来源、限制和未验证项写在 docs/channels.md。

约定

  • 消息只有五个字段:title、text、fields、severity、url。图片、附件、@人、按钮交互各平台差异太大,不进统一模型。
  • text 只认一种标记:**粗体**。飞书原样发,Telegram 转 <b>,Slack 转 *粗体*,Discord 原样发。
  • 发送不抛异常:fanout 把任何通道的失败变成 DeliveryResult(ok=False, error=...),一个通道挂了不影响其他通道。
  • 渲染是纯函数:mktagi_notify.render 里没有网络,可以直接对 payload 做断言。
  • 同步 SDK 丢线程:lark-oapi、slack-sdk、discord.SyncWebhook 是同步的,适配器内部用 asyncio.to_thread,对外统一 async。

开发

uv sync --all-extras
uv run pytest
uv run ruff check . && uv run ruff format --check .
uv run pyright

贡献流程见 CONTRIBUTING.md,版本规则是 X.Y.Z 语义化版本,见 CHANGELOG.md。

许可证

MIT,见 LICENSE。

当前是 0.0.x,接口随时可能改;到 1.0.0 才承诺兼容性。

Metadata

Release files for mktagi-notify 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mktagi-notify 0.0.1
File Size Uploaded Provenance Actions
mktagi_notify-0.0.1.tar.gz 140.8 kB Without provenance Details for mktagi_notify-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mktagi-notify 0.0.1
File Interpreter ABI Platform Actions
mktagi_notify-0.0.1-py3-none-any.whl Python 3 none any Details for mktagi_notify-0.0.1-py3-none-any.whl

Total release size: 158.8 kB

Release files / mktagi_notify-0.0.1.tar.gz

Download URL mktagi_notify-0.0.1.tar.gz
Size 140.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b5d7af6e5ee218241807c09b697a6e4a522e91e30b3d622347c58f232f492195
BLAKE2b-256 checksum
How to use checksums
631d1b0c151dd23af96967b350d83af2ffd500803d74748407644ea8fc4ecd4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / mktagi_notify-0.0.1-py3-none-any.whl

Download URL mktagi_notify-0.0.1-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8efe62a8a189c4ccb24076e23a55362a38b5c72da22a9ae0ecdb86f682ed8602
BLAKE2b-256 checksum
How to use checksums
22aff1b90bd23a3781f592e3a87187f7a61af4f3e60ac257b611a4a65502722d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for mktagi-notify 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page