mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +08:00
commit
8e70b22d1c
@ -161,6 +161,10 @@ type noticeImage struct {
|
|||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type noticeSendResp struct {
|
||||||
|
NoticeId string `json:"new_fid"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *QQClient) GetGroupNotice(groupCode int64) (l []*GroupNoticeMessage, err error) {
|
func (c *QQClient) GetGroupNotice(groupCode int64) (l []*GroupNoticeMessage, err error) {
|
||||||
v := url.Values{}
|
v := url.Values{}
|
||||||
v.Set("bkn", strconv.Itoa(c.getCSRFToken()))
|
v.Set("bkn", strconv.Itoa(c.getCSRFToken()))
|
||||||
@ -265,27 +269,37 @@ func (c *QQClient) uploadGroupNoticePic(img []byte) (*noticeImage, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddGroupNoticeSimple 发群公告
|
// AddGroupNoticeSimple 发群公告
|
||||||
func (c *QQClient) AddGroupNoticeSimple(groupCode int64, text string) error {
|
func (c *QQClient) AddGroupNoticeSimple(groupCode int64, text string) (noticeId string, err error) {
|
||||||
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}`, groupCode, c.getCSRFToken(), url.QueryEscape(text))
|
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}`, groupCode, c.getCSRFToken(), url.QueryEscape(text))
|
||||||
_, err := utils.HttpPostBytesWithCookie("https://web.qun.qq.com/cgi-bin/announce/add_qun_notice?bkn="+fmt.Sprint(c.getCSRFToken()), []byte(body), c.getCookiesWithDomain("qun.qq.com"))
|
resp, err := utils.HttpPostBytesWithCookie("https://web.qun.qq.com/cgi-bin/announce/add_qun_notice?bkn="+fmt.Sprint(c.getCSRFToken()), []byte(body), c.getCookiesWithDomain("qun.qq.com"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "request error")
|
return "", errors.Wrap(err, "request error")
|
||||||
}
|
}
|
||||||
return nil
|
var res noticeSendResp
|
||||||
|
err = json.Unmarshal(resp, &res)
|
||||||
|
if err != nil {
|
||||||
|
return "", errors.Wrap(err, "json unmarshal error")
|
||||||
|
}
|
||||||
|
return res.NoticeId, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddGroupNoticeWithPic 发群公告带图片
|
// AddGroupNoticeWithPic 发群公告带图片
|
||||||
func (c *QQClient) AddGroupNoticeWithPic(groupCode int64, text string, pic []byte) error {
|
func (c *QQClient) AddGroupNoticeWithPic(groupCode int64, text string, pic []byte) (noticeId string, err error) {
|
||||||
img, err := c.uploadGroupNoticePic(pic)
|
img, err := c.uploadGroupNoticePic(pic)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return "", err
|
||||||
}
|
}
|
||||||
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`, groupCode, c.getCSRFToken(), url.QueryEscape(text), img.ID, img.Width, img.Height)
|
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`, groupCode, c.getCSRFToken(), url.QueryEscape(text), img.ID, img.Width, img.Height)
|
||||||
_, err = utils.HttpPostBytesWithCookie("https://web.qun.qq.com/cgi-bin/announce/add_qun_notice?bkn="+fmt.Sprint(c.getCSRFToken()), []byte(body), c.getCookiesWithDomain("qun.qq.com"))
|
resp, err := utils.HttpPostBytesWithCookie("https://web.qun.qq.com/cgi-bin/announce/add_qun_notice?bkn="+fmt.Sprint(c.getCSRFToken()), []byte(body), c.getCookiesWithDomain("qun.qq.com"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "request error")
|
return "", errors.Wrap(err, "request error")
|
||||||
}
|
}
|
||||||
return nil
|
var res noticeSendResp
|
||||||
|
err = json.Unmarshal(resp, &res)
|
||||||
|
if err != nil {
|
||||||
|
return "", errors.Wrap(err, "json unmarshal error")
|
||||||
|
}
|
||||||
|
return res.NoticeId, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *QQClient) DelGroupNotice(groupCode int64, fid string) error {
|
func (c *QQClient) DelGroupNotice(groupCode int64, fid string) error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user