-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
57 lines (48 loc) · 1.01 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
package main
import (
"context"
"fmt"
"log"
"os"
"os/signal"
"syscall"
"golang.org/x/oauth2"
"github.com/honk-ci/honk-notify/pkg/github"
"github.com/honk-ci/honk-notify/pkg/honk"
"github.com/honk-ci/honk-notify/pkg/twitter"
)
func main() {
token := os.Getenv("GITHUB_AUTH_TOKEN")
if token == "" {
log.Fatal("Unauthorized: No token present")
}
ctx := context.Background()
ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token})
tc := oauth2.NewClient(ctx, ts)
c := make(chan interface{})
go twitter.WatchTwitter([]string{
"michigan",
"kubernetes honk",
"kubecon honk",
"kcsna2019",
"kubekhan",
}, c)
go github.WatchGithub(tc, []string{
"kubernetes",
"kubernetes-sigs",
"honk-ci",
}, c)
go func() {
for {
val := <-c
log.Println(fmt.Sprintf("%v", val))
honk.Honk()
}
}()
// Wait for SIGINT and SIGTERM (HIT CTRL-C)
ch := make(chan os.Signal)
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
log.Println(<-ch)
log.Println("Stopping Honk-Alert...")
close(c)
}