feat: 在消息处理逻辑中完善合并转发功能,确保用户信息完整并提升消息发送的准确性

This commit is contained in:
lixiangwuxian 2025-05-04 23:27:57 +08:00
parent 77a506917e
commit a8713b6005
2 changed files with 40 additions and 4 deletions

View File

@ -287,10 +287,28 @@ func getMyRecentScore(msg model.Message) (reply *model.Reply) {
}
//如果消息行数太多,使用合并转发
if recordCount > 5 {
textMsg := message.TextMessage{
Type: "text",
Data: message.TextMessageData{
Text: "玩家 " + userName + " 的" + strconv.Itoa(recordCount) + "条最近记录为:\n" + scoreMsg,
},
}
nodeMsg := message.NewNodeMessage()
loginAccountInfo, err := action.GetLoginAccountInfo()
if err != nil {
log.Println("GetLoginAccountInfo error:", err)
return nil
}
if loginAccountInfo == nil {
return nil
}
nodeMsg.Data.UserID = strconv.FormatInt(int64(loginAccountInfo.Data.UserID), 10)
nodeMsg.Data.Nickname = loginAccountInfo.Data.Nickname
nodeMsg.Data.Content = []any{&textMsg}
action.ActionManager.SendForward(
&model.Reply{
ReplyMsg: "玩家 " + userName + " 的" + strconv.Itoa(recordCount) + "条最近记录为:\n" + scoreMsg,
ReferOriginMsg: true,
ReplyMsg: []any{&nodeMsg},
ReferOriginMsg: false,
FromMsg: msg,
},
)

View File

@ -300,10 +300,28 @@ func getMyRecentScore(msg model.Message) (reply *model.Reply) {
}
//如果消息行数太多,使用合并转发
if recordCount > 5 {
textMsg := message.TextMessage{
Type: "text",
Data: message.TextMessageData{
Text: "玩家 " + userName + " 的" + strconv.Itoa(recordCount) + "条最近记录为:\n" + scoreMsg,
},
}
nodeMsg := message.NewNodeMessage()
loginAccountInfo, err := action.GetLoginAccountInfo()
if err != nil {
log.Println("GetLoginAccountInfo error:", err)
return nil
}
if loginAccountInfo == nil {
return nil
}
nodeMsg.Data.UserID = strconv.FormatInt(int64(loginAccountInfo.Data.UserID), 10)
nodeMsg.Data.Nickname = loginAccountInfo.Data.Nickname
nodeMsg.Data.Content = []any{&textMsg}
action.ActionManager.SendForward(
&model.Reply{
ReplyMsg: "玩家 " + userName + " 的" + strconv.Itoa(recordCount) + "条最近记录为:\n" + scoreMsg,
ReferOriginMsg: true,
ReplyMsg: []any{&nodeMsg},
ReferOriginMsg: false,
FromMsg: msg,
},
)