All pastes #407230 Raw Edit

kAFKa Minimalist AFK

public text v1 · immutable
#407230 ·published 2007-03-22 23:38 UTC
rendered paste body
; kAFKa Minimalist AFK Message Notifier
; by Travis Rosenbaum [03/22/2007]
; ---
; Discreet notification of new messages.
; When a new message is recieved, the number
; of new messages appears in the upper left of
; the screen. Simply click to restore focus to
; the window with new messages.

; Can be used in any event:
; AddAFK <Target window name>

;New Channel Messages
on 1:TEXT:*:#: {
  AddAFK $chan
}

;New Query Messages
on 1:TEXT:*:?: {
  AddAFK $nick
}

;Creates a window showing the number of new messages
alias AddAFK {
  if ($window($1) != $active) {
    inc %AFK. $+ [ $1 ]
    window -dk0por +dL @AFK. $+ $1 0 0 $width([ % $+ [ AFK. $+ [ $1 ] ] ],Fixedsys,9,1) $height([ % $+ [ AFK. $+ [ $1 ] ] ],Fixedsys,9) @AFKWindow
    drawtext -bor @AFK. $+ $1 $rgb(255,255,255) $rgb(0,0,0) 0 0 [ % $+ [ AFK. $+ [ $1 ] ] ]
  }
}

;When number is clicked, close it and show channel\query window.
menu @AFKWindow {
  sclick:{
    var %afkwindow = $gettok($active,2,$asc(.))
    window -c $active
    if ($window(%afkwindow) != $null) {
      window -a %afkwindow
    }
    unset %AFK. $+ [ %afkwindow ]
  }
}