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.1.1.tar.gz (14.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.1.1-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: erispulse_kookadapter-0.1.1.tar.gz
  • Upload date:
  • Size: 14.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.1.1.tar.gz
Algorithm Hash digest
SHA256 c65db53f6ee494c682b53c99cca988245e2fedf1c048663e69204f8c17fed8b1
MD5 5bcc2b984eb8ad0bc839e401c446fa91
BLAKE2b-256 4b1c4896a283f75733f0e4595e64908578273a359ab2e9686060dd054cfb1680

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for erispulse_kookadapter-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7a08361db0775b170b81fe64d7405695b9a957a321df43f9b4ecd0262582c248
MD5 3515dbe0d6677b58548bd9604071e822
BLAKE2b-256 9b1dfe6433aedbad045621af031ae708c094336b30f17a4cefa9d358189c6b2b

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