安装
Chronocat
请按照 Chronocat 的指引安装。
目前推荐版本为 v0.0.51
迁移指南
如果你原先为 go-cqhttp 用户,可以参考 迁移指南 来修改你的插件。
首次使用者同样可以参考该指南。
配置
修改 NoneBot 配置文件 .env 或者 .env.*。
Driver
参考 driver 配置项,添加 ForwardDriver 支持。
如:
DRIVER=~httpx+~websockets
DRIVER=~aiohttp
关于 ForwardDriver ,参考 Driver。
RED_AUTO_DETECT
是否自动检测 Chronocat 的配置文件 ~/.chronocat/config/chronocat.yml 并读取内容,默认为 False。
配置文件详细内容请参考 Chronocat/config。
该配置项需要在 Chronocat 版本 v0.0.46 以上才可用。
使用该配置项时,你需要通过 pip install nonebot-adapter-red[auto_detect] 安装 nonebot-adapter-red。
如果你已经配置了 RED_BOTS,则该配置项不会生效。
RED_BOTS
配置机器人帐号,如:
RED_BOTS='
[
{
"port": "xxx",
"token": "xxx",
"host": "xxx"
}
]
'
你需要从 Chronocat 的配置文件 ~/.chronocat/config/chronocat.yml 中获取 port、token、host。
在单账号下,
port与配置文件下的servers[X].port一致token与配置文件下的servers[X].token一致host与配置文件下的servers[X].listen一致
# ~/.chronocat/config/chronocat.yml
servers:
- type: red
# Chronocat 已经自动生成了随机 token。要妥善保存哦!
# 客户端使用服务时需要提供这个 token!
token: DEFINE_CHRONO_TOKEN # token
# Chronocat 开启 red 服务的端口,默认为 16530。
port: 16530 # port
# 服务器监听的地址。 如果你不知道这是什么,那么不填此项即可!
listen: localhost # host
而多账号下,
port与配置文件下下的overrides[QQ].servers[X].port一致,并且一个QQ只能对应一个porttoken与配置文件下下的overrides[QQ].servers[X].token一致host与配置文件下下的overrides[QQ].servers[X].listen一致
# ~/.chronocat/config/chronocat.yml
overrides:
1234567890:
servers:
- type: red
# Chronocat 已经自动生成了随机 token。要妥善保存哦!
# 客户端使用服务时需要提供这个 token!
token: DEFINE_CHRONO_TOKEN # token
# Chronocat 开启 red 服务的端口,默认为 16530。
port: 16531 # port
# 服务器监听的地址。 如果你不知道这是什么,那么不填此项即可!
listen: localhost
旧版 Chronocat
对于旧版的 Chronocat,
port是默认的16530token被默认存储在%AppData%/BetterUniverse/QQNT/RED_PROTOCOL_TOKEN或~/BetterUniverse/QQNT/RED_PROTOCOL_TOKEN中,并保持不变。host默认为localhost。
功能
支持的事件:
- 群聊消息、好友消息 (能够接收到来着不同设备的自己的消息)
- 群名称改动事件
- 群成员禁言/解除禁言事件
- 群成员加入事件 (包括旧版受邀请入群)
支持的 api:
- 发送消息 (文字,at,图片,文件,表情,引用回复)
- 发送伪造合并转发 (文字,at,图片)
- 获取自身资料
- 获取好友、群组、群组内群员资料
- 获取群公告
- 禁言/解禁群员
- 全体禁言
- 获取历史消息
- 获取媒体消息的原始数据
完整的 api 文档请参考 API 文档 或 QQNTRedProtocol
示例
from pathlib import Path
from nonebot import on_command
from nonebot.adapters.red import Bot
from nonebot.adapters.red.event import MessageEvent
from nonebot.adapters.red.message import MessageSegment
matcher = on_command("test")
@matcher.handle()
async def handle_receive(bot: Bot, event: MessageEvent):
if event.is_group:
await bot.send_group_message(event.scene, MessageSegment.image(Path("path/to/img.jpg")))
Metadata
Release files for nonebot-adapter-red 0.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nonebot_adapter_red-0.9.0.tar.gz | 22.8 kB | Without provenance | Details for nonebot_adapter_red-0.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nonebot_adapter_red-0.9.0-py3-none-any.whl | Python 3 | none | any | Details for nonebot_adapter_red-0.9.0-py3-none-any.whl |
Total release size: 47.4 kB
Release files / nonebot_adapter_red-0.9.0.tar.gz
| Download URL | nonebot_adapter_red-0.9.0.tar.gz |
|---|---|
| Size | 22.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a657c5ffb071c91deb4109bb94ac8046dcbea5cbb584437995c30ffb2d184954
|
|
BLAKE2b-256 checksum How to use checksums |
c1d581fda183c540aa6dd5444aa720b34d4724e0d962fcbb0535d29fe9d6f5a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
pdm/2.12.3 CPython/3.10.12
|
Release files / nonebot_adapter_red-0.9.0-py3-none-any.whl
| Download URL | nonebot_adapter_red-0.9.0-py3-none-any.whl |
|---|---|
| Size | 24.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8dd5cd0a5d964faa23823b7c37fa8c64fa3ed8f67fa66515fe44a2708ee438ec
|
|
BLAKE2b-256 checksum How to use checksums |
19c6b45001ee2e85352c39e10dacdd74cc8e2c99a5fc41f3dafb3ebc49fe1a61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
pdm/2.12.3 CPython/3.10.12
|
Security for nonebot-adapter-red 0.9.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.