Skip to main content

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

Project description

logo

Nakuru Project

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

kuriyama 的基础上改动

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

食用方法

使用 pip install nakuru-project 安装。

需要将 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,项目现在还存在着许多问题。

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

nakuru_project-1.0.1.tar.gz (350.5 kB view details)

Uploaded Source

Built Distribution

nakuru_project-1.0.1-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file nakuru_project-1.0.1.tar.gz.

File metadata

  • Download URL: nakuru_project-1.0.1.tar.gz
  • Upload date:
  • Size: 350.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for nakuru_project-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1cfe8a66a7e416f8d7cb97559dea4e8df09f6671877f06fcc7b823c8e4c7e5c6
MD5 be01bbf9aa677907e8edfe0e5860e056
BLAKE2b-256 cf575f09376178eed226b8f6a2b119c016729080b723f3d0c8b4ad8419779082

See more details on using hashes here.

File details

Details for the file nakuru_project-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: nakuru_project-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for nakuru_project-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 16265081762cfe146cae0102741904b0019627f13464a6d7c449e58ddf699e05
MD5 36f920382e8a8dba5f05cab43c099cf7
BLAKE2b-256 3bbc92e1381d6070327610329d7fa328373c5a5b7ab77cc212c4330be1bb7ae6

See more details on using hashes here.

Supported by

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