refactor: 优化 SendMsg 函数中的消息处理逻辑,支持不同类型的 ReplyMsg,提升代码灵活性和可读性
This commit is contained in:
parent
5f8609bef2
commit
26b8d2b03a
@ -2,6 +2,7 @@ package action
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
"sync"
|
||||
@ -44,7 +45,12 @@ func (am *actionManager) SendMsg(reply *model.Reply) error {
|
||||
ID: int(reply.FromMsg.OriginMsgId),
|
||||
},
|
||||
}
|
||||
reply.ReplyMsg = append([]any{replyMsg}, reply.ReplyMsg)
|
||||
switch reply.ReplyMsg.(type) {
|
||||
case []any:
|
||||
reply.ReplyMsg = append([]any{replyMsg}, reply.ReplyMsg)
|
||||
case string:
|
||||
reply.ReplyMsg = fmt.Sprintf("%s%s", replyMsg.ToCQString(), reply.ReplyMsg)
|
||||
}
|
||||
}
|
||||
userID := strconv.FormatInt(reply.FromMsg.UserId, 10)
|
||||
if reply.FromMsg.UserId == 0 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user