修复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 cookies map[string][]*http.Cookie
} }
func NewClient(client *http.Client) *Client { func NewClient() *Client {
return &Client{Client: client}
}
// DefaultClient 自动存储cookie
// 设置客户端不自动跳转
func DefaultClient() *Client {
jar, _ := cookiejar.New(nil) jar, _ := cookiejar.New(nil)
timeout := 30 * time.Second timeout := 30 * time.Second
client := &http.Client{ return &Client{
Client: &http.Client{
CheckRedirect: func(req *http.Request, via []*http.Request) error { CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse return http.ErrUseLastResponse
}, },
Jar: jar, Jar: jar,
Timeout: timeout, Timeout: timeout,
} }}
c := NewClient(client) }
c.AddHttpHook(UserAgentHook{})
return c // DefaultClient 自动存储cookie
// 设置客户端不自动跳转
func DefaultClient() *Client {
client := NewClient()
client.AddHttpHook(UserAgentHook{})
return client
} }
func (c *Client) AddHttpHook(hooks ...HttpHook) { func (c *Client) AddHttpHook(hooks ...HttpHook) {

View File

@ -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{}
} }