Skip to main content

ErisPulse Kook Adapter - Kook平台适配器

Project description

ErisPulse-KookAdapter

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

项目目前已托管至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"]

参考文档

Project details


Download files

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

Source Distribution

erispulse_kookadapter-0.2.1.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

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

erispulse_kookadapter-0.2.1-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file erispulse_kookadapter-0.2.1.tar.gz.

File metadata

  • Download URL: erispulse_kookadapter-0.2.1.tar.gz
  • Upload date:
  • Size: 21.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for erispulse_kookadapter-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c2f26a35f48f75a7a407e910e648ba059fe01540ed00c4f62ba50afd46b3590f
MD5 cf812100e8040fd473a1f9c91be0a451
BLAKE2b-256 590b5f01356d993eacd6a32f0a6ddd750d19d3ccb7d3e00dafec45be3e4b26b4

See more details on using hashes here.

File details

Details for the file erispulse_kookadapter-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for erispulse_kookadapter-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f0fd325d74fd2e781e70ffdc0f2b58b0df7639d113ea25d07ac35e3a581ce15
MD5 b4982a5786984acb0aa39a88cbf8127b
BLAKE2b-256 905c9997dad10d2a789a5e40b9c4a2861d34dd99bd38f206ab408aa07ef679a6

See more details on using hashes here.

Supported by

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