on *:CONNECT:{ timertimers 0 1 timercheck } alias timercheck { if (!$hget(timers)) { hmake timers 100 $iif($exists(timers.db),hload timers timers.db) } var %b = 1 while ($hget(timers,%b).item) { tokenize 32 $hget(timers,%b).data var %next = $1,%last = $2,%together = $calc($1 + $2) if (%together <= $ctime) { $$3- hadd timers $hget(timers,%b).item $1 $ctime $3- } inc %b } } ; $timer.ids(#channel) alias timer.ids { if ($isid) && ($1) { if (!$hget(timers)) { hmake timers 100 $iif($exists(timers.db),hload timers timers.db) } if ($left($1,1) != $chr(35)) { return 0 } var %a = 1,%b while ($hget(timers,%a).item) { var %stuff = $v1,%chan = $gettok(%stuff,1,$asc(.)),%id = $gettok(%stuff,2,$asc(.)) if (%chan == $1) { var %b = $addtok(%b,%id,44) } inc %a } return %b } } ;hadd -m timers . on 400:TEXT:@timer*:#:{ ;timer add if (!$2) { notice $nick You must specify } if ($2 == list) { var %ids = $timer.ids($chan),%b = 1 if (%ids == $null) { notice $nick Error: There are no timers for $chan $+ . | return } while ($gettok(%ids,%b,44) != $null) { var %id = $v1 var %all = $hget(timers,$chan $+ . $+ %id) tokenize 32 %all var %dur = $1, %last $calc($2 + $1), %cmd $3- notice $nick Timer: Name: %id Duration: $duration(%dur) Next time: $duration($calc(%last - $ctime)) Channel: $4 Message: $5- inc %b } } if ($2 == add) { if (!$5) { notice $nick Error: Please specify | return } elseif ($duration($4) < $duration(2m)) { notice $nick Error: Duration must be greater than 2 minutes. | return } else { var %duration = $duration($4) hadd -m timers # $+ . $+ $3 %duration 0 privmsg $iif($left($5,1) == $chr(35),$5-,$chan $5-) hsave timers timers.db if (!$timer(timers)) { .timertimers 0 1 timercheck } notice $nick Timer  $+ $3 $+  added to Message: $iif($left($5,1) == $chr(35),$5,$chan) $6- } } if ($2 == remove) { if (!$3) { notice $nick Error: You must specify a timer name. } else { if ($hget(timers,$chan $+ . $+ $3) == $null) { notice $nick Error: Invaild name. Vaild names are: $iif($timer.ids($chan),$v1,None) } else { hdel timers # $+ . $+ $3 notice $nick Deleted timer: $3 } } } } }