Documentation Sync
This page is auto-generated from plugins/adapters/onebot11/README.md. Please edit the in-package README and then run pnpm sync:adapter-docs.
@zhin.js/adapter-onebot11
Zhin.js OneBot 11 adapter (Plugin Runtime). The production path is a forward WebSocket client (connection: ws); reverse WS is also supported (connection: wss, via httpHostToken).
Features
- OneBot 11 Standard compatible (events + actions)
- Convention-based
defineAdapter/definePlugin(nousePluginneeded) - Forward WebSocket (
connection: ws): the application connects to the OneBot implementation's WS server access_tokenauthentication (Bearer + query)- Inbound via
messageGatewayToken; outboundsend({ target, payload })
Installation
bash
pnpm add @zhin.js/adapter-onebot11Plugin Runtime
@zhin.js/adapter— convention-basedadapters/onebot11.ts(defineAdapter)@zhin.js/core—messageGatewayTokeninbound/outbound@zhin.js/plugin-runtime—plugin.ts(definePlugin)- Configuration goes to
plugins.<instanceKey>via the plugin'sschema.json
Inbound: gateway.receive({ adapter, target: "private:uid"|"group:gid", content, sender, metadata }) Outbound: send({ target, payload }) -> WS send_private_msg / send_group_msg (payload is rendered by gateway/core; no segment-mapper)
Minimal Configuration
yaml
# zhin.config.yml (Plugin Runtime)
plugins:
onebot11:
connection: ws
reconnect_interval: 5000
heartbeat_interval: 30000
endpoints:
- name: ob11-bot
url: "ws://127.0.0.1:6700"
access_token: "${ONEBOT11_ACCESS_TOKEN}"The root plugin zhin.plugins (or project graph) must reference @zhin.js/adapter-onebot11 (instanceKey: onebot11).
Connection Modes
| connection | Status |
|---|---|
ws | Implemented (recommended) |
wss | Implemented: reverse WS (httpHostToken) |
Authentication
- Bearer:
Authorization: Bearer <access_token> - Forward WS attaches request headers during Upgrade and includes
access_tokenin the URL query
Actions and Events
- Events:
post_type(message/notice/request/meta_event),message_type,message, etc. - Actions:
send_private_msg,send_group_msg,delete_msg,set_group_special_title, etc.
AI Tools
| Category | Path |
|---|---|
| Permit vocabulary | agent/PERMITS.md |
| Platform tools | agent/tools/set_title.ts -> onebot11_set_title |
| Skill documentation | agent/skills/onebot11.md |
Migration Notes (Plugin Runtime)
- Notice / request side events have been removed: the old Adapter built
notice.receive/request.receiveevents forpost_type: notice|request; the new Plugin Runtime (messageGatewayToken) has no side-event bus yet — inbound only processespost_type: message, and notice / request events are silently discarded. - Group management tools have not been migrated yet: the old Adapter registered a full set of agent tools (kick/mute/group card, etc.) via
createSceneManagementTools; after migration, onlyonebot11_set_titleis retained. Other group management capabilities can be invoked viacallApi(e.g.,set_group_kick,set_group_ban) as an escape hatch. - Platform permission access control:
plugin.tssetup has registeredregisterDefaultScenePlatformPermitChecker('onebot11').scene_admin/scene_ownerare determined based on the sender'srole(owner / admin) in the inbound metadata.
Documentation Links
License
MIT License