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:
36
internal/adapter/onebot11/bot.go
Normal file
36
internal/adapter/onebot11/bot.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package onebot11
|
||||
|
||||
import (
|
||||
"cellbot/internal/engine"
|
||||
"cellbot/internal/protocol"
|
||||
"cellbot/pkg/net"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// Bot OneBot11机器人实例
|
||||
type Bot struct {
|
||||
*protocol.BaseBotInstance
|
||||
adapter *Adapter
|
||||
}
|
||||
|
||||
// NewBot 创建OneBot11机器人实例
|
||||
func NewBot(id string, config *Config, logger *zap.Logger, wsManager *net.WebSocketManager, eventBus *engine.EventBus) *Bot {
|
||||
adapter := NewAdapter(config, logger, wsManager, eventBus)
|
||||
baseBot := protocol.NewBaseBotInstance(id, adapter, logger)
|
||||
|
||||
return &Bot{
|
||||
BaseBotInstance: baseBot,
|
||||
adapter: adapter,
|
||||
}
|
||||
}
|
||||
|
||||
// GetAdapter 获取适配器
|
||||
func (b *Bot) GetAdapter() *Adapter {
|
||||
return b.adapter
|
||||
}
|
||||
|
||||
// GetConfig 获取配置
|
||||
func (b *Bot) GetConfig() *Config {
|
||||
return b.adapter.config
|
||||
}
|
||||
Reference in New Issue
Block a user