예제 #1
0
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
		}
	}()
}
예제 #2
0
파일: handlers.go 프로젝트: pzsz/sp0rkle
func tellCheck(line *base.Line) {
	nick := line.Nick
	if line.Cmd == "NICK" {
		// We want the destination nick, not the source.
		nick = line.Args[0]
	}
	r := rc.TellsFor(nick)
	for i := range r {
		if line.Cmd == "NICK" {
			bot.Privmsg(string(r[i].Chan), nick+": "+r[i].Reply())
			bot.Reply(line, "%s", r[i].Reply())
		} else {
			bot.Privmsg(line.Nick, r[i].Reply())
			bot.ReplyN(line, "%s", r[i].Reply())
		}
		rc.RemoveId(r[i].Id)
	}
	if len(r) > 0 {
		delete(listed, line.Nick)
	}
}