Skip to main content
ErisPulse KookAdapter

ErisPulse KookAdapter

Kook(开黑啦)机器人适配器 —— 基于 ErisPulse 框架。

基于开源机器人框架 ErisPulse 的 Kook(开黑啦)机器人适配器,支持频道 / 私信消息收发、KMarkdown、卡片消息、@提及与回复等完整能力。

PyPI Python License Stars Downloads ErisPulse


项目目前已托管至PyPi,使用以下命令以完成安装:

pip install ErisPulse-KookAdapter

此时执行ep list,应该可以看到ErisPulse-KookAdapter在已安装的适配器列表中。

使用

from ErisPulse import sdk
adapter = sdk.adapter.get("Kook")

然后就可以对adapter变量进行适配器方法操作了。

适配器支持链式调用:

# @用户
await kook.Send.To("group", "频道ID").At("用户ID").Text("Hello")

# @多个用户
await kook.Send.To("group", "频道ID").At("用户1").At("用户2").Text("Hello")

# @全体
await kook.Send.To("group", "频道ID").AtAll().Text("公告")

# 回复消息
await kook.Send.To("group", "频道ID").Reply("消息ID").Text("回复内容")

# 组合使用
await kook.Send.To("group", "频道ID").At("用户ID").Reply("消息ID").Text("Hello")

另外,支持不同消息SendDSL调用:

# 文本消息
await kook.Send.To("group", "频道ID").Text("Hello World")

# 图片消息
await kook.Send.To("group", "频道ID").Image("http://example.com/image.jpg")

# 视频消息
await kook.Send.To("group", "频道ID").Video("http://example.com/video.mp4")

# 文件消息
await kook.Send.To("group", "频道ID").File("http://example.com/file.pdf")

# 语音消息
await kook.Send.To("group", "频道ID").Voice("http://example.com/voice.mp3")

# KMarkdown 消息
await kook.Send.To("group", "频道ID").Markdown("**粗体** *斜体*")

# 卡片消息
await kook.Send.To("group", "频道ID").Card({
    "type": "card",
    "theme": "primary",
    "size": "lg",
    "modules": [
        {"type": "header", "text": {"type": "plain-text", "content": "标题"}},
        {"type": "section", "text": {"type": "kmarkdown", "content": "内容"}}
    ]
})

私信消息

# 发送私信给指定用户
await kook.Send.To("user", "用户ID").Text("Hello")
await kook.Send.To("user", "用户ID").Markdown("**私信内容**")
await kook.Send.To("user", "用户ID").Card({...})

消息编辑与撤回

# 发送消息并获取消息ID
result = await kook.Send.To("group", "频道ID").Markdown("**原始内容**")
msg_id = result["data"]["msg_id"]

# 编辑消息(仅支持 KMarkdown 和 CardMessage)
await kook.Send.To("group", "频道ID").Edit(msg_id, "**更新后的内容**")

# 撤回消息
await kook.Send.To("group", "频道ID").Recall(msg_id)

# 上传本地文件 并获取文件URL
result = await kook.Send.Upload("C:/path/to/image.jpg")
file_url = result["data"]["url"]

参考文档

Metadata

Release files for ErisPulse-KookAdapter 4.3.0

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

Source distribution (sdist)

Source distribution for ErisPulse-KookAdapter 4.3.0
File Size Uploaded Provenance Actions
erispulse_kookadapter-4.3.0.tar.gz 33.3 kB Without provenance Details for erispulse_kookadapter-4.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ErisPulse-KookAdapter 4.3.0
File Interpreter ABI Platform Actions
erispulse_kookadapter-4.3.0-py3-none-any.whl Python 3 none any Details for erispulse_kookadapter-4.3.0-py3-none-any.whl

Total release size: 60.8 kB

Release files / erispulse_kookadapter-4.3.0.tar.gz

Download URL erispulse_kookadapter-4.3.0.tar.gz
Size 33.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d2735b3d85f7c0dced1f1f43c7c4a1574018ffd605cd770fec58fee1a2dfc39a
BLAKE2b-256 checksum
How to use checksums
a12c8b924bdd6e519dd10b48460a6892e4ddd51c8fc3abe67e739714fc56d767
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / erispulse_kookadapter-4.3.0-py3-none-any.whl

Download URL erispulse_kookadapter-4.3.0-py3-none-any.whl
Size 27.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9397ed241b62f0256d10fbb7773fdc27821cfbd29c0a01749cfd5a82ae8a06d3
BLAKE2b-256 checksum
How to use checksums
95234a68510e7043bb309c7597b085ce8013d3fc7ef74d7f9773e1b3ffc9401c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for ErisPulse-KookAdapter 4.3.0

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.

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