(domain string)
| 84 | } |
| 85 | |
| 86 | func (c *QQClient) GetCookies(domain string) (*Cookies, error) { |
| 87 | skey, err := c.GetSkey() |
| 88 | if err != nil { |
| 89 | return nil, err |
| 90 | } |
| 91 | var token string |
| 92 | if tokenTime, ok := c.ticket.psKeys.Load(domain); ok { |
| 93 | if time.Now().Before(tokenTime.expireTime) { |
| 94 | token = tokenTime.key |
| 95 | } else { |
| 96 | cookies, err := c.FetchCookies([]string{domain}) |
| 97 | if err != nil { |
| 98 | return nil, err |
| 99 | } |
| 100 | token = cookies[0] |
| 101 | c.ticket.psKeys.Store(domain, &keyInfo{ |
| 102 | key: token, |
| 103 | expireTime: time.Now().Add(24 * time.Hour), |
| 104 | }) |
| 105 | } |
| 106 | } else { |
| 107 | cookies, err := c.FetchCookies([]string{domain}) |
| 108 | if err != nil { |
| 109 | return nil, err |
| 110 | } |
| 111 | token = cookies[0] |
| 112 | c.ticket.psKeys.Store(domain, &keyInfo{ |
| 113 | key: token, |
| 114 | expireTime: time.Now().Add(24 * time.Hour), |
| 115 | }) |
| 116 | } |
| 117 | return &Cookies{ |
| 118 | uin: c.Uin, |
| 119 | SKey: skey, |
| 120 | PsKey: token, |
| 121 | }, nil |
| 122 | } |
| 123 | |
| 124 | func GTK(s string) int { |
| 125 | hash := 5381 |
no test coverage detected