All pastes #485321 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-05-12 23:39 UTC
rendered paste body
on $*:TEXT:/^!event ([^ ]+) (.+)$/Si:#events:{
  if ($nick($chan,$nick,ho)) {
    var %time = $regml(1), %event = $regml(2)
    if (!$regex(%time,/^([0-9]{1,2}):([0-9]{2})$/S)) .notice $nick Invalid time format - must be <hours>:<minutes>
    elseif ($gettok(%time,1,58) !isnum 0-23) || ($gettok(%time,2,58) !isnum 0-59) .notice $nick Invalid time.
    else {
      var %x = 1
      while ($($+(%,event.name.,%x),2)) inc %x
      set $+(%,event.name.,%x) %event
      set $+(%,event.time.,%x) %time
      $+(.timerevent.start.,%x) -o 1 $calc(($ctime($asctime(mmmm d yyyy) %time) - 12600) - $ctime) start.countdown %x
      .notice $nick Countdown will begin in $+($duration($calc(($ctime($asctime(mmmm d yyyy) %time) - 12600) - $ctime)),.)
    }
  }
}
alias -l start.countdown {
  $+(.timerevent.display.,$1) -o 5 300 display.event $1
  msg #events The event $qt($($+(%,event.name.,$1),2)) will start in 30 minutes.
}
alias -l display.event {
  msg #events The event $qt($($+(%,event.name.,$1),2)) will start in $calc(($timer($+(event.display.,$1)).reps + 1) * 5) minutes.
  if ($timer($+(event.display.,$1)).reps == 0) || (!$timer($+(event.display.,$1)).reps) $+(.timerevent.5mins.,$1) -o 4 60 last5mins $1
}
alias -l last5mins {
  msg #events The event $qt($($+(%,event.name.,$1),2)) will start in $calc($timer($+(event.5mins.,$1)).reps) $iif($timer($+(event.5mins.,$1)).reps == 0,minute.,minutes.)
  if ($timer($+(event.5mins.,$1)).reps == 0) || (!$timer($+(event.5mins.,$1)).reps) $+(.timerevent.on.,$1) -o 1 60 event.start $1
}
alias -l event.start {
  The event $qt($($+(%,event.name.,$1),2)) is now starting!
  unset $+(%,event.*.,$1)
}
on *:TEXT:!events:#events:{
  if ($var(%event.name.*,0) == 0) .notice $nick There are currently no events scheduled.
  else {
    var %a = 1
    while ($var(%event.name.*,%a)) {
      var %x = $gettok($v1,3,46)
      .timer 1 $calc(%a * .5) .notice $nick $+(%x,$chr(41)) $qt($($+(%,event.name.,%x),2)) - begins at $($+(%,event.time.,%x),2) $+($chr(40),in $duration($calc(($ctime($asctime(mmmm d yyyy) $($+(%,event.time.,%x),2)) - 10800) - $ctime)),$chr(41))
      inc %a
    }
  }
}
on $*:TEXT:/^!delevent ([0-9]+)$/Si:#events:{
  if ($nick($chan,$nick,ho)) {
    if ($($+(%,event.name.,$2),2)) {
      .notice $nick The event $qt($v1) has been deleted.
      unset $+(%,event.*.,$2)
      $+(.timerevent.*.,$2) off
    }
    else Event $2 does not exist. Type "!events" for a list of scheduled events.
  }
}