• Stars
    star
    125
  • Rank 284,669 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created about 1 year ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

NoneBot2 基于 Red 协议 的 QQNT 适配器

NoneBot-Adapter-Red

✨ NoneBot2 Red Protocol适配器 / Red Protocol Adapter for NoneBot2 ✨

安装

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 中获取 porttokenhost

在单账号下,

  • 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 只能对应一个 port
  • token 与配置文件下下的 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 是默认的 16530
  • token 被默认存储在 %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")))

More Repositories

1

nonebot2

跨平台 Python 异步聊天机器人框架 / Asynchronous multi-platform chatbot framework written in Python
Python
5,724
star
2

nonebot

基于 OneBot 标准的 Python 异步 QQ 机器人框架 / Asynchronous QQ robot framework based on OneBot for Python
Python
2,098
star
3

aiocqhttp

A Python SDK with async I/O for CQHTTP (OneBot).
Python
272
star
4

adapter-qq

NoneBot2 QQ 适配器 / QQ adapter for nonebot2
Python
205
star
5

awesome-nonebot

NoneBot 相关资源汇总
164
star
6

nb-cli

NoneBot2 脚手架 / CLI for NoneBot2
Python
155
star
7

adapter-satori

NoneBot2 Satori 适配器 / Satori Protocol adapter for nonebot2
Python
82
star
8

plugin-apscheduler

APScheduler Support for NoneBot2
Python
77
star
9

plugin-alconna

强大的 Nonebot2 命令匹配拓展,支持富文本/多媒体解析,跨平台消息收发
Python
71
star
10

adapter-onebot

NoneBot2 OneBot 适配器 / OneBot adapter for nonebot2
Python
67
star
11

adapter-telegram

NoneBot2 Telegram适配器 / Telegram Adapter for NoneBot2
Python
50
star
12

discussions

NoneBot 论坛
49
star
13

plugin-test

Test frontend for nonebot v2+
Vue
47
star
14

cli-plugin-webui

Web UI for NoneBot CLI
Vue
43
star
15

adapter-console

NoneBot2 终端适配器 / Console adapter for nonebot2
Python
32
star
16

plugin-orm

SQLAlchemy support for NoneBot2
Python
30
star
17

nonebug

NoneBot2 测试框架 / NoneBot2 test framework
Python
27
star
18

adapter-feishu

NoneBot2 飞书适配器 / FeiShu (LarkSuite) adapter for nonebot2
Python
26
star
19

noneprompt

Prompt toolkit for console interaction (support async, typing)
Python
25
star
20

nonebot2-tutorial

tutorial for nonebot2
23
star
21

registry

NoneBot 插件商店测试
Vue
22
star
22

plugin-filehost

NoneBot2 的 HTTP 静态文件托管插件,为跨机文件传输提供解决方案 / Effortless static file hosting plugin for NoneBot2.
Python
19
star
23

docusaurus-theme-nonepress

TypeScript
19
star
24

adapter-discord

NoneBot2 Discord 适配器 / Discord adapter for nonebot2
Python
19
star
25

plugin-localstore

Local Storage Support for NoneBot2
Python
17
star
26

noneflow

NoneBot workflow management bot built with NoneBot
Python
17
star
27

adapter-github

GitHub adapter for nonebot2
Python
13
star
28

plugin-status

Python
12
star
29

cli-plugin-docker

docker support for nb-cli
Python
11
star
30

nonemoji

Python
11
star
31

nonetrip

一个提供NoneBot1兼容层的NoneBot2插件
Python
10
star
32

nonechat

通用控制台聊天界面
Python
9
star
33

adapter-dodo

NoneBot2 DoDo 适配器 / DoDo adapter for nonebot2
Python
8
star
34

nb-autodoc

Python API documentation tool supporting the modern PEPs and typing features.
Python
8
star
35

nonecorn

ASGI server that forked from hypercorn, with extra features beyond asgi spec
Python
6
star
36

adapter-kritor

NoneBot2 Kritor 协议适配器 / Kritor Protocol adapter for nonebot2
Python
6
star
37

plugin-sentry

Sentry Support for NoneBot2
Python
5
star
38

nonebot-anime

Bilibili番剧查询
Python
4
star
39

nonebot-alarm

自然语言定时提醒nonebot插件
Python
3
star
40

adapter-mirai

Mirai Api HTTP adapter for nonebot2
Python
3
star
41

noneblockly

Craft NoneBot plugins with ease: Embrace low-code development through Blockly.
TypeScript
3
star
42

nonebot-talk

NoneBot 研讨会演示内容归档
Vue
2
star
43

auto-changelog

Python
2
star
44

nonebot-tuling

NoneBot 图灵机器人插件
Python
2
star
45

homepage

JavaScript
1
star
46

adapter-ding

Ding adapter for nonebot2
Python
1
star
47

vuepress-theme-nonebot

Vue
1
star