; return wheter a user's mask (nick!user@host - you can use wildcards) has admin level
; YOUR ULIST HAS TO CONTAIN MASKS FOR IT TO WORK, if it's made of plain nicknames, try $nick in place of $fulladdress
alias -l isadmin { return $ulist($fulladdress,admin) }
; return hash table name
alias -l ht { return $+(helpqueue,$cid) }
; regex routine (find nickname tokens in hash table data)
alias -l nickreg { return $+(/(?<=^|\s)\Q,$replacexcs($1,\E,\E\\E\Q),\E(?=$|\s),/i) }
; queue joining non-admins and send message to all present admins 7s after last join
on @*:join:#: {
if (!$isadmin) {
hadd -m $ht $chan $hget($ht,$chan) $nick
$+(timer,$ht,$chr(1),$chan) 1 7 messageadmins
}
}
; voice next user in channel's queue
on @admin:text:!next:#:{
if ($hget($ht,$chan)) { mode $chan +v $gettok($v1,1,32) }
else { notice $nick Help queue of $chan is empty. }
}
; remove voiced users from queue
on *:voice:#: { hadd -m $ht $chan $remtok($hget($ht,$chan),$vnick,0,32) }
; remove kicked users from channel's queue; clear queue if kicked yourself
on *:kick:#: {
if ($knick == $me) { if ($hget($ht)) hdel $v1 $chan }
elseif (!$ulist($ial($knick),admin)) { hadd -m $ht $chan $remtok($hget($ht,$chan),$knick,0,32) }
}
; remove parting users from channel's queue; clear queue if parting yourself
on *:part:#: {
if ($nick == $me) { if ($hget($ht)) hdel $v1 $chan }
elseif (!$isadmin) { hadd -m $ht $chan $remtok($hget($ht,$chan),$nick,0,32) }
}
; remove quitting users from queue(s); clear queue if quitting yourself
on *:quit: {
if ($nick == $me) { if ($hget($ht)) hfree $v1 }
elseif (!$isadmin) {
while ($hfind($ht,$nickreg($nick),1,r).data) { hadd $ht $v1 $remtok($hget($ht,$v1),$nick,0,32) }
}
}
; update queue(s) on nickchange
on !*:nick: {
if (!$isadmin) {
while ($hfind($ht,$nickreg($nick),1,r).data) { hadd $ht $v1 $reptok($hget($ht,$v1),$nick,$newnick,0,32) }
}
}
; clear queue on disconnect
on *:disconnect: { if ($hget($ht)) hfree $v1 }
; send message to all admins on that channel (max. 4 target nicks per message)
alias -l messageadmins {
var %n = 1, %c = $gettok($ctimer,-1,1), %present
while ($ulist(*,admin,%n)) {
if ($ialchan($v1,%c,1).nick) {
var %present = $addtok(%present,$v1,44)
if ($numtok(%present,44) == 4) { notice $v1 $queuemessage(%c) | var %present }
}
inc %n
}
if (%present) { notice $v1 $queuemessage(%c) }
}
; message layout
alias -l queuemessage {
var %t = $numtok($hget($ht,$1),32)
return There $iif((%t > 1),are %t users,is $iif((%t == 1),one user,no user left)) in the help queue of $1 $+ .
}