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

Method AddGroupNoticeSimple

client/operation.go:1202–1223  ·  view source on GitHub ↗

AddGroupNoticeSimple 发群公告

(groupUin uint32, text string)

Source from the content-addressed store, hash-verified

1200
1201// AddGroupNoticeSimple 发群公告
1202func (c *QQClient) AddGroupNoticeSimple(groupUin uint32, text string) (noticeID string, err error) {
1203 bkn, err := c.GetCsrfToken()
1204 if err != nil {
1205 return "", err
1206 }
1207 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}`, groupUin, bkn, url.QueryEscape(text))
1208 req, err := http.NewRequest(http.MethodPost, "https://web.qun.qq.com/cgi-bin/announce/add_qun_notice?bkn="+strconv.Itoa(bkn), strings.NewReader(body))
1209 if err != nil {
1210 return "", err
1211 }
1212 resp, err := c.SendRequestWithCookie(req)
1213 if err != nil {
1214 return "", err
1215 }
1216 var res entity.NoticeSendResp
1217 err = json.NewDecoder(resp.Body).Decode(&res)
1218 if err != nil {
1219 return "", err
1220 }
1221 _ = resp.Body.Close()
1222 return res.NoticeID, nil
1223}
1224
1225// AddGroupNoticeWithPic 发群公告带图片
1226func (c *QQClient) AddGroupNoticeWithPic(groupUin uint32, text string, pic []byte) (noticeID string, err error) {

Callers

nothing calls this directly

Calls 3

GetCsrfTokenMethod · 0.95
SendRequestWithCookieMethod · 0.95
CloseMethod · 0.45

Tested by

no test coverage detected