-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub.go
More file actions
31 lines (28 loc) · 992 Bytes
/
github.go
File metadata and controls
31 lines (28 loc) · 992 Bytes
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
package jobs
import (
"sentinel/config"
"sentinel/service"
"sentinel/utils"
"strconv"
cron "github.com/robfig/cron/v3"
)
func RegisterGithubCronJob() {
if config.Env != "PROD" {
utils.SugarLogger.Infoln("Github CRON Job not registered because environment is not PROD")
return
}
c := cron.New()
entryID, err := c.AddFunc(config.GithubCron, func() {
_, _ = service.Discord.ChannelMessageSend(config.DiscordLogChannel, ":alarm_clock: Starting github CRON Job")
utils.SugarLogger.Infoln("Starting github CRON Job...")
service.CleanGithubMembers()
utils.SugarLogger.Infoln("Finished github CRON Job!")
_, _ = service.Discord.ChannelMessageSend(config.DiscordLogChannel, ":white_check_mark: Finished github job!")
})
if err != nil {
utils.SugarLogger.Errorln("Error registering CRON Job: " + err.Error())
return
}
c.Start()
utils.SugarLogger.Infoln("Registered CRON Job: " + strconv.Itoa(int(entryID)) + " scheduled with cron expression: " + config.GithubCron)
}