func Remind(r *reminders.Reminder) { delta := r.RemindAt.Sub(time.Now()) if delta < 0 { return } c := make(chan bool) running[r.Id] = c go func() { select { case <-time.After(delta): bot.Privmsg(string(r.Chan), r.Reply()) // TODO(fluffle): Tie this into state tracking properly. bot.Privmsg(string(r.Target), r.Reply()) Forget(r.Id, false) case <-c: return } }() }
func Remind(r *reminders.Reminder, ctx *bot.Context) { delta := r.RemindAt.Sub(time.Now()) if delta < 0 { return } c := make(chan struct{}) running[r.Id] = c go func() { select { case <-time.After(delta): ctx.Privmsg(string(r.Chan), r.Reply()) // TODO(fluffle): Tie this into state tracking properly. ctx.Privmsg(string(r.Target), r.Reply()) // This is used in snooze to reinstate reminders. finished[strings.ToLower(string(r.Target))] = r if pc != nil { if s := pc.GetByNick(string(r.Target)); s.CanPush() { push.Push(s, "Reminder from sp0rkle!", r.Reply()) } } Forget(r.Id, false) case <-c: return } }() }