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:
@@ -82,16 +82,16 @@ func ConvertAction(action protocol.Action) string {
|
||||
|
||||
// SendPrivateMessageAction 发送私聊消息动作
|
||||
type SendPrivateMessageAction struct {
|
||||
UserID int64 `json:"user_id"`
|
||||
Message interface{} `json:"message"`
|
||||
AutoEscape bool `json:"auto_escape,omitempty"`
|
||||
UserID int64 `json:"user_id"`
|
||||
Message any `json:"message"`
|
||||
AutoEscape bool `json:"auto_escape,omitempty"`
|
||||
}
|
||||
|
||||
// SendGroupMessageAction 发送群消息动作
|
||||
type SendGroupMessageAction struct {
|
||||
GroupID int64 `json:"group_id"`
|
||||
Message interface{} `json:"message"`
|
||||
AutoEscape bool `json:"auto_escape,omitempty"`
|
||||
GroupID int64 `json:"group_id"`
|
||||
Message any `json:"message"`
|
||||
AutoEscape bool `json:"auto_escape,omitempty"`
|
||||
}
|
||||
|
||||
// DeleteMessageAction 撤回消息动作
|
||||
@@ -224,12 +224,12 @@ type SetRestartAction struct {
|
||||
|
||||
// ActionResponse API响应
|
||||
type ActionResponse struct {
|
||||
Status string `json:"status"`
|
||||
RetCode int `json:"retcode"`
|
||||
Data map[string]interface{} `json:"data,omitempty"`
|
||||
Echo string `json:"echo,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Wording string `json:"wording,omitempty"`
|
||||
Status string `json:"status"`
|
||||
RetCode int `json:"retcode"`
|
||||
Data map[string]any `json:"data,omitempty"`
|
||||
Echo string `json:"echo,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Wording string `json:"wording,omitempty"`
|
||||
}
|
||||
|
||||
// 响应状态码常量
|
||||
@@ -245,7 +245,7 @@ const (
|
||||
)
|
||||
|
||||
// BuildActionRequest 构建动作请求
|
||||
func BuildActionRequest(action string, params map[string]interface{}, echo string) *OB11Action {
|
||||
func BuildActionRequest(action string, params map[string]any, echo string) *OB11Action {
|
||||
return &OB11Action{
|
||||
Action: action,
|
||||
Params: params,
|
||||
@@ -254,8 +254,8 @@ func BuildActionRequest(action string, params map[string]interface{}, echo strin
|
||||
}
|
||||
|
||||
// BuildSendPrivateMsg 构建发送私聊消息请求
|
||||
func BuildSendPrivateMsg(userID int64, message interface{}, autoEscape bool) map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
func BuildSendPrivateMsg(userID int64, message any, autoEscape bool) map[string]any {
|
||||
return map[string]any{
|
||||
"user_id": userID,
|
||||
"message": message,
|
||||
"auto_escape": autoEscape,
|
||||
@@ -263,8 +263,8 @@ func BuildSendPrivateMsg(userID int64, message interface{}, autoEscape bool) map
|
||||
}
|
||||
|
||||
// BuildSendGroupMsg 构建发送群消息请求
|
||||
func BuildSendGroupMsg(groupID int64, message interface{}, autoEscape bool) map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
func BuildSendGroupMsg(groupID int64, message any, autoEscape bool) map[string]any {
|
||||
return map[string]any{
|
||||
"group_id": groupID,
|
||||
"message": message,
|
||||
"auto_escape": autoEscape,
|
||||
@@ -272,15 +272,15 @@ func BuildSendGroupMsg(groupID int64, message interface{}, autoEscape bool) map[
|
||||
}
|
||||
|
||||
// BuildDeleteMsg 构建撤回消息请求
|
||||
func BuildDeleteMsg(messageID int32) map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
func BuildDeleteMsg(messageID int32) map[string]any {
|
||||
return map[string]any{
|
||||
"message_id": messageID,
|
||||
}
|
||||
}
|
||||
|
||||
// BuildSetGroupBan 构建群组禁言请求
|
||||
func BuildSetGroupBan(groupID, userID int64, duration int64) map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
func BuildSetGroupBan(groupID, userID int64, duration int64) map[string]any {
|
||||
return map[string]any{
|
||||
"group_id": groupID,
|
||||
"user_id": userID,
|
||||
"duration": duration,
|
||||
@@ -288,8 +288,8 @@ func BuildSetGroupBan(groupID, userID int64, duration int64) map[string]interfac
|
||||
}
|
||||
|
||||
// BuildSetGroupKick 构建群组踢人请求
|
||||
func BuildSetGroupKick(groupID, userID int64, rejectAddRequest bool) map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
func BuildSetGroupKick(groupID, userID int64, rejectAddRequest bool) map[string]any {
|
||||
return map[string]any{
|
||||
"group_id": groupID,
|
||||
"user_id": userID,
|
||||
"reject_add_request": rejectAddRequest,
|
||||
@@ -297,8 +297,8 @@ func BuildSetGroupKick(groupID, userID int64, rejectAddRequest bool) map[string]
|
||||
}
|
||||
|
||||
// BuildSetGroupCard 构建设置群名片请求
|
||||
func BuildSetGroupCard(groupID, userID int64, card string) map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
func BuildSetGroupCard(groupID, userID int64, card string) map[string]any {
|
||||
return map[string]any{
|
||||
"group_id": groupID,
|
||||
"user_id": userID,
|
||||
"card": card,
|
||||
|
||||
Reference in New Issue
Block a user