feat: 在消息处理逻辑中添加合并转发功能,当记录条数超过 5 条时使用合并转发,提升用户体验

This commit is contained in:
lixiangwuxian 2025-05-04 23:24:44 +08:00
parent 5bb07950f6
commit 77a506917e
3 changed files with 25 additions and 1 deletions

View File

@ -86,7 +86,7 @@ func (am *actionManager) SendForward(reply *model.Reply) error {
if err != nil {
return err
}
log.Default().Printf("\033[32m↑\033[0m:%s", string(sendPkgJson))
log.Default().Printf("\033[32m↑\033[0m(forward):%s", string(sendPkgJson))
if err = am.botConn.WriteMessage(websocket.TextMessage, sendPkgJson); err != nil {
return err
}

View File

@ -7,6 +7,7 @@ import (
"strings"
"sync"
"git.lxtend.com/qqbot/action"
"git.lxtend.com/qqbot/constants"
"git.lxtend.com/qqbot/handler"
"git.lxtend.com/qqbot/message"
@ -284,6 +285,17 @@ func getMyRecentScore(msg model.Message) (reply *model.Reply) {
FromMsg: msg,
}
}
//如果消息行数太多,使用合并转发
if recordCount > 5 {
action.ActionManager.SendForward(
&model.Reply{
ReplyMsg: "玩家 " + userName + " 的" + strconv.Itoa(recordCount) + "条最近记录为:\n" + scoreMsg,
ReferOriginMsg: true,
FromMsg: msg,
},
)
return nil
}
return &model.Reply{
ReplyMsg: "玩家 " + userName + " 的" + strconv.Itoa(recordCount) + "条最近记录为:\n" + scoreMsg,
ReferOriginMsg: true,

View File

@ -7,6 +7,7 @@ import (
"strings"
"sync"
"git.lxtend.com/qqbot/action"
"git.lxtend.com/qqbot/constants"
"git.lxtend.com/qqbot/handler"
"git.lxtend.com/qqbot/message"
@ -297,6 +298,17 @@ func getMyRecentScore(msg model.Message) (reply *model.Reply) {
FromMsg: msg,
}
}
//如果消息行数太多,使用合并转发
if recordCount > 5 {
action.ActionManager.SendForward(
&model.Reply{
ReplyMsg: "玩家 " + userName + " 的" + strconv.Itoa(recordCount) + "条最近记录为:\n" + scoreMsg,
ReferOriginMsg: true,
FromMsg: msg,
},
)
return nil
}
return &model.Reply{
ReplyMsg: "玩家 " + userName + " 的" + strconv.Itoa(recordCount) + "条最近记录为:\n" + scoreMsg,
ReferOriginMsg: true,