alias _refreshnotify {
  @ _notify = notify()
  //^notify - 
  @ delarray(n_off)
  @ delarray(n_on)
  fe ($_notify) nn {
    @ setitem(n_off $numitems(n_off) $nn!*@* not yet)}}
_refreshnotify
on #^connect 69 * {_refreshnotify;//^notify $_notify}
on ^notify_signon_uh * {
  echo $fparse(format_notify_signon_uh $tolower($strftime(%I:%M%p)) $0 $1)
  @ delitem(n_off $matchitem(n_off \*$0\*))
  @ setitem(n_on $numitems(n_on) $0!$1 $time())
  if (match(notify $tab_levels)) {
    addtab /m $0}
  if (match($0 $_nnotes)&&([$1]=~word(0 $_nnote[$encode($0)]))) {
    ^local aa $_nnote[$encode($0)]
    msg $0 $stripansicodes($datetime($word(1 $aa))) - argon notify note: $restw(2 $aa)
    @_nnote[$encode($0)]=[]
    remword _nnotes $0
    ge notify note for $0 has been delivered!}}
on ^notify_signoff_uh * {
  echo $fparse(format_notify_signoff_uh $tolower($strftime(%I:%M%p)) $0 $1)
  @ delitem(n_on $matchitem(n_on \*$0\*))
  @ setitem(n_off $numitems(n_off) $0!$1 $time())}
alias notify {
  if ([$0]) {
    switch ($*) {
    (-) {
      @delarray(n_on)
      @delarray(n_off)
      //notify -}
    (-*) {
      @delitem(n_on $matchitem(n_on $after(- $0)!*))
      @delitem(n_off $matchitem(n_off $after(- $0)!*))
      //notify $*}
    (*) {
      fe ($*) nn {
        @setitem(n_off $numitems(n_off) $strip(+ $nn!*@* not yet))}
      //notify $*}}} else {
      echo $box.head()
      if (numitems(n_on)) {
        echo $box.echo_head($(c.hk)[$(c.lc)$numdots(50 currently online) $(c.lc)$numdots(10 signon time)$(c.hk)])
        for (@xx=0, xx<numitems(n_on), @xx++) {
          echo $box.echo($(c.hk)[$(cl)$numdots(50 $word(0 $getitem(n_on $xx))) $(cl)$numdots(10 $_fixmtime($word(1 $getitem(n_on $xx))))$(c.hk)])}}
      if (numitems(n_off)) {
        echo $box.echo($(c.hk)[$(c.lc)$numdots(50 currently offline) $(c.lc)$numdots(10 last seen)$(c.hk)])
        for (@xx=0, xx<numitems(n_off), @xx++) {
          echo $box.echo($(c.hk)[$(cl)$numdots(50 $word(0 $getitem(n_off $xx))) $(cl)$numdots(10 ${word(2 $getitem(n_off $xx))?restw(1 $getitem(n_off $xx)):_fixmtime($word(1 $getitem(n_off $xx)))})$(c.hk)])}}
      echo $box.footer()}}

do //^notify $_notify

### notify notes, original by shade.
alias note {
  if ([$1]) {
    if ([$0]=~[*!*]&&(match($before(! $0) $notify()))) {
      if (matchitem(n_on $0 *)<0) {
        @_nnote[$encode($before(! $0))]=[$after(! $0) $time() $1-]
        push _nnotes $before(! $0)
        ge notify note for $before(! $0) \($after(! $0)\) now pending delivery.} else {
        ge $0 is already online. why not try \/msg instead? \;>}} else {
      ge $0 is not on your notify list.}} else {
    ausage note}}
alias unnote {
  if ([$0]) {
    if (match($0 $_nnotes)) {
      @_nnote[$encode($0)]=[]
      remword _nnotes $0
      ge removed notify note for $0.} else {
      ge there are no notes pending for $0.}} else {
    ausage unnote}}
alias notelist {
  if (_nnotes) {
    echo $box.head()
    wrapon 6
    fe ($_nnotes) aa {
      ^local bb $_nnote[$encode($aa)]
      echo $box.echo($datetime($word(1 $bb)) - $aa!$word(0 $bb): $restw(2 $bb))}
    wrapoff
    echo $box.footer()} else {
    ge there are no notes pending.}}

alias listnotes notelist
alias remnote unnote

alias ntdiff2 {
  @function_return=[$0]==[\?\?\?]?[$0]:tdiff2($0)}

### nidle: notify list idle checker, idea by psykotyk, code by shade.
alias nidle {if (numitems(n_on)) {
  ^local ni.
  ge checking notify list idle times.. one moment..
  for (@xx=0, xx<numitems(n_on), @xx++) {
    push ni.l $word(0 $getitem(n_on $xx)) $_getidle($before(! $getitem(n_on $xx)))}
  echo $box.head()
  echo $box.echo_head($(c.hk)[$(c.hw)$numdots(50 nick!user@host) $(c.hw)$numdots(12 idle time)$(c.hk)])
  fe ($ni.l) ni.n ni.t {
    echo $box.echo($(c.hk)[$(cl)$numdots(50 $ni.n) $(cl)$numdots(12 $nospace($ntdiff2($before(. $ni.t)))${after(. $ni.t)?[ $(c.lm)a]:})$(c.hk)])}
  echo $box.footer()} else {
  ge no users are currently online.}}
#sjk'97

