mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-14 11:02:43 +00:00
36 lines
787 B
Go
36 lines
787 B
Go
package customevent
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func scheduleCleanup() {
|
|
if err := cleanupStoredEvents(db); err != nil {
|
|
logrus.WithError(err).Error("executing custom event database cleanup")
|
|
}
|
|
}
|
|
|
|
func scheduleSend() {
|
|
evts, err := mc.PopEventsToExecute()
|
|
if err != nil {
|
|
logrus.WithError(err).Error("collecting scheduled custom events for sending")
|
|
return
|
|
}
|
|
|
|
for i := range evts {
|
|
go func(evt storedCustomEvent) {
|
|
evtData, err := parseEvent(evt.Channel, strings.NewReader(evt.Fields))
|
|
if err != nil {
|
|
logrus.WithError(err).Error("parsing fields in stored event")
|
|
return
|
|
}
|
|
|
|
if err = eventCreatorFunc("custom", evtData); err != nil {
|
|
logrus.WithError(err).Error("triggering stored event")
|
|
return
|
|
}
|
|
}(evts[i])
|
|
}
|
|
}
|