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.3

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.3
File Size Uploaded Provenance Actions
erispulse_kookadapter-4.3.3.tar.gz 34.4 kB Without provenance Details for erispulse_kookadapter-4.3.3.tar.gz

Built distribution (wheel)

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

Total release size: 62.9 kB

Release files / erispulse_kookadapter-4.3.3.tar.gz

Download URL erispulse_kookadapter-4.3.3.tar.gz
Size 34.4 kB
Tags Source
SHA-256 checksum
How to use checksums
70acb4d1f9e2a0382c7faa6460ac8e8dd66e80a0556ef24753d40fafa0047fc5
BLAKE2b-256 checksum
How to use checksums
7d738101d6761c1898669b6f11e5ca39001d146015b4957c591190691811ddb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

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

Download URL erispulse_kookadapter-4.3.3-py3-none-any.whl
Size 28.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
da9176170ce8cdc85f71eaa9e74973f29732a4b16f52f475b61bba62c3d1d001
BLAKE2b-256 checksum
How to use checksums
db794b73113761b279239ca39fe3cbaa75c19989d39d0049ac0d0325c6831e5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for ErisPulse-KookAdapter 4.3.3

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