MCPcopy Create free account
hub / github.com/LagrangeDev/LagrangeGo / AddGroupNoticeWithPic

Method AddGroupNoticeWithPic

client/operation.go:1226–1251  ·  view source on GitHub ↗

AddGroupNoticeWithPic 发群公告带图片

(groupUin uint32, text string, pic []byte)

Source from the content-addressed store, hash-verified

1224
1225// AddGroupNoticeWithPic 发群公告带图片
1226func (c *QQClient) AddGroupNoticeWithPic(groupUin uint32, text string, pic []byte) (noticeID string, err error) {
1227 bkn, err := c.GetCsrfToken()
1228 if err != nil {
1229 return "", err
1230 }
1231 img, err := c.uploadGroupNoticePic(bkn, pic)
1232 if err != nil {
1233 return "", err
1234 }
1235 body := fmt.Sprintf(`qid=%v&bkn=%v&text=%v&pinned=0&type=1&settings={"is_show_edit_card":0,"tip_window_type":1,"confirm_required":1}&pic=%v&imgWidth=%v&imgHeight=%v`, groupUin, bkn, url.QueryEscape(text), img.ID, img.Width, img.Height)
1236 req, err := http.NewRequest(http.MethodPost, "https://web.qun.qq.com/cgi-bin/announce/add_qun_notice?bkn="+strconv.Itoa(bkn), strings.NewReader(body))
1237 if err != nil {
1238 return "", err
1239 }
1240 resp, err := c.SendRequestWithCookie(req)
1241 if err != nil {
1242 return "", err
1243 }
1244 var res entity.NoticeSendResp
1245 err = json.NewDecoder(resp.Body).Decode(&res)
1246 if err != nil {
1247 return "", err
1248 }
1249 _ = resp.Body.Close()
1250 return res.NoticeID, nil
1251}
1252
1253// DelGroupNotice 删除群公告
1254func (c *QQClient) DelGroupNotice(groupUin uint32, fid string) error {

Callers

nothing calls this directly

Calls 4

GetCsrfTokenMethod · 0.95
uploadGroupNoticePicMethod · 0.95
SendRequestWithCookieMethod · 0.95
CloseMethod · 0.45

Tested by

no test coverage detected