This repository has been archived on 2022-10-02. You can view files and clone it, but cannot push or open issues or pull requests.
dcbot-old/cron/cron.go

32 lines
650 B
Go
Raw Normal View History

2020-05-30 10:43:11 +00:00
package cron
import (
"time"
2020-06-02 07:00:40 +00:00
2020-06-05 12:36:29 +00:00
"github.com/tribalwarshelp/golang-sdk/sdk"
2020-06-02 07:00:40 +00:00
"github.com/tribalwarshelp/dcbot/discord"
"github.com/tribalwarshelp/dcbot/server"
"github.com/tribalwarshelp/dcbot/tribe"
2020-05-30 10:43:11 +00:00
"github.com/robfig/cron/v3"
)
type Config struct {
ServerRepo server.Repository
TribeRepo tribe.Repository
Discord *discord.Session
2020-06-05 12:36:29 +00:00
API *sdk.SDK
2020-05-30 10:43:11 +00:00
}
2020-06-06 12:59:11 +00:00
func Attach(c *cron.Cron, cfg Config) {
2020-05-30 10:43:11 +00:00
h := &handler{
lastEnnobledAt: make(map[string]time.Time),
serverRepo: cfg.ServerRepo,
tribeRepo: cfg.TribeRepo,
discord: cfg.Discord,
api: cfg.API,
2020-05-30 10:43:11 +00:00
}
c.AddFunc("@every 1m", h.checkLastEnnoblements)
2020-05-30 10:43:11 +00:00
}