chore: update dependencies and improve bot configuration

- Upgrade Go version to 1.24.0 and update toolchain.
- Update various dependencies in go.mod and go.sum, including:
  - Upgrade `fasthttp/websocket` to v1.5.12
  - Upgrade `fsnotify/fsnotify` to v1.9.0
  - Upgrade `valyala/fasthttp` to v1.58.0
  - Add new dependencies for `bytedance/sonic` and `google/uuid`.
- Refactor bot configuration in config.toml to support multiple bot protocols, including "milky" and "onebot11".
- Modify internal configuration structures to accommodate new bot settings.
- Enhance event dispatcher with metrics tracking and asynchronous processing capabilities.
- Implement WebSocket connection management with heartbeat and reconnection logic.
- Update server handling for bot management and event publishing.
This commit is contained in:
lafay
2026-01-05 00:40:09 +08:00
parent ac0dfb64c9
commit 44fe05ff62
30 changed files with 6311 additions and 182 deletions

View File

@@ -14,6 +14,7 @@ type Config struct {
Server ServerConfig `toml:"server"`
Log LogConfig `toml:"log"`
Protocol ProtocolConfig `toml:"protocol"`
Bots []BotConfig `toml:"bots"`
}
// ServerConfig 服务器配置
@@ -38,6 +39,43 @@ type ProtocolConfig struct {
Options map[string]string `toml:"options"`
}
// BotConfig Bot 配置
type BotConfig struct {
ID string `toml:"id"`
Protocol string `toml:"protocol"`
Enabled bool `toml:"enabled"`
Milky MilkyConfig `toml:"milky"`
OneBot11 OneBot11Config `toml:"onebot11"`
}
// MilkyConfig Milky 协议配置
type MilkyConfig struct {
ProtocolURL string `toml:"protocol_url"`
AccessToken string `toml:"access_token"`
EventMode string `toml:"event_mode"`
WebhookListenAddr string `toml:"webhook_listen_addr"`
Timeout int `toml:"timeout"`
RetryCount int `toml:"retry_count"`
}
// OneBot11Config OneBot11 协议配置
type OneBot11Config struct {
ConnectionType string `toml:"connection_type"` // ws, ws-reverse, http, http-post
Host string `toml:"host"`
Port int `toml:"port"`
AccessToken string `toml:"access_token"`
WSUrl string `toml:"ws_url"` // 正向WS地址
WSReverseUrl string `toml:"ws_reverse_url"` // 反向WS监听地址
HTTPUrl string `toml:"http_url"` // 正向HTTP地址
HTTPPostUrl string `toml:"http_post_url"` // HTTP POST上报地址
Secret string `toml:"secret"` // 签名密钥
Timeout int `toml:"timeout"` // 超时时间(秒)
Heartbeat int `toml:"heartbeat"` // 心跳间隔(秒)
ReconnectInterval int `toml:"reconnect_interval"` // 重连间隔(秒)
SelfID string `toml:"self_id"` // 机器人QQ号
Nickname string `toml:"nickname"` // 机器人昵称
}
// ConfigManager 配置管理器
type ConfigManager struct {
configPath string