Skip to content

配置说明

LinDream 框架的配置文件是 config.json,位于项目根目录下。以下是所有配置项的详细说明:

基本配置项

bot

  • platform: 机器人平台 (如: 'qq', 'discord', 'telegram')
  • account: 机器人账号
  • password: 机器人密码(如果需要)

server

  • host: 服务器监听地址
  • port: 服务器监听端口
  • debug: 是否开启调试模式

plugins

  • enabled: 启用的插件列表
  • path: 插件目录路径

security

  • enable_content_check: 是否启用内容审核
  • whitelist: 白名单用户列表
  • blacklist: 黑名单用户列表

详细配置说明

机器人平台配置

根据不同平台,需要配置相应的连接参数:

json
{
  "bot": {
    "platform": "qq",
    "account": "your_account",
    "token": "your_token"
  }
}

消息处理配置

json
{
  "message": {
    "enable_filter": true,
    "filter_keywords": ["关键词1", "关键词2"],
    "auto_reply": true
  }
}

AI 集成配置

json
{
  "ai": {
    "enable": true,
    "provider": "openai",
    "api_key": "your_api_key",
    "model": "gpt-3.5-turbo"
  }
}

数据库配置

json
{
  "database": {
    "type": "sqlite",
    "path": "./data/database.db",
    "host": "localhost",
    "port": 3306,
    "username": "user",
    "password": "password"
  }
}

示例配置文件

json
{
  "bot": {
    "platform": "qq",
    "account": "123456789",
    "token": "your_token_here"
  },
  "server": {
    "host": "0.0.0.0",
    "port": 8080,
    "debug": false
  },
  "plugins": {
    "enabled": ["echo", "help", "weather"],
    "path": "./plugins"
  },
  "security": {
    "enable_content_check": true,
    "whitelist": [123456789],
    "blacklist": []
  },
  "message": {
    "enable_filter": true,
    "filter_keywords": ["敏感词"],
    "auto_reply": true
  },
  "ai": {
    "enable": true,
    "provider": "openai",
    "api_key": "your_api_key_here",
    "model": "gpt-3.5-turbo"
  },
  "database": {
    "type": "sqlite",
    "path": "./data/database.db"
  }
}

配置文件加载顺序

  1. 默认配置
  2. config.json 文件
  3. 环境变量覆盖
  4. 命令行参数覆盖

注意事项

  • 修改配置文件后需要重启机器人以使配置生效
  • 配置文件使用 JSON 格式,请确保语法正确
  • 敏感信息如 API 密钥等建议通过环境变量配置

Released under the MIT License.