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.
2020-06-05 15:49:51 +00:00
|
|
|
package cron
|
|
|
|
|
|
|
|
import (
|
2021-05-06 12:42:37 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"github.com/tribalwarshelp/shared/tw/twmodel"
|
|
|
|
"time"
|
|
|
|
|
2021-07-17 15:22:36 +00:00
|
|
|
"github.com/tribalwarshelp/dcbot/util/twutil"
|
2020-06-05 15:49:51 +00:00
|
|
|
)
|
|
|
|
|
2021-05-06 12:42:37 +00:00
|
|
|
func isBarbarian(p *twmodel.Player) bool {
|
2021-05-06 13:25:09 +00:00
|
|
|
return twutil.IsPlayerNil(p) || p.ID == 0
|
2020-07-22 13:46:10 +00:00
|
|
|
}
|
2021-05-06 12:42:37 +00:00
|
|
|
|
|
|
|
func trackDuration(log *logrus.Entry, fn func(), fnName string) func() {
|
|
|
|
return func() {
|
|
|
|
now := time.Now()
|
|
|
|
log := log.WithField("fnName", fnName)
|
|
|
|
log.Infof("'%s' has been called", fnName)
|
|
|
|
|
|
|
|
fn()
|
|
|
|
|
|
|
|
duration := time.Since(now)
|
|
|
|
log.
|
|
|
|
WithField("duration", duration.Nanoseconds()).
|
|
|
|
WithField("durationPretty", duration.String()).
|
|
|
|
Infof("'%s' finished executing", fnName)
|
|
|
|
}
|
|
|
|
}
|