forked from falltodis/ik
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
62 lines (52 loc) · 1.24 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"bytes"
"encoding/json"
"io/ioutil"
"net/http"
"os"
)
type Ret struct {
Ret int `json:"ret"`
Msg string `json:"msg"`
}
type Config struct {
Cookie string `json:"cookie"`
Pushplus string `json:"pushplus"`
}
func main() {
iKuu()
}
func iKuu() {
config := &Config{}
osConfig := os.Getenv("CONFIG")
json.Unmarshal([]byte(osConfig), config)
url := "https://ikuuu.co/user/checkin"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Set("Cookie", config.Cookie)
client := http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
ret := &Ret{}
err := json.Unmarshal(body, ret)
if err != nil {
sendPushPlus(config.Pushplus, "iKuuu 签到", "Cookie 已失效请检查!")
return
}
sendPushPlus(config.Pushplus, "iKuuu 签到", ret.Msg)
}
func sendPushPlus(token, title, content string) {
url := "https://www.pushplus.plus/send"
ma := make(map[string]interface{})
ma["token"] = token
ma["title"] = title
ma["content"] = content
js, _ := json.Marshal(ma)
param := bytes.NewReader(js)
req, _ := http.NewRequest("POST", url, param)
req.Header.Set("Content-Type", "application/json")
client := http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
}