diff --git a/coolq/api.go b/coolq/api.go index 960830f..2fa0bee 100644 --- a/coolq/api.go +++ b/coolq/api.go @@ -124,7 +124,13 @@ func (bot *CQBot) CQSendGroupMessage(groupId int64, i interface{}) MSG { // fix at display for _, e := range elem { if at, ok := e.(*message.AtElement); ok && at.Target != 0 { - at.Display = "@" + bot.Client.FindGroup(groupId).FindMember(at.Target).DisplayName() + at.Display = "@" + func() string { + mem := bot.Client.FindGroup(groupId).FindMember(at.Target) + if mem != nil { + return mem.DisplayName() + } + return strconv.FormatInt(at.Target, 10) + }() } } mid := bot.SendGroupMessage(groupId, &message.SendingMessage{Elements: elem}) diff --git a/coolq/bot.go b/coolq/bot.go index ba27714..c095bf7 100644 --- a/coolq/bot.go +++ b/coolq/bot.go @@ -95,7 +95,7 @@ func (bot *CQBot) SendGroupMessage(groupId int64, m *message.SendingMessage) int var newElem []message.IMessageElement for _, elem := range m.Elements { if i, ok := elem.(*message.ImageElement); ok { - _, _ = bot.Client.UploadGroupImage(int64(rand.Intn(11451419198)), i.Data) + _, _ = bot.Client.UploadGroupImage(int64(rand.Intn(11451419)), i.Data) gm, err := bot.Client.UploadGroupImage(groupId, i.Data) if err != nil { log.Warnf("警告: 群 %v 消息图片上传失败: %v", groupId, err)