diff --git a/coolq/cqcode.go b/coolq/cqcode.go index 1ce3dd2ac..c26feae6b 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -243,6 +243,16 @@ func toElements(e []message.IMessageElement, source message.Source) (r []msg.Ele {K: "type", V: "sticker"}, }, } + case *message.GroupFileElement: + m = msg.Element{ + Type: "file", + Data: pairs{ + {K: "path", V: o.Path}, + {K: "name", V: o.Name}, + {K: "size", V: strconv.FormatInt(o.Size, 10)}, + {K: "busid", V: strconv.FormatInt(int64(o.Busid), 10)}, + }, + } case *msg.LocalImage: data := pairs{ {K: "file", V: o.File}, @@ -378,6 +388,11 @@ func ToMessageContent(e []message.IMessageElement, source message.Source) (r []g "type": "face", "data": global.MSG{"id": o.ID, "type": "sticker"}, } + case *message.GroupFileElement: + m = global.MSG{ + "type": "file", + "data": global.MSG{"path": o.Path, "name": o.Name, "size": strconv.FormatInt(o.Size, 10), "busid": strconv.FormatInt(int64(o.Busid), 10)}, + } default: continue } @@ -849,6 +864,17 @@ func (bot *CQBot) ConvertElement(spec *onebot.Spec, elem msg.Element, sourceType v.File = cacheFile } return v, nil + case "file": + path := elem.Get("path") + name := elem.Get("name") + size, _ := strconv.ParseInt(elem.Get("size"), 10, 64) + busid, _ := strconv.ParseInt(elem.Get("busid"), 10, 64) + return &message.GroupFileElement{ + Name: name, + Size: size, + Path: path, + Busid: int32(busid), + }, nil default: return nil, errors.New("unsupported message type: " + elem.Type) } diff --git a/coolq/event.go b/coolq/event.go index 61e763f48..9081985dd 100644 --- a/coolq/event.go +++ b/coolq/event.go @@ -118,7 +118,7 @@ func (bot *CQBot) groupMessageEvent(c *client.QQClient, m *message.GroupMessage) "url": c.GetGroupFileUrl(m.GroupCode, file.Path, file.Busid), }, }) - return + // return } } source := message.Source{