一款为 go-cqhttp 的正向 WebSocket 设计的 Python SDK,支持纯 CQ 码与消息链的转换处理
Project description
Nakuru Project
这是由idoknow维护的分支
一款为 go-cqhttp 的正向 WebSocket 设计的 Python SDK,支持纯 CQ 码与消息链的转换处理
在 kuriyama 的基础上改动
项目名来源于藍月なくる,图标由せら绘制
食用方法
使用 pip install nakuru-project-idk 安装。
需要将 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nakuru_project_idk-0.0.2.1.tar.gz.
File metadata
- Download URL: nakuru_project_idk-0.0.2.1.tar.gz
- Upload date:
- Size: 350.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3012a0076d3faeeb1d8b790e7c2cf9eb14962752e50340ab50d735a2f42c2a8e
|
|
| MD5 |
d85ab752e5fa339e44098db4c317424f
|
|
| BLAKE2b-256 |
4d022e59ed6a70452b669412a7b89fb9c14396f61fb63b30797c3263cae7ea04
|
File details
Details for the file nakuru_project_idk-0.0.2.1-py3-none-any.whl.
File metadata
- Download URL: nakuru_project_idk-0.0.2.1-py3-none-any.whl
- Upload date:
- Size: 24.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bddd8af8a46ef381bd05b806d6c07bd8ba407c58b47ce6148d750bd77c4420bc
|
|
| MD5 |
d160102ea1a2204cc46763c0e236bab5
|
|
| BLAKE2b-256 |
4a675c9c8f1ba4a599e35a77ca7e0a0210ab6cd732f719bc3b0fc95c69aaca10
|