Framework Configuration
NekoBot's core framework configuration defines the basic behavior and functionality of the system.
Configuration File Structure
Framework configuration is located at the root level of data/config.json and includes the following main sections:
json
{
"framework_config": {
"web_host": "0.0.0.0",
"web_port": 6285,
"log_level": "INFO",
"timezone": "Asia/Shanghai",
"enable_webui": true,
"api_flavor": "chat_completions"
},
"permission_config": {
"admin_users": ["12345678"],
"whitelist_groups": []
},
"moderation_config": {
"enable": false,
"keywords": []
},
"conversation_config": {
"max_history_len": 50,
"persistence_driver": "sqlite",
"auto_summary_threshold": 20
}
}Framework Configuration (framework_config)
Controls the behavior of NekoBot's core framework.
| Setting | Type | Default | Description |
|---|---|---|---|
web_host | string | "0.0.0.0" | Web UI listening address |
web_port | integer | 6285 | Web UI listening port |
log_level | string | "INFO" | Log level: DEBUG, INFO, WARNING, ERROR |
timezone | string | "Asia/Shanghai" | System timezone |
enable_webui | boolean | true | Whether to enable Web management interface |
api_flavor | string | "chat_completions" | API flavor: "chat_completions" (OpenAI compatible) or "anthropic" |
Log Level Explanation
DEBUG: Most detailed logs, for debuggingINFO: General information, records normal operation statusWARNING: Warning messages, doesn't affect operation but needs attentionERROR: Error messages, requires immediate handling
Permission Configuration (permission_config)
Controls access permissions for users and groups.
| Setting | Type | Default | Description |
|---|---|---|---|
admin_users | array | [] | List of administrator user IDs |
whitelist_groups | array | [] | List of whitelisted group IDs |
Permission Rules
- Administrator Users: Have all permissions, can execute administrative commands
- Whitelisted Groups: Only groups in the whitelist can trigger bot responses
- Blacklist: No independent configuration yet, can be implemented via plugins
Example Configuration
json
{
"permission_config": {
"admin_users": ["12345678", "87654321"],
"whitelist_groups": ["10001", "10002"]
}
}Moderation Configuration (moderation_config)
Provides basic content moderation functionality.
| Setting | Type | Default | Description |
|---|---|---|---|
enable | boolean | false | Whether to enable content moderation |
keywords | array | [] | List of sensitive keywords |
Moderation Rules
- When
enableistrue, the system checks if messages contain sensitive keywords - Messages matching keywords will be intercepted and won't trigger plugin responses
- Keyword matching supports simple string matching
Example Configuration
json
{
"moderation_config": {
"enable": true,
"keywords": ["sensitive_word1", "sensitive_word2", "banned_word"]
}
}Conversation Configuration (conversation_config)
Controls dialogue history management and persistence.
| Setting | Type | Default | Description |
|---|---|---|---|
max_history_len | integer | 50 | Maximum history entries (user+assistant message pairs) |
persistence_driver | string | "sqlite" | Persistence driver: "sqlite" or "memory" |
auto_summary_threshold | integer | 20 | Auto-summary threshold (triggers summary when history exceeds this value) |
Conversation Management Features
1. History Management
- System automatically maintains conversation history
- Old messages are compressed or removed when exceeding
max_history_lenlimit - Supports conversation context preservation
2. Automatic Summarization
- Triggered when history length exceeds
auto_summary_threshold - Uses LLM to generate conversation summaries
- Summaries maintain long-term context, reducing token consumption
3. Persistence Storage
- SQLite: Conversation history stored in
data/conversations.sqlite3 - Memory: Memory-only storage, lost after restart
Example Configuration
json
{
"conversation_config": {
"max_history_len": 100,
"persistence_driver": "sqlite",
"auto_summary_threshold": 30
}
}Advanced Configuration
Database Configuration
To use an external database, add database configuration to framework_config:
json
{
"framework_config": {
"database": {
"url": "postgresql://user:password@localhost/nekobot",
"pool_size": 10
}
}
}Cache Configuration
json
{
"framework_config": {
"cache": {
"type": "redis",
"url": "redis://localhost:6379/0",
"ttl": 3600
}
}
}Configuration Priority
- Environment Variables: Highest priority, overrides configuration file
- Configuration File: Settings in
data/config.json - Default Values: Framework's built-in defaults
Environment Variable Overrides
Some configurations can be overridden by environment variables:
NEKOBOT_HOST: Overridesweb_hostNEKOBOT_PORT: Overridesweb_portNEKOBOT_WEBUI: Overridesenable_webui
Configuration Validation
The system automatically validates configuration integrity at startup:
- Checks if required fields exist
- Verifies field types are correct
- Automatically completes missing configuration items
- Generates configuration backup files
Troubleshooting
Configuration Not Taking Effect
- Check if the configuration file path is correct
- Confirm the file format is valid JSON
- Check configuration loading information in startup logs
Permission Issues
- Ensure configuration file has correct read/write permissions
- Check database file permissions (if using SQLite)
Performance Issues
- Adjust
max_history_lento reduce memory usage - Consider using external database to improve performance
- Adjust log level to reduce I/O overhead
Next Steps
- Platform Configuration - Configure chat platform connections
- LLM Provider Configuration - Configure AI services
- Plugin Development - Extend functionality