From a0219d76ea2da8c7897d771a3ca0c64d02ee8260 Mon Sep 17 00:00:00 2001 From: Mrs4s Date: Wed, 28 Oct 2020 11:52:47 +0800 Subject: [PATCH] fix empty friend message. --- coolq/bot.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/coolq/bot.go b/coolq/bot.go index b71163d..861a204 100644 --- a/coolq/bot.go +++ b/coolq/bot.go @@ -296,6 +296,10 @@ func (bot *CQBot) SendPrivateMessage(target int64, m *message.SendingMessage) in } newElem = append(newElem, elem) } + if len(newElem) == 0 { + log.Warnf("好友消息发送失败: 消息为空.") + return -1 + } m.Elements = newElem var id int32 = -1 if bot.Client.FindFriend(target) != nil { // 双向好友