From af1358465c709417bda9c7f1746876638df16f3e Mon Sep 17 00:00:00 2001 From: Akiba Date: Thu, 30 Jun 2022 17:22:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=A0=E9=99=A4=E5=85=AC=E5=91=8A=20?= =?UTF-8?q?feat:=20=E8=8E=B7=E5=8F=96=E5=85=AC=E5=91=8A=E7=8E=B0=E5=9C=A8?= =?UTF-8?q?=E4=BC=9A=E8=BF=94=E5=9B=9Enotice=5Fid(fid)=20=E7=94=A8?= =?UTF-8?q?=E6=9D=A5=E5=88=A0=E9=99=A4=E5=85=AC=E5=91=8A=20fix:=20?= =?UTF-8?q?=E2=80=9C=E5=8F=91=E9=80=81=E7=BB=99=E6=96=B0=E6=88=90=E5=91=98?= =?UTF-8?q?=E2=80=9D=E7=9A=84=E5=85=AC=E5=91=8A=E6=97=A0=E6=B3=95=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/http_api.go | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/client/http_api.go b/client/http_api.go index 98a18afb..cc2ec183 100644 --- a/client/http_api.go +++ b/client/http_api.go @@ -119,17 +119,22 @@ func (c *QQClient) GetTts(text string) ([]byte, error) { /* -------- GroupNotice -------- */ type groupNoticeRsp struct { - Feeds []*struct { - SenderId uint32 `json:"u"` - PublishTime uint64 `json:"pubt"` - Message struct { - Text string `json:"text"` - Images []noticeImage `json:"pics"` - } `json:"msg"` - } `json:"feeds"` + Feeds []*GroupNoticeFeed `json:"feeds"` + Inst []*GroupNoticeFeed `json:"inst"` +} + +type GroupNoticeFeed struct { + NoticeId string `json:"fid"` + SenderId uint32 `json:"u"` + PublishTime uint64 `json:"pubt"` + Message struct { + Text string `json:"text"` + Images []noticeImage `json:"pics"` + } `json:"msg"` } type GroupNoticeMessage struct { + NoticeId string `json:"notice_id"` SenderId uint32 `json:"sender_id"` PublishTime uint64 `json:"publish_time"` Message struct { @@ -187,9 +192,8 @@ func (c *QQClient) GetGroupNotice(groupCode int64) (l []*GroupNoticeMessage, err } func (c *QQClient) parseGroupNoticeJson(s *groupNoticeRsp) []*GroupNoticeMessage { - o := make([]*GroupNoticeMessage, 0, len(s.Feeds)) - for _, v := range s.Feeds { - + o := make([]*GroupNoticeMessage, 0, len(s.Feeds)+len(s.Inst)) + parse := func(v *GroupNoticeFeed) { ims := make([]GroupNoticeImage, 0, len(v.Message.Images)) for i := 0; i < len(v.Message.Images); i++ { ims = append(ims, GroupNoticeImage{ @@ -200,6 +204,7 @@ func (c *QQClient) parseGroupNoticeJson(s *groupNoticeRsp) []*GroupNoticeMessage } o = append(o, &GroupNoticeMessage{ + NoticeId: v.NoticeId, SenderId: v.SenderId, PublishTime: v.PublishTime, Message: struct { @@ -211,7 +216,12 @@ func (c *QQClient) parseGroupNoticeJson(s *groupNoticeRsp) []*GroupNoticeMessage }, }) } - + for _, v := range s.Feeds { + parse(v) + } + for _, v := range s.Inst { + parse(v) + } return o } @@ -277,3 +287,12 @@ func (c *QQClient) AddGroupNoticeWithPic(groupCode int64, text string, pic []byt } return nil } + +func (c *QQClient) DelGroupNotice(groupCode int64, fid string) error { + body := fmt.Sprintf(`fid=%s&qid=%v&bkn=%v&ft=23&op=1`, fid, groupCode, c.getCSRFToken()) + _, err := utils.HttpPostBytesWithCookie("https://web.qun.qq.com/cgi-bin/announce/del_feed", []byte(body), c.getCookiesWithDomain("qun.qq.com")) + if err != nil { + return errors.Wrap(err, "request error") + } + return nil +}