Skip to main content

ChatLark

ChatArch 的 Feishu/Lark bot helper 包,承接从 ChatTool 拆出的轻量机器人、消息发送、事件服务和消息内容构造能力。更广泛的 Feishu/Lark OpenAPI 操作仍优先使用官方 lark-cli

快速开始

pip install -e ".[dev]"
chatlark --help
chatlark --version
chatlark --tree
chatlark --tree-brief
chatlark send --help
chatlark serve --help
python -m pytest -q
python -m build

CLI

chatlark info
chatlark send USER_ID "Hello"
chatlark send "Hello"                  # 使用 FEISHU_DEFAULT_RECEIVER_ID
chatlark send -t chat_id "Hello team" # 使用 FEISHU_DEFAULT_CHAT_ID
chatlark serve echo
chatlark serve webhook

模型调用相关命令暂不放入 ChatLark 的默认命令面;需要模型 backend 的 bot 编排会在后续单独设计,避免重新引入 ChatTool 或其他 LLM runtime 硬依赖。

CLI 树

chatlark --tree 由 ChatStyle 从真实 Click registry 渲染,并保留参数签名:

chatlark
├── --help  # Show this message and exit.
├── --version  # Show the version and exit.
├── --tree  # Print the registered CLI tree and exit.
├── --tree-brief  # Print the registered CLI tree without parameter signatures and exit.
├── info [--env ENV-REF]  # Read bot metadata and validate credentials without printing secrets.
├── send [RECEIVER] [TEXT] [--env ENV-REF] [--type ID-TYPE]  # Send one remote text message and print its message ID, never credentials.
└── serve  # Run long-lived Lark bot network services.
    ├── echo [--mode MODE] [--host HOST] [--port PORT] [--log-level LOG-LEVEL]  # Run an echo bot that receives and replies to remote messages.
    └── webhook [--host HOST] [--port PORT] [--path PATH] [--log-level LOG-LEVEL] [--encrypt-key ENCRYPT-KEY] [--verification-token VERIFICATION-TOKEN]  # Run a webhook verifier without printing token values.

chatlark --tree-brief 保留同一组节点和说明,但省略参数签名。

Leaf 主要输入 输出 副作用与边界
chatlark info 可选 Feishu profile 或 .env bot 名称、Open ID、状态 只读远程请求;不输出凭据
chatlark send receiver、text、ID type、可选配置 message_id 或错误码 发送一条远程消息;不输出凭据
chatlark serve echo mode、host、port、log level 长期运行日志 接收并回复消息;不输出凭据
chatlark serve webhook listener 与 webhook 参数 长期运行日志 启动监听服务;不输出 token 值

Python API

from chatlark import LarkBot, ChatSession

bot = LarkBot()
session = ChatSession(system="你是助手")

@bot.on_message
def chat(ctx):
    ctx.reply(session.chat(ctx.sender_id, ctx.text))

bot.start()

配置

ChatLark 复用 ChatEnv 的 Feishu 配置字段:

  • FEISHU_APP_ID
  • FEISHU_APP_SECRET
  • FEISHU_API_BASE
  • FEISHU_DEFAULT_RECEIVER_ID
  • FEISHU_DEFAULT_CHAT_ID

默认从 ChatEnv active Feishu profile($CHATARCH_HOME/envs/Feishu/.env)读取,并回退到进程环境变量。infosend 也可通过 -e/--env 指定 ChatEnv Feishu profile 名称或显式 .env 文件;命名 profile 由 ChatEnv EnvStore 解析,且不会被全局激活。

边界

  • ChatLark:bot helper、消息发送、事件服务、消息上下文、消息内容构造。
  • lark-cli:广泛 Feishu/Lark OpenAPI 操作和用户授权流程。
  • ChatTool:迁移完成后只应保留有意设计的兼容入口或依赖连接,不再重复持有 Lark business logic。

开发说明

扩展前先阅读 DEVELOP.mdAGENTS.md。发布走 PyPI Trusted Publisher/OIDC workflow,不使用本地 token 上传正式版本。

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chatlark-0.1.2.tar.gz (25.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chatlark-0.1.2-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file chatlark-0.1.2.tar.gz.

File metadata

  • Download URL: chatlark-0.1.2.tar.gz
  • Upload date:
  • Size: 25.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for chatlark-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9fa53688e64bdcb7d9042c0be45d52e3cdd5fb459b232be949d54920b78c593e
MD5 281b7058c83dd23d528d105f0631a324
BLAKE2b-256 2d129b83c5cc40ddea5faa67dfa1df2d5c083ab626a85f14a5fb642584da8b9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatlark-0.1.2.tar.gz:

Publisher: publish.yml on ChatArch/ChatLark

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chatlark-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: chatlark-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for chatlark-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dc8c41075b2b38b1e31e6a200e3066ceaa81b2b622a4d7f42f41d06d85cb47f3
MD5 ff99a2016474d1ae3a15eddfff2848da
BLAKE2b-256 4e875657778df98db1f66c17395789ce0fa2dfd3dc9a3a9dff389fb7910130a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatlark-0.1.2-py3-none-any.whl:

Publisher: publish.yml on ChatArch/ChatLark

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 files

0.1.1

2 files

0.1.0

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page