Skip to content

Commit

Permalink
💩👌 make lint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Jan 6, 2022
1 parent a6ab7de commit 919651a
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions plugin_manager/timer/sleep.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ func firstWeek(date *time.Time, week time.Weekday) (d time.Time) {
return
}

func (ts *Timer) nextWakeTime() (date time.Time) {
func (t *Timer) nextWakeTime() (date time.Time) {
date = time.Now()
m := ts.Month()
d := ts.Day()
h := ts.Hour()
mn := ts.Minute()
w := ts.Week()
m := t.Month()
d := t.Day()
h := t.Hour()
mn := t.Minute()
w := t.Week()
var unit time.Duration
logrus.Debugln("[timer] unit init:", unit)
if mn >= 0 {
Expand Down Expand Up @@ -74,35 +74,35 @@ func (ts *Timer) nextWakeTime() (date time.Time) {
}
switch stable {
case 0b0101:
if ts.Day() != time.Now().Day() || ts.Month() != time.Now().Month() {
if t.Day() != time.Now().Day() || t.Month() != time.Now().Month() {
h = 0
}
case 0b1001:
if ts.Month() != time.Now().Month() {
if t.Month() != time.Now().Month() {
d = 0
}
case 0b0001:
if ts.Month() != time.Now().Month() {
if t.Month() != time.Now().Month() {
d = 0
h = 0
}
}
logrus.Debugln("[timer] stable:", stable)
logrus.Debugln("[timer] m:", m, "d:", d, "h:", h, "mn:", mn, "w:", w)
date = time.Date(date.Year(), time.Month(m), d, h, mn, date.Second(), date.Nanosecond(), date.Location())
date = time.Date(date.Year(), m, d, h, mn, date.Second(), date.Nanosecond(), date.Location())
logrus.Debugln("[timer] date original:", date)
if unit > 0 {
date = date.Add(unit)
}
logrus.Debugln("[timer] date after add:", date)
if time.Until(date) <= 0 {
if ts.Month() < 0 {
if ts.Day() > 0 || (ts.Day() == 0 && ts.Week() >= 0) {
if t.Month() < 0 {
if t.Day() > 0 || (t.Day() == 0 && t.Week() >= 0) {
date = date.AddDate(0, 1, 0)
} else if ts.Day() < 0 || ts.Week() < 0 {
if ts.Hour() > 0 {
} else if t.Day() < 0 || t.Week() < 0 {
if t.Hour() > 0 {
date = date.AddDate(0, 0, 1)
} else if ts.Minute() > 0 {
} else if t.Minute() > 0 {
date = date.Add(time.Hour)
}
}
Expand Down Expand Up @@ -140,7 +140,7 @@ func (ts *Timer) nextWakeTime() (date time.Time) {
default:
date = date.AddDate(1, 0, 0)
}
date = firstWeek(&date, time.Weekday(w))
date = firstWeek(&date, w)
}
logrus.Debugln("[timer] date after s2:", date)
if time.Until(date) <= 0 {
Expand All @@ -149,14 +149,14 @@ func (ts *Timer) nextWakeTime() (date time.Time) {
return date
}

func (ts *Timer) judgeHM() {
if ts.Hour() < 0 || ts.Hour() == time.Now().Hour() {
if ts.Minute() < 0 || ts.Minute() == time.Now().Minute() {
if ts.SelfID != 0 {
ts.sendmsg(ts.GrpID, zero.GetBot(ts.SelfID))
func (t *Timer) judgeHM() {
if t.Hour() < 0 || t.Hour() == time.Now().Hour() {
if t.Minute() < 0 || t.Minute() == time.Now().Minute() {
if t.SelfID != 0 {
t.sendmsg(t.GrpID, zero.GetBot(t.SelfID))
} else {
zero.RangeBot(func(id int64, ctx *zero.Ctx) (_ bool) {
ts.sendmsg(ts.GrpID, ctx)
t.sendmsg(t.GrpID, ctx)
return
})
}
Expand Down

0 comments on commit 919651a

Please sign in to comment.