Skip to main content
logo

Nakuru Project

一款为 go-cqhttp 的正向 WebSocket 设计的 Python SDK,支持纯 CQ 码与消息链的转换处理

在 kuriyama 的基础上改动

项目名来源于藍月なくる,图标由せら绘制

食用方法

使用 pip install git+https://github.com/Lxns-Network/nakuru-project.git 安装。

需要将 go-cqhttp 的正向 WebSocket 与 HTTP 配置项开启。

示例

没有文档,源码就是文档。

from nakuru import (
    CQHTTP,
    GroupMessage,
    Notify,
    GroupMessageRecall,
    FriendRequest
)
from nakuru.entities.components import Plain, Image

app = CQHTTP(
    host="127.0.0.1",
    port=6700,
    http_port=5700,
    token="TOKEN" # 可选,如果配置了 Access-Token
)

@app.receiver("GroupMessage")
async def _(app: CQHTTP, source: GroupMessage):
    # 通过纯 CQ 码处理
    if source.raw_message == "戳我":
        await app.sendGroupMessage(source.group_id, f"[CQ:poke,qq={source.user_id}]")
    # 通过消息链处理
    chain = source.message
    if isinstance(chain[0], Plain):
        if chain[0].text == "看":
            await app.sendGroupMessage(source.group_id, [
                Plain(text="给你看"),
                Image.fromFileSystem("D:/好康的.jpg")
            ])

@app.receiver("GroupMessageRecall")
async def _(app: CQHTTP, source: GroupMessageRecall):
    await app.sendGroupMessage(source.group_id, "你撤回了一条消息")

@app.receiver("Notify")
async def _(app: CQHTTP, source: Notify):
    if source.sub_type == "poke" and source.target_id == 114514:
        await app.sendGroupMessage(source.group_id, "不许戳我")

@app.receiver("FriendRequest")
async def _(app: CQHTTP, source: FriendRequest):
    await app.setFriendRequest(source.flag, True)

app.run()

贡献

欢迎 PR 代码或提交 Issue,项目现在还存在着许多问题。

Release files for nakuru-project-test 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nakuru-project-test 0.0.1
File Size Uploaded
nakuru_project_test-0.0.1.tar.gz 348.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nakuru-project-test 0.0.1
File Interpreter ABI Platform
nakuru_project_test-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 372.1 kB

Release files / nakuru_project_test-0.0.1.tar.gz

Download URL nakuru_project_test-0.0.1.tar.gz
Size 348.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a1f8b72e719e56cb911d02ac6166c58c8d257fc7bdd90156846daa24bc536ee1
BLAKE2b-256 checksum
How to use checksums
488e44466d6bdb8dfc96a8e6a107c273aa596505c9783bdc733062cfe6e77334
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / nakuru_project_test-0.0.1-py3-none-any.whl

Download URL nakuru_project_test-0.0.1-py3-none-any.whl
Size 23.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
18cbac8abaa92918fe3dcd4da0d2db61466ac045eed4f3f248e40e13bc141c6a
BLAKE2b-256 checksum
How to use checksums
480c0eacb736f69d1536c4055ce78a33a95ca4a4a31ad34e56fced6c88a76e13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.0.1 This release

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