refactor: modernize codebase for Go 1.26 and fix adapter issues

- Upgrade Go version from 1.24 to 1.26.1 with updated dependencies
- Replace interface{} with any type throughout codebase
- Add message deduplication in OneBot11 adapter to prevent duplicate event processing
- URL-encode access token in WebSocket connections to handle special characters
- Remove duplicate bot startup hooks in DI providers (now handled by botManager.StartAll)
- Use slices.Clone and errgroup.Go patterns for cleaner concurrent code
- Apply omitzero JSON tags for optional fields (Go 1.24+ feature)
This commit is contained in:
lafay
2026-03-18 01:22:49 +08:00
parent f3a72264af
commit f3220a2381
32 changed files with 2262 additions and 296 deletions

View File

@@ -6,9 +6,9 @@ type Action interface {
// GetType 获取动作类型
GetType() ActionType
// GetParams 获取动作参数
GetParams() map[string]interface{}
GetParams() map[string]any
// Execute 执行动作
Execute(ctx interface{}) (map[string]interface{}, error)
Execute(ctx any) (map[string]any, error)
}
// ActionType 动作类型
@@ -27,20 +27,20 @@ const (
ActionTypeGetGroupMemberList ActionType = "get_group_member_list"
// 群组相关动作
ActionTypeSetGroupKick ActionType = "set_group_kick"
ActionTypeSetGroupBan ActionType = "set_group_ban"
ActionTypeSetGroupAdmin ActionType = "set_group_admin"
ActionTypeSetGroupWholeBan ActionType = "set_group_whole_ban"
ActionTypeSetGroupKick ActionType = "set_group_kick"
ActionTypeSetGroupBan ActionType = "set_group_ban"
ActionTypeSetGroupAdmin ActionType = "set_group_admin"
ActionTypeSetGroupWholeBan ActionType = "set_group_whole_ban"
// 其他动作
ActionTypeGetStatus ActionType = "get_status"
ActionTypeGetVersion ActionType = "get_version"
ActionTypeGetStatus ActionType = "get_status"
ActionTypeGetVersion ActionType = "get_version"
)
// BaseAction 基础动作结构
type BaseAction struct {
Type ActionType `json:"type"`
Params map[string]interface{} `json:"params"`
Type ActionType `json:"type"`
Params map[string]any `json:"params"`
}
// GetType 获取动作类型
@@ -49,19 +49,19 @@ func (a *BaseAction) GetType() ActionType {
}
// GetParams 获取动作参数
func (a *BaseAction) GetParams() map[string]interface{} {
func (a *BaseAction) GetParams() map[string]any {
return a.Params
}
// Execute 执行动作(需子类实现)
func (a *BaseAction) Execute(ctx interface{}) (map[string]interface{}, error) {
func (a *BaseAction) Execute(ctx any) (map[string]any, error) {
return nil, ErrNotImplemented
}
// SendPrivateMessageAction 发送私聊消息动作
type SendPrivateMessageAction struct {
BaseAction
UserID string `json:"user_id"`
UserID string `json:"user_id"`
Message string `json:"message"`
}