修复message无法json序列化的问题

This commit is contained in:
eatmoreapple 2021-12-17 10:09:56 +08:00
parent 8d8913c65c
commit 3e167178df
2 changed files with 16 additions and 16 deletions

View File

@ -46,25 +46,25 @@ type Client struct {
cookies map[string][]*http.Cookie
}
func NewClient(client *http.Client) *Client {
return &Client{Client: client}
func NewClient() *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
// 设置客户端不自动跳转
func DefaultClient() *Client {
jar, _ := cookiejar.New(nil)
timeout := 30 * time.Second
client := &http.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
client := NewClient()
client.AddHttpHook(UserAgentHook{})
return client
}
func (c *Client) AddHttpHook(hooks ...HttpHook) {

View File

@ -48,9 +48,9 @@ type Message struct {
Url string
senderInGroupUserName string
RecommendInfo RecommendInfo
Bot *Bot
Bot *Bot `json:"-"`
mu sync.RWMutex
Context context.Context
Context context.Context `json:"-"`
item map[string]interface{}
}