fix: 在 MsgInHandler 中添加对 StructuredMsg 长度的检查,避免潜在的数组越界错误;更新 PlayerDataLite 结构体,添加 Gorm 标签以支持数据库映射
This commit is contained in:
parent
c50ca47911
commit
5ce7f7bba4
@ -119,7 +119,7 @@ func MsgInHandler(msg model.Message) (reply *model.Reply) {
|
||||
return reply
|
||||
}
|
||||
}
|
||||
if msg.StructuredMsg[0].GetMessageType() == qq_message.TypeAt {
|
||||
if len(msg.StructuredMsg) > 0 && msg.StructuredMsg[0].GetMessageType() == qq_message.TypeAt {
|
||||
if atMsg, ok := msg.StructuredMsg[0].(*qq_message.AtMessage); ok {
|
||||
atUserID := atMsg.Data.QQ
|
||||
loginAccountInfo, err := action.GetLoginAccountInfo()
|
||||
|
@ -203,21 +203,21 @@ type PlayerData struct {
|
||||
}
|
||||
|
||||
type PlayerDataLite struct {
|
||||
ID string `json:"id" db:"id"`
|
||||
Name string `json:"name" db:"name"`
|
||||
ProfilePicture string `json:"profilePicture" db:"profile_picture"`
|
||||
Country string `json:"country" db:"country"`
|
||||
Device string `json:"device" db:"device"`
|
||||
PP float64 `json:"pp" db:"pp"`
|
||||
Rank int `json:"rank" db:"rank"`
|
||||
CountryRank int `json:"countryRank" db:"country_rank"`
|
||||
TotalScore int `json:"totalScore" db:"total_score"`
|
||||
TotalRankedScore int `json:"totalRankedScore" db:"total_ranked_score"`
|
||||
AverageRankedAccuracy float64 `json:"averageRankedAccuracy" db:"average_ranked_accuracy"`
|
||||
TotalPlayCount int `json:"totalPlayCount" db:"total_play_count"`
|
||||
RankedPlayCount int `json:"rankedPlayCount" db:"ranked_play_count"`
|
||||
ReplaysWatched int `json:"replaysWatched" db:"replays_watched"`
|
||||
GeneratedTime string `json:"generatedTime" db:"generated_time"`
|
||||
ID string `json:"id" db:"id" gorm:"column:id"`
|
||||
Name string `json:"name" db:"name" gorm:"column:name"`
|
||||
ProfilePicture string `json:"profilePicture" db:"profile_picture" gorm:"column:profile_picture"`
|
||||
Country string `json:"country" db:"country" gorm:"column:country"`
|
||||
Device string `json:"device" db:"device" gorm:"column:device"`
|
||||
PP float64 `json:"pp" db:"pp" gorm:"column:pp"`
|
||||
Rank int `json:"rank" db:"rank" gorm:"column:rank"`
|
||||
CountryRank int `json:"countryRank" db:"country_rank" gorm:"column:country_rank"`
|
||||
TotalScore int `json:"totalScore" db:"total_score" gorm:"column:total_score"`
|
||||
TotalRankedScore int `json:"totalRankedScore" db:"total_ranked_score" gorm:"column:total_ranked_score"`
|
||||
AverageRankedAccuracy float64 `json:"averageRankedAccuracy" db:"average_ranked_accuracy" gorm:"column:average_ranked_accuracy"`
|
||||
TotalPlayCount int `json:"totalPlayCount" db:"total_play_count" gorm:"column:total_play_count"`
|
||||
RankedPlayCount int `json:"rankedPlayCount" db:"ranked_play_count" gorm:"column:ranked_play_count"`
|
||||
ReplaysWatched int `json:"replaysWatched" db:"replays_watched" gorm:"column:replays_watched"`
|
||||
GeneratedTime string `json:"generatedTime" db:"generated_time" gorm:"column:generated_time"`
|
||||
}
|
||||
|
||||
func (p PlayerDataLite) IsDiffFrom(p2 PlayerDataLite) bool {
|
||||
|
Loading…
x
Reference in New Issue
Block a user