Overview
This guide helps you migrate between different versions of NapCat, covering breaking changes, deprecated features, and new functionality.Version Compatibility
Current Requirements
- NapCat Version: Always use the latest stable release
- NTQQ Version: Compatible with currently supported NTQQ versions
- Community Access: Requires NapCat >= 4.17.31 (join key valid for latest 100 versions)
Migration Checklist
Before updating:-
Backup your configuration
-
Review release notes
- Check GitHub Releases for changes
- Look for breaking changes
- Note deprecated features
-
Test in development
- Test the new version in a dev environment first
- Verify all network adapters work
- Test critical API calls
-
Update incrementally
- Don’t skip major versions
- Update one major version at a time if possible
Configuration Changes
Network Configuration Structure
The network configuration uses a consistent structure across all adapter types:Required Fields
Ensure all network adapters include required fields:Token Configuration
Tokens are now consistently namedtoken across all adapters:
Heartbeat Configuration
WebSocket heartbeat intervals are now in milliseconds:API Changes
Response Format
All API responses follow the OneBot 11 standard:Error Codes
Standardized error codes:| Code | Meaning |
|---|---|
| 0 | Success |
| 1400 | Invalid JSON |
| 1403 | Authentication failed |
| 1404 | API not found |
| 200 | Generic error |
Message Format
Message format options:"array"- OneBot 11 message segment array (recommended)"string"- CQ code format string
Network Adapter Changes
HTTP Server
New Configuration:- Added
enableWebsocketoption to enable WebSocket on same port - Supports request bodies up to 5000MB (previously limited)
- Improved JSON5 parsing support
WebSocket Server
New Configuration:heartIntervalnow in milliseconds- Added
enableForcePushEventoption - Maximum payload size: 50MB
WebSocket Client (Reverse)
New Configuration:- Added automatic reconnection
reconnectIntervalconfigurable (default: 5000ms)- Sends
X-Self-IDheader - Sends
x-client-role: Universalfor Koishi compatibility
HTTP Client (Webhook)
New Configuration:- HMAC-SHA1 signature in
X-Signatureheader - Sends
X-Self-IDheader - Supports quick action responses
Authentication Changes
Token Authentication
All adapters now support consistent token authentication: Authorization Header:Signature Verification
Webhook requests include HMAC signature:X-Signature header to verify authenticity.
Deprecated Features
Legacy Configuration Format
Old flat configuration format is deprecated. Use the structured format: Old (Deprecated):Single Network Adapter
Multiple adapters of the same type are now supported:New Features
HTTP Server WebSocket Support
HTTP servers can now handle WebSocket connections on the same port:/- Event WebSocket/api- API WebSocket
JSON5 Support
All parsers now support JSON5 syntax:Debug Mode
Each adapter can enable debug logging:Report Self Message
Control whether bot’s own messages are reported:Breaking Changes by Version
Version 4.x
Configuration Structure- Network configuration moved to
networkobject - Adapters now in typed arrays (httpServers, websocketServers, etc.)
- Each adapter requires unique
namefield
- Standardized token field name
- HMAC signature for webhooks
- Token sent in Authorization header for reverse WebSocket
- Response format strictly follows OneBot 11
- Error codes standardized
- Echo parameter handling improved
Version 3.x to 4.x
If migrating from version 3.x:-
Update configuration structure
-
Update authentication code
- Check for Authorization header
- Verify HMAC signatures for webhooks
-
Update API response handling
- Parse
retcodeinstead ofstatus - Handle new error codes
- Parse
-
Update WebSocket connection logic
- Handle lifecycle events
- Update heartbeat handling
- Handle reconnection events
Common Migration Issues
Configuration Not Loading
Symptom: Changes have no effect Solution:- Validate JSON syntax
- Check file location
- Restart NapCat completely
- Check logs for parsing errors
Authentication Failures
Symptom: 403 errors or connection rejected Solution:- Update token field name to
token - Update authentication header format
- Verify token matches in config and client
WebSocket Connection Issues
Symptom: WebSocket won’t connect Solution:- Update connection URL format
- Update authentication method
- Handle new lifecycle events
- Update heartbeat interval (now in milliseconds)
Missing Events
Symptom: Events not received after update Solution:- Check
reportSelfMessagesetting - Verify adapter is enabled
- Connect to correct endpoint (
/for events) - Check message format setting
Testing After Migration
Basic Connectivity
WebSocket Connection
Send Test Message
Webhook Testing
Rollback Plan
If migration fails:-
Stop NapCat
-
Restore backup
-
Reinstall previous version
- Download previous release
- Replace with backed-up version
-
Restart
Getting Help
If you encounter issues during migration:- Check Troubleshooting Guide
- Review GitHub Issues
- Join Community Groups
- Check FAQ
- Current NapCat version
- Previous NapCat version
- Configuration file (remove sensitive tokens)
- Error messages from logs
- Steps you’ve already tried
Next Steps
- Review Configuration Guide
- Check API Documentation
- Read Best Practices
- Join the Community
