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:
@@ -49,7 +49,7 @@ func handleWelcomeEvent(ctx context.Context, event protocol.Event, botManager *p
|
||||
zap.Any("user_id", userID))
|
||||
|
||||
// 获取操作者ID(邀请者或审批者)
|
||||
var operatorID interface{}
|
||||
var operatorID any
|
||||
if opID, exists := data["operator_id"]; exists {
|
||||
operatorID = opID
|
||||
}
|
||||
@@ -95,7 +95,7 @@ func handleWelcomeEvent(ctx context.Context, event protocol.Event, botManager *p
|
||||
|
||||
action := &protocol.BaseAction{
|
||||
Type: protocol.ActionTypeSendGroupMessage,
|
||||
Params: map[string]interface{}{
|
||||
Params: map[string]any{
|
||||
"group_id": groupID,
|
||||
"message": welcomeChain,
|
||||
},
|
||||
@@ -285,14 +285,14 @@ const welcomeTemplate = `
|
||||
`
|
||||
|
||||
// buildWelcomeMessage 构建欢迎消息链(使用HTML模板渲染图片)
|
||||
func buildWelcomeMessage(ctx context.Context, userID, operatorID interface{}, subType string, logger *zap.Logger) (protocol.MessageChain, error) {
|
||||
func buildWelcomeMessage(ctx context.Context, userID, operatorID any, subType string, logger *zap.Logger) (protocol.MessageChain, error) {
|
||||
logger.Debug("Starting to build welcome message",
|
||||
zap.Any("user_id", userID),
|
||||
zap.Any("operator_id", operatorID),
|
||||
zap.String("sub_type", subType))
|
||||
|
||||
// 准备模板数据
|
||||
data := map[string]interface{}{
|
||||
data := map[string]any{
|
||||
"UserID": fmt.Sprintf("%v", userID),
|
||||
}
|
||||
logger.Debug("Template data prepared", zap.Any("data", data))
|
||||
|
||||
Reference in New Issue
Block a user