/
main.go
87 lines (72 loc) · 1.54 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"github.com/bluele/slack"
)
var (
APPSTORE_ID string = "493470467"
PLAYSTORE_URL string = ""
SLACK_WEB_HOOK_URL = ""
SLACK_CHANNEL = ""
SLACK_TOKEN = ""
LAST_CHECKED_ID = ""
)
const (
APPSTORE_URL string = "http://itunes.apple.com/jp/rss/customerreviews/id=%s/json"
)
func main() {
// if len(os.Args) == 1 {
// cmd := exec.Command(os.Args[0], "--child")
// cmd.Start()
// } else {
// tick := time.Tick(3 * time.Second)
// for {
// select {
// case _ = <-tick:
// now := time.Now()
// content := []byte(now.String())
// ioutil.WriteFile("/tmp/output", content, os.ModePerm)
// }
// }
// }
response := GetAppStoreReview()
for res, _ := range response.Feed {
}
}
func GetAppStoreReview() ITunesResponse {
url := fmt.Sprintf(APPSTORE_URL, APPSTORE_ID)
fmt.Println(url)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
fmt.Errorf("error")
}
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Errorf("error")
}
defer resp.Body.Close()
val, err := ioutil.ReadAll(resp.Body)
var res ITunesResponse
json.Unmarshal(val, &res)
return res
}
func SaveAppStoreReview(label string) {
LAST_CHECKED_ID = label
}
func SortItem() {
}
func Notify(message string) {
s := slack.New(SLACK_TOKEN)
c, err := s.FindChannelByName(SLACK_CHANNEL)
if err != nil {
panic(err)
}
err = s.ChatPostMessage(c.Id, message, nil)
if err != nil {
panic(err)
}
}