-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
39 lines (31 loc) · 780 Bytes
/
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
package main
import (
"log"
"net/http"
"github.com/robfig/cron"
"github.com/wicoady1/discord_webhook/services/drs_newsfeed"
"github.com/wicoady1/discord_webhook/util/database"
"github.com/wicoady1/discord_webhook/util/webhook"
)
var cronTask *cron.Cron
func main() {
//initialize DB
module := webhook.InitWebHookModule()
database.Init(module.Config.Database)
//initialize Cron
if cronTask == nil {
cronTask = cron.New()
} else {
cronTask.Stop()
}
err := cronTask.AddFunc("0/10 * * * * *", func() {
drs_newsfeed.GenerateContent(module)
})
if err != nil {
log.Println("[CRON Task]", err)
return
}
cronTask.Start()
log.Println("[Webhook Bot] Cron task is running!")
http.ListenAndServe(":8000", nil) //dummy to enforce program to keep running
}