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)
|
req.Header.Add("Content-Type", jsonContentType)
|
||||||
return c.Do(req)
|
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"
|
webWxVerifyUserUrl = "https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxverifyuser"
|
||||||
syncCheckUrl = "https://webpush.wx2.qq.com/cgi-bin/mmwebwx-bin/synccheck"
|
syncCheckUrl = "https://webpush.wx2.qq.com/cgi-bin/mmwebwx-bin/synccheck"
|
||||||
webWxUpLoadMediaUrl = "https://file.wx2.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia"
|
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"
|
jsonContentType = "application/json; charset=utf-8"
|
||||||
)
|
)
|
||||||
|
35
message.go
35
message.go
@ -3,6 +3,7 @@ package openwechat
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -170,6 +171,17 @@ func (m *Message) IsSystem() bool {
|
|||||||
return m.MsgType == 10000
|
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之间传递信息
|
// 用在多个messageHandler之间传递信息
|
||||||
func (m *Message) Set(key string, value interface{}) {
|
func (m *Message) Set(key string, value interface{}) {
|
||||||
m.mu.Lock()
|
m.mu.Lock()
|
||||||
@ -194,18 +206,17 @@ func (m *Message) init(bot *Bot) {
|
|||||||
m.Content = strings.Join(data[1:], "")
|
m.Content = strings.Join(data[1:], "")
|
||||||
m.senderInGroupUserName = data[0]
|
m.senderInGroupUserName = data[0]
|
||||||
receiver, err := m.Receiver()
|
receiver, err := m.Receiver()
|
||||||
if err != nil {
|
if err == nil {
|
||||||
return
|
displayName := receiver.DisplayName
|
||||||
}
|
if displayName == "" {
|
||||||
displayName := receiver.DisplayName
|
displayName = receiver.NickName
|
||||||
if displayName == "" {
|
}
|
||||||
displayName = receiver.NickName
|
atFlag := "@" + displayName
|
||||||
}
|
index := len(atFlag) + 1 + 1
|
||||||
atFlag := "@" + displayName
|
if strings.HasPrefix(m.Content, atFlag) && unicode.IsSpace(rune(m.Content[index])) {
|
||||||
index := len(atFlag) + 1 + 1
|
m.IsAt = true
|
||||||
if strings.HasPrefix(m.Content, atFlag) && unicode.IsSpace(rune(m.Content[index])) {
|
m.Content = m.Content[index+1:]
|
||||||
m.IsAt = true
|
}
|
||||||
m.Content = m.Content[index+1:]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user