How qiannqq/napcat-adapter works
NapCat-Adapter bridges Miao-Yunzai plugins to a NapCat OneBot connection. Startup loads configuration and initializes adapter instances; the adapter exchanges events and message/API operations with NapCat while exposing Yunzai-compatible bot behavior. Message normalization, media handling, and the Guoba settings interface are distinct capabilities. The adapter source is only excerpted, so some detailed routing and conversion links are supported by README claims rather than inspected call sites.
Main entry points: index.js Plugin entry · adapter/index.js Adapter lifecycle · common.js Message conversion · cfg.js Config loader
Components 18
Startup and config
- Plugin entry
index.js - Config loader
lib/utils/cfg.js - Config files
config
Protocol bridge
- Adapter lifecycle
adapter/index.js - NapCat client
adapter/index.js - Event translation
adapter/index.js - Message conversion
lib/utils/common.js - Media handling
lib/utils/common.js - Face dictionaries
lib/face.js - Protobuf support
lib/utils/protobuf.js - Bot operations
adapter/index.js
Yunzai compatibility
- Bot compatibility
lib/bot.js - UIN adaptation
lib/uin.js - Bridge utilities
lib/utils/common.js
Configuration UI
- Guoba settings
guoba.support.js - Update command
other/u.js
Other components
- Yunzai host
- NapCat OneBot
Connections 21
- Yunzai host → Plugin entry: loads plugin
README.md - Plugin entry → Config loader: loads config
index.js - Config loader → Config files: reads defaults
lib/utils/cfg.js - Plugin entry → Adapter lifecycle: creates and initializes
index.js - Adapter lifecycle → NapCat client: constructs
adapter/index.js - NapCat client → NapCat OneBot: connects
README.md - Adapter lifecycle → Event translation: translates events
adapter/index.js - NapCat OneBot → Event translation: sends events
README.md - Event translation → Yunzai host: dispatches events
README.md - Adapter lifecycle → Bridge utilities: uses utilities
adapter/index.js - Bridge utilities → Message conversion: converts messages
lib/utils/common.js - Message conversion → Media handling: resolves media
lib/utils/common.js - Message conversion → Face dictionaries: uses dictionaries
lib/index.js - Adapter lifecycle → Bot operations: exposes operations
README.md - Bot operations → NapCat OneBot: invokes OneBot APIs
README.md - Plugin entry → Bot compatibility: loads compatibility layer
- Bot compatibility → Bot operations: delegates bot calls
lib/bot.js - Plugin entry → UIN adaptation: adapts account identity
- Yunzai host → Guoba settings: configures adapter
guoba.support.js - Guoba settings → Config files: reads and writes
guoba.support.js - Yunzai host → Update command: invokes update command