Skip to main content

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:
  1. Backup your configuration
  2. Review release notes
    • Check GitHub Releases for changes
    • Look for breaking changes
    • Note deprecated features
  3. Test in development
    • Test the new version in a dev environment first
    • Verify all network adapters work
    • Test critical API calls
  4. 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 named token across all adapters:

Heartbeat Configuration

WebSocket heartbeat intervals are now in milliseconds:
Previously this may have been in seconds in some configurations.

API Changes

Response Format

All API responses follow the OneBot 11 standard:

Error Codes

Standardized error codes:

Message Format

Message format options:
  • "array" - OneBot 11 message segment array (recommended)
  • "string" - CQ code format string

Network Adapter Changes

HTTP Server

New Configuration:
Changes:
  • Added enableWebsocket option to enable WebSocket on same port
  • Supports request bodies up to 5000MB (previously limited)
  • Improved JSON5 parsing support

WebSocket Server

New Configuration:
Changes:
  • heartInterval now in milliseconds
  • Added enableForcePushEvent option
  • Maximum payload size: 50MB

WebSocket Client (Reverse)

New Configuration:
Changes:
  • Added automatic reconnection
  • reconnectInterval configurable (default: 5000ms)
  • Sends X-Self-ID header
  • Sends x-client-role: Universal for Koishi compatibility

HTTP Client (Webhook)

New Configuration:
Changes:
  • HMAC-SHA1 signature in X-Signature header
  • Sends X-Self-ID header
  • Supports quick action responses

Authentication Changes

Token Authentication

All adapters now support consistent token authentication: Authorization Header:
Query Parameter:
WebSocket URL:

Signature Verification

Webhook requests include HMAC signature:
Check the X-Signature header to verify authenticity.

Deprecated Features

Legacy Configuration Format

Old flat configuration format is deprecated. Use the structured format: Old (Deprecated):
New:

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:
Connect to:
  • / - 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 network object
  • Adapters now in typed arrays (httpServers, websocketServers, etc.)
  • Each adapter requires unique name field
Authentication
  • Standardized token field name
  • HMAC signature for webhooks
  • Token sent in Authorization header for reverse WebSocket
API Changes
  • 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:
  1. Update configuration structure
  2. Update authentication code
    • Check for Authorization header
    • Verify HMAC signatures for webhooks
  3. Update API response handling
    • Parse retcode instead of status
    • Handle new error codes
  4. 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:
  1. Validate JSON syntax
  2. Check file location
  3. Restart NapCat completely
  4. Check logs for parsing errors

Authentication Failures

Symptom: 403 errors or connection rejected Solution:
  1. Update token field name to token
  2. Update authentication header format
  3. Verify token matches in config and client

WebSocket Connection Issues

Symptom: WebSocket won’t connect Solution:
  1. Update connection URL format
  2. Update authentication method
  3. Handle new lifecycle events
  4. Update heartbeat interval (now in milliseconds)

Missing Events

Symptom: Events not received after update Solution:
  1. Check reportSelfMessage setting
  2. Verify adapter is enabled
  3. Connect to correct endpoint (/ for events)
  4. Check message format setting

Testing After Migration

Basic Connectivity

WebSocket Connection

Send Test Message

Webhook Testing

Rollback Plan

If migration fails:
  1. Stop NapCat
  2. Restore backup
  3. Reinstall previous version
    • Download previous release
    • Replace with backed-up version
  4. Restart

Getting Help

If you encounter issues during migration:
  1. Check Troubleshooting Guide
  2. Review GitHub Issues
  3. Join Community Groups
  4. Check FAQ
When asking for help, provide:
  • Current NapCat version
  • Previous NapCat version
  • Configuration file (remove sensitive tokens)
  • Error messages from logs
  • Steps you’ve already tried

Next Steps