refactor: 修改 NewSelfNodeMessage 函数以接受内容参数,并更新消息处理逻辑以简化代码结构

This commit is contained in:
lixiangwuxian
2025-05-05 02:02:14 +08:00
parent b55d1f24b8
commit 2eb0d5de20
3 changed files with 6 additions and 10 deletions

View File

@@ -8,7 +8,7 @@ import (
"git.lxtend.com/qqbot/message"
)
func NewSelfNodeMessage() *message.NodeMessage {
func NewSelfNodeMessage(content ...any) *message.NodeMessage {
loginAccountInfo, err := action.GetLoginAccountInfo()
if err != nil {
log.Println("GetLoginAccountInfo error:", err)
@@ -17,5 +17,5 @@ func NewSelfNodeMessage() *message.NodeMessage {
if loginAccountInfo == nil {
return nil
}
return &message.NodeMessage{Type: message.TypeNode, Data: message.NodeMessageData{UserID: strconv.FormatInt(int64(loginAccountInfo.Data.UserID), 10), Nickname: loginAccountInfo.Data.Nickname}}
return &message.NodeMessage{Type: message.TypeNode, Data: message.NodeMessageData{UserID: strconv.FormatInt(int64(loginAccountInfo.Data.UserID), 10), Nickname: loginAccountInfo.Data.Nickname, Content: content}}
}