Project

General

Profile

Bell icon on menubar for new PM notification v0.1.1 » Bell icon on menubar for new PM notification v0.1.1.ini

Mr. BS, 12/21/2015 09:11 PM

 
; http://dev.adiirc.com/boards/5/topics/511
; Bell icon on menubar for new PM notification
; v0.1.1 by pereba

alias clearbell {
if ($hget(unreadpms)) hfree $v1
if ($menubar(bell).name) menubar -d $v1
}

on *:Nick: {
; transfer old nick data to new one
if ($hget(unreadpms,$nick).data && $query($newnick)) {
hdel unreadpms $nick | hadd -m unreadpms $newnick $v1
}
}

On *:Text:*:?: {
if ($nick != $active) {
$update($v1,$wid).add
}
}

On *:Active:?: {
if ($window($active).type != query) return
$update($active).clean
}

On *:Close:?: $update($target).clean

alias -l update {
if ($prop == add) {
hinc -m unreadpms $total | hadd -m unreadpms $1 $calc($gettok($hget(unreadpms,$1).data,1,32) +1) $2
}
elseif ($hget(unreadpms,$total) && $prop == clean) {
hadd unreadpms $total $calc($v1 - $gettok($hget(unreadpms,$1),1,32))
hdel unreadpms $1
}
if ($hget(unreadpms,$total)) menubar $iif($menubar(bell),-t bell,-a bell bell) $iif($osmajor < 7 && $osminor < 2,💬,🔔) $+ $supnumbers($hget(unreadpms,$total))
elseif ($menubar(bell).name) menubar -d $v1
}

alias -l supnumbers {
return $replace($1,0,⁰,1,¹,2,²,3,³,4,⁴,5,⁵,6,⁶,7,⁷,8,⁸,9,⁹)
}

alias -l total return total $+ $chr(44)

menu bell {
$submenu($bellmenu($1))
-
Clear All $chr(9) $chr(10008): /clearbell
}

alias -l bellmenu {
while ($1 <= $hget(unreadpms,0).item) {
if ($hget(unreadpms,$1).item == $total) return -
return $v1 $chr(9) $chr(40) $+ $gettok($hget(unreadpms,$1).data,1,32) $+ $chr(41) : window -a @ $+ $gettok($hget(unreadpms,$1).data,2,32)
}
}
(3-3/3)