/
main.go
56 lines (40 loc) · 1.16 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
package main
import (
"github.com/0x1a0b/hooked/config"
"github.com/0x1a0b/hooked/exampleCheckEmbeds"
"github.com/0x1a0b/hooked/exampleCheckSimple"
"github.com/0x1a0b/hooked/geekHackRss"
"github.com/0x1a0b/hooked/steamEconomy"
"github.com/robfig/cron/v3"
log "github.com/sirupsen/logrus"
"time"
)
func init() {
config.Read()
log.SetLevel(config.GetLogLevel())
log.SetReportCaller(true)
exampleSimple = exampleCheckSimple.Setup()
exampleEmbeds = exampleCheckEmbeds.Setup()
geekHack = geekHackRss.Setup()
rustSkins = steamEconomy.Setup()
time.Sleep(1 * time.Second)
log.Debugf("initialized")
}
var (
geekHack *geekHackRss.Instance
rustSkins *steamEconomy.Instance
exampleEmbeds *exampleCheckEmbeds.Instance
exampleSimple *exampleCheckSimple.Instance
)
func main() {
// https://godoc.org/github.com/robfig/cron
c := cron.New()
c.AddFunc("@every 10m", func() { go geekHack.Run() })
c.AddFunc("@every 10m", func() { go rustSkins.Run() })
if log.GetLevel() == log.TraceLevel {
c.AddFunc("@every 1m", func() { go exampleSimple.Run() })
c.AddFunc("@every 1m", func() { go exampleEmbeds.Run() })
}
log.Debugf("starting cron in foreground")
c.Run()
}