{"id":20390252,"url":"https://github.com/nonebot/adapter-red","last_synced_at":"2025-07-04T00:05:21.553Z","repository":{"id":184620559,"uuid":"672209320","full_name":"nonebot/adapter-red","owner":"nonebot","description":"NoneBot2 基于 Red 协议 的 QQNT 适配器 ","archived":false,"fork":false,"pushed_at":"2024-02-15T10:11:06.000Z","size":195,"stargazers_count":125,"open_issues_count":3,"forks_count":10,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-14T10:23:27.820Z","etag":null,"topics":["qqnt","red-protocol"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nonebot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"open_collective":"nonebot","custom":["https://afdian.net/@nonebot"]}},"created_at":"2023-07-29T09:37:42.000Z","updated_at":"2025-04-09T08:49:01.000Z","dependencies_parsed_at":"2023-08-28T21:25:13.625Z","dependency_job_id":"9f518d32-0b37-43e3-8f70-d337d1d15e36","html_url":"https://github.com/nonebot/adapter-red","commit_stats":{"total_commits":128,"total_committers":11,"mean_commits":"11.636363636363637","dds":0.2890625,"last_synced_commit":"4eb3f0867564a8abf082993ae7897b6b7ff86c3b"},"previous_names":["zhaomaoniu/nonebot-adapter-red","nonebot/adapter-red"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/nonebot/adapter-red","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nonebot%2Fadapter-red","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nonebot%2Fadapter-red/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nonebot%2Fadapter-red/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nonebot%2Fadapter-red/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nonebot","download_url":"https://codeload.github.com/nonebot/adapter-red/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nonebot%2Fadapter-red/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260627440,"owners_count":23038539,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["qqnt","red-protocol"],"created_at":"2024-11-15T03:23:53.598Z","updated_at":"2025-07-04T00:05:21.492Z","avatar_url":"https://github.com/nonebot.png","language":"Python","funding_links":["https://opencollective.com/nonebot","https://afdian.net/@nonebot"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# NoneBot-Adapter-Red\n\n_✨ NoneBot2 Red Protocol适配器 / Red Protocol Adapter for NoneBot2 ✨_\n\n\u003c/div\u003e\n\n## 安装\n\n### Chronocat\n\n请按照 [Chronocat](https://chronocat.vercel.app) 的指引安装。\n\n**目前推荐版本为 `v0.0.51`**\n\n## 迁移指南\n\n如果你原先为 `go-cqhttp` 用户，可以参考 [迁移指南](./migrate.md) 来修改你的插件。\n\n**首次使用者同样可以参考该指南。**\n\n## 配置\n\n修改 NoneBot 配置文件 `.env` 或者 `.env.*`。\n\n### Driver\n\n参考 [driver](https://nonebot.dev/docs/appendices/config#driver) 配置项，添加 `ForwardDriver` 支持。\n\n如：\n\n```dotenv\nDRIVER=~httpx+~websockets\nDRIVER=~aiohttp\n```\n\n关于 `ForwardDriver` ，参考 [Driver](https://nonebot.dev/docs/advanced/driver)。\n\n### RED_AUTO_DETECT\n\n是否自动检测 Chronocat 的配置文件 `~/.chronocat/config/chronocat.yml` 并读取内容，默认为 `False`。\n\n配置文件详细内容请参考 [Chronocat/config](https://chronocat.vercel.app/config/)。\n\n该配置项需要在 `Chronocat` 版本 `v0.0.46` 以上才可用。\n\n使用该配置项时，你需要通过 `pip install nonebot-adapter-red[auto_detect]` 安装 `nonebot-adapter-red`。\n\n**如果你已经配置了 `RED_BOTS`，则该配置项不会生效。**\n\n### RED_BOTS\n\n配置机器人帐号，如：\n\n```dotenv\nRED_BOTS='\n[\n  {\n    \"port\": \"xxx\",\n    \"token\": \"xxx\",\n    \"host\": \"xxx\"\n  }\n]\n'\n```\n\n你需要从 Chronocat 的配置文件 `~/.chronocat/config/chronocat.yml` 中获取 `port`、`token`、`host`。\n\n在单账号下，\n- `port` 与配置文件下的 `servers[X].port` 一致\n- `token` 与配置文件下的 `servers[X].token` 一致\n- `host` 与配置文件下的 `servers[X].listen` 一致\n\n```yaml\n# ~/.chronocat/config/chronocat.yml\nservers:\n  - type: red\n    # Chronocat 已经自动生成了随机 token。要妥善保存哦！\n    # 客户端使用服务时需要提供这个 token！\n    token: DEFINE_CHRONO_TOKEN  # token\n    # Chronocat 开启 red 服务的端口，默认为 16530。\n    port: 16530  # port\n    # 服务器监听的地址。 如果你不知道这是什么，那么不填此项即可！\n    listen: localhost  # host\n```\n\n而多账号下，\n- `port` 与配置文件下下的 `overrides[QQ].servers[X].port` 一致，并且一个 `QQ` 只能对应一个 `port`\n- `token` 与配置文件下下的 `overrides[QQ].servers[X].token` 一致\n- `host` 与配置文件下下的 `overrides[QQ].servers[X].listen` 一致\n\n```yaml\n# ~/.chronocat/config/chronocat.yml\noverrides:\n  1234567890:\n    servers:\n      - type: red\n        # Chronocat 已经自动生成了随机 token。要妥善保存哦！\n        # 客户端使用服务时需要提供这个 token！\n        token: DEFINE_CHRONO_TOKEN  # token\n        # Chronocat 开启 red 服务的端口，默认为 16530。\n        port: 16531  # port\n        # 服务器监听的地址。 如果你不知道这是什么，那么不填此项即可！\n        listen: localhost\n```\n\n#### 旧版 Chronocat\n\n对于旧版的 Chronocat，\n- `port` 是默认的 `16530`\n- `token` 被默认存储在 `%AppData%/BetterUniverse/QQNT/RED_PROTOCOL_TOKEN` 或 `~/BetterUniverse/QQNT/RED_PROTOCOL_TOKEN` 中，并保持不变。\n- `host` 默认为 `localhost`。\n\n\n## 功能\n\n支持的事件：\n- 群聊消息、好友消息 (能够接收到来着不同设备的自己的消息)\n- 群名称改动事件\n- 群成员禁言/解除禁言事件\n- 群成员加入事件 (包括旧版受邀请入群)\n\n支持的 api:\n- 发送消息 (文字，at，图片，文件，表情，引用回复)\n- 发送伪造合并转发 (文字，at，图片)\n- 获取自身资料\n- 获取好友、群组、群组内群员资料\n- 获取群公告\n- 禁言/解禁群员\n- 全体禁言\n- 获取历史消息\n- 获取媒体消息的原始数据\n\n完整的 api 文档请参考 [API 文档](api.md) 或 [QQNTRedProtocol](https://chrononeko.github.io/QQNTRedProtocol/http/)\n\n## 示例\n\n```python\nfrom pathlib import Path\n\nfrom nonebot import on_command\nfrom nonebot.adapters.red import Bot\nfrom nonebot.adapters.red.event import MessageEvent\nfrom nonebot.adapters.red.message import MessageSegment\n\n\nmatcher = on_command(\"test\")\n\n@matcher.handle()\nasync def handle_receive(bot: Bot, event: MessageEvent):\n    if event.is_group:\n        await bot.send_group_message(event.scene, MessageSegment.image(Path(\"path/to/img.jpg\")))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnonebot%2Fadapter-red","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnonebot%2Fadapter-red","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnonebot%2Fadapter-red/lists"}