mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-09 00:30:02 +00:00
37 lines
787 B
Go
37 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])
|
||
|
}
|
||
|
}
|