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.1.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.1.0
File Size Uploaded
erispulse_kookadapter-4.1.0.tar.gz 32.0 kB Details

Built distribution (wheel)

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

Total release size: 58.2 kB

Release files / erispulse_kookadapter-4.1.0.tar.gz

Download URL erispulse_kookadapter-4.1.0.tar.gz
Size 32.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f41bdc48905113ce06c901fa320113eaea63dd3c0fbf6802f684c8fb7b125462
BLAKE2b-256 checksum
How to use checksums
92e59d1371615e09fd8e34bbd5f2e58916a64575a8583888b2a84096e36862b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

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

Download URL erispulse_kookadapter-4.1.0-py3-none-any.whl
Size 26.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c04c5d315882455be73b860155b9edf8328a2b9237fb5469932a5fa82bf90176
BLAKE2b-256 checksum
How to use checksums
ff5e5e9e46cefb6d0f17f2baaf23a4dcdde4c5bc78aa08004bd5721839cef7e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

4.1.0 This release

2 release files

4.0.0

2 release files

0.2.1

2 release files

0.1.1

2 release files

0.1.0

2 release files

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