37 lines
764 B
Go
37 lines
764 B
Go
|
|
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
|
||
|
|
}
|