alias parseusermodes {
/*
* Fill the two variables below accordingly.
* When connected normally, mirc provides
* this information via $nickmode and $chanmodes
* but you can't use those in sockets. Ideally you
* should be getting them from the 005 raw, if supplied
*/
var %nickmode = $nickmode
var %chanmodes = $chanmodes
hfree -w usermodes
hmake usermodes 10
var %i = 1, %sign
while $mid($1,%i,1) != $null {
if ($v1 isin +-) %sign = $v1
else {
var %mode = $v1
if $2 != $null && %mode isincs %nickmode {
var %oppsign = $mid(-+,%sign $+ 1,1)
hadd usermodes %sign $+ %mode $addtok($hget(usermodes,%sign $+ %mode),$2,32)
hadd usermodes %oppsign $+ %mode $remtok($hget(usermodes,%oppsign $+ %mode),$2,32)
tokenize 32 $1 $3-
}
elseif ($matchtokcs(%chanmodes,%mode,1,44) != $null && $&
($findtokcs(%chanmodes,$v1,44) isnum 1-2 || ($v1 %sign == 3 +))) $&
tokenize 32 $1 $3-
}
inc %i
}
; done parsing, now just display the user modes
%i = 1
while $hget(usermodes,%i).item {
%mode = $v1
if ($hget(usermodes,$v1) != $null) {
var %nicks = $v1
echo -a %mode : %nicks
}
inc %i
}
hfree usermodes
}