add message Image get support
This commit is contained in:
parent
bf6ce1aff0
commit
526431f400
10
client.go
10
client.go
@ -349,3 +349,13 @@ func (c *Client) WebWxVerifyUser(storage WechatStorage, info RecommendInfo, veri
|
||||
req.Header.Add("Content-Type", jsonContentType)
|
||||
return c.Do(req)
|
||||
}
|
||||
|
||||
func (c *Client) WebWxGetMsgImg(msg *Message, info LoginInfo) (*http.Response, error) {
|
||||
path, _ := url.Parse(webWxGetMsgImgUrl)
|
||||
params := url.Values{}
|
||||
params.Add("MsgID", msg.MsgId)
|
||||
params.Add("skey", info.SKey)
|
||||
params.Add("type", "slave")
|
||||
path.RawQuery = params.Encode()
|
||||
return c.Get(path.String())
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ const (
|
||||
webWxVerifyUserUrl = "https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxverifyuser"
|
||||
syncCheckUrl = "https://webpush.wx2.qq.com/cgi-bin/mmwebwx-bin/synccheck"
|
||||
webWxUpLoadMediaUrl = "https://file.wx2.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia"
|
||||
webWxGetMsgImgUrl = "https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxgetmsgimg"
|
||||
|
||||
jsonContentType = "application/json; charset=utf-8"
|
||||
)
|
||||
|
17
message.go
17
message.go
@ -3,6 +3,7 @@ package openwechat
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
@ -170,6 +171,17 @@ func (m *Message) IsSystem() bool {
|
||||
return m.MsgType == 10000
|
||||
}
|
||||
|
||||
func (m *Message) IsNotify() bool {
|
||||
return m.MsgType == 51 && m.StatusNotifyCode != 0
|
||||
}
|
||||
|
||||
func (m *Message) GetMsgImageResponse() (*http.Response, error) {
|
||||
if !m.IsPicture() {
|
||||
return nil, errors.New("Picture type message required")
|
||||
}
|
||||
return m.Bot.Caller.Client.WebWxGetMsgImg(m, m.Bot.storage.GetLoginInfo())
|
||||
}
|
||||
|
||||
// 用在多个messageHandler之间传递信息
|
||||
func (m *Message) Set(key string, value interface{}) {
|
||||
m.mu.Lock()
|
||||
@ -194,9 +206,7 @@ func (m *Message) init(bot *Bot) {
|
||||
m.Content = strings.Join(data[1:], "")
|
||||
m.senderInGroupUserName = data[0]
|
||||
receiver, err := m.Receiver()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if err == nil {
|
||||
displayName := receiver.DisplayName
|
||||
if displayName == "" {
|
||||
displayName = receiver.NickName
|
||||
@ -208,6 +218,7 @@ func (m *Message) init(bot *Bot) {
|
||||
m.Content = m.Content[index+1:]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//func (m *Message) Agree() error {
|
||||
|
Loading…
x
Reference in New Issue
Block a user