修复message无法json序列化的问题
This commit is contained in:
parent
8d8913c65c
commit
3e167178df
28
client.go
28
client.go
@ -46,25 +46,25 @@ type Client struct {
|
|||||||
cookies map[string][]*http.Cookie
|
cookies map[string][]*http.Cookie
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClient(client *http.Client) *Client {
|
func NewClient() *Client {
|
||||||
return &Client{Client: client}
|
jar, _ := cookiejar.New(nil)
|
||||||
|
timeout := 30 * time.Second
|
||||||
|
return &Client{
|
||||||
|
Client: &http.Client{
|
||||||
|
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||||
|
return http.ErrUseLastResponse
|
||||||
|
},
|
||||||
|
Jar: jar,
|
||||||
|
Timeout: timeout,
|
||||||
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultClient 自动存储cookie
|
// DefaultClient 自动存储cookie
|
||||||
// 设置客户端不自动跳转
|
// 设置客户端不自动跳转
|
||||||
func DefaultClient() *Client {
|
func DefaultClient() *Client {
|
||||||
jar, _ := cookiejar.New(nil)
|
client := NewClient()
|
||||||
timeout := 30 * time.Second
|
client.AddHttpHook(UserAgentHook{})
|
||||||
client := &http.Client{
|
return client
|
||||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
|
||||||
return http.ErrUseLastResponse
|
|
||||||
},
|
|
||||||
Jar: jar,
|
|
||||||
Timeout: timeout,
|
|
||||||
}
|
|
||||||
c := NewClient(client)
|
|
||||||
c.AddHttpHook(UserAgentHook{})
|
|
||||||
return c
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) AddHttpHook(hooks ...HttpHook) {
|
func (c *Client) AddHttpHook(hooks ...HttpHook) {
|
||||||
|
@ -48,9 +48,9 @@ type Message struct {
|
|||||||
Url string
|
Url string
|
||||||
senderInGroupUserName string
|
senderInGroupUserName string
|
||||||
RecommendInfo RecommendInfo
|
RecommendInfo RecommendInfo
|
||||||
Bot *Bot
|
Bot *Bot `json:"-"`
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
Context context.Context
|
Context context.Context `json:"-"`
|
||||||
item map[string]interface{}
|
item map[string]interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user