ErisPulse KookAdapter
Kook(开黑啦)机器人适配器 —— 基于 ErisPulse 框架。
基于开源机器人框架 ErisPulse 的 Kook(开黑啦)机器人适配器,支持频道 / 私信消息收发、KMarkdown、卡片消息、@提及与回复等完整能力。
项目目前已托管至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.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| erispulse_kookadapter-4.2.0.tar.gz | 33.0 kB | Without provenance | Details for erispulse_kookadapter-4.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| erispulse_kookadapter-4.2.0-py3-none-any.whl | Python 3 | none | any | Details for erispulse_kookadapter-4.2.0-py3-none-any.whl |
Total release size: 60.2 kB
Release files / erispulse_kookadapter-4.2.0.tar.gz
| Download URL | erispulse_kookadapter-4.2.0.tar.gz |
|---|---|
| Size | 33.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9fa5ae29819ca97c430d15cb899f43d4955d6e29936dba14b7ec1a3d955ae022
|
|
BLAKE2b-256 checksum How to use checksums |
d0297d82a593adcaa0ebb1661506c65638ed94cd7f6466147f3a247a870d754d
|
| 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.2.0-py3-none-any.whl
| Download URL | erispulse_kookadapter-4.2.0-py3-none-any.whl |
|---|---|
| Size | 27.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3983e1d1c8a165b2e09438cc183696eaa5b06b572d1b66006a551e2678c4121d
|
|
BLAKE2b-256 checksum How to use checksums |
b39729469bc2e6d83f9a942716871effd53004b7cdd0347c04547053877d18d4
|
| 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.2.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.