refactor: 优化 SendMsg 函数中的消息处理逻辑,使用类型断言提升代码灵活性和可读性
This commit is contained in:
parent
26b8d2b03a
commit
7b664f436b
@ -45,11 +45,11 @@ func (am *actionManager) SendMsg(reply *model.Reply) error {
|
||||
ID: int(reply.FromMsg.OriginMsgId),
|
||||
},
|
||||
}
|
||||
switch reply.ReplyMsg.(type) {
|
||||
switch replyMsgVal := reply.ReplyMsg.(type) {
|
||||
case []any:
|
||||
reply.ReplyMsg = append([]any{replyMsg}, reply.ReplyMsg)
|
||||
reply.ReplyMsg = append([]any{replyMsg}, replyMsgVal...)
|
||||
case string:
|
||||
reply.ReplyMsg = fmt.Sprintf("%s%s", replyMsg.ToCQString(), reply.ReplyMsg)
|
||||
reply.ReplyMsg = fmt.Sprintf("%s%s", replyMsg.ToCQString(), replyMsgVal)
|
||||
}
|
||||
}
|
||||
userID := strconv.FormatInt(reply.FromMsg.UserId, 10)
|
||||
|
Loading…
x
Reference in New Issue
Block a user