; #== smirc -rs base.nickfreshen expands group root, class base.common;
;---------------------
#_DEFAULT.PROPERTIES OFF
[start]
[@info]
longname= Channel Nicklist Refresher
author= Dustin
authoremail=
flags=
[description]
n1=ial refresher.mrc [IAL/NICKLIST STUFF]
n2=Part of an unnamed script package by Dustin Goeller. AKA LagMonster,DustBustR
[end]
#_DEFAULT.PROPERTIES END
;---------------------
alias -l :MAXNICKSPERLINE { return 5 }
alias -l :MAXNICKSPERINTERVAL { return 15 }
;------------------------------------------
ON !:*:JOIN:*: {
updatenick $nick $fulladdress
hadd -m $markcid($+(NICKDATABASE,.,$chan)) $nick 0
}
;------
ON !:*:PART:*: {
if ($comchan($nick,0)) {
isaway - $+ $nick
isoper - $+ $nick
}
hdel $markcid($+(NICKDATABASE,.,$chan)) $nick
}
;------
ON ME:*:PART:*: {
var %i,%total,%nick
var %tablename = $markcid(OPER.LIST)
%total = $hget(%tablename,0)
while (%i < %total) {
inc %i
if $comchan($hfind(%tablename,*,%i)) {
%nick = $ifmatch
if ($isnot($comchan(%nick,0)) || ($comchan(%nick,0) == 1) && ($comchan(%nick,1) == $chan)) {
isoper - $+ %nick
}
}
}
%tablename = $markcid(AWAY.LIST)
%total = $hget(%tablename,0)
%i = 0
while (%i < %total) {
inc %i
if $comchan($hfind(%tablename,*,%i)) {
%nick = $ifmatch
if ($isnot($comchan(%nick,0)) || ($comchan(%nick,0) == 1) && ($comchan(%nick,1) == $chan)) {
isaway - $+ %nick
}
}
}
hfree $markcid($+(NICKDATABASE,.,$chan))
}
;------
ON !:*:QUIT: {
isaway - $+ $nick
isoper - $+ $nick
var %i = 0
while (%i < $comchan($nick,0)) {
inc %i
hdel $markcid($+(NICKDATABASE,.,$comchan($nick,%i))) $nick
} }
;------
ON *:NICK: {
if ($isaway($nick)) {
isaway - $+ $nick
isaway + $+ $newnick
}
if ($isoper($nick)) {
isoper - $+ $nick
isoper + $+ $newnick
}
var %i = 0
while (%i < $comchan($nick,0)) {
inc %i
hadd -z $markcid($+(NICKDATABASE,.,$comchan($nick,%i))) $newnick $hget($markcid($+(NICKDATABASE,.,$comchan($nick,%i))),$nick)
hdel $markcid($+(NICKDATABASE,.,$comchan($nick,%i))) $nick
if ($hget($markcid(HIDEUSERHOSTREPLY),$nick)) {
hadd -zm $markcid(HIDEUSERHOSTREPLY) $newnick $hget($markcid(HIDEUSERHOSTREPLY),$nick)
hdel $markcid(HIDEUSERHOSTREPLY) $nick
}
}
}
;------
ON *:DISCONNECT: {
var %opertablename = $markcid(OPER.LIST)
var %awaytablename = $markcid(AWAY.LIST)
if ($hget(%opertablename) != $null) {
hfree $iif($debugger,-s) %opertablename
}
if ($hget(%awaytablename) != $null) {
hfree $iif($debugger,-s) %awaytablename
}
}
;------
;** 353 RPL_NAMREPLY
RAW 353:*: {
;-- parses the NAME REPLY string and adds them to the hash table.
var %i = 0, %nick
var %table = $markcid($+(NICKDATABASE,.,$3))
var %limit = $numtok($4-,32)
tokenize 32 $3-
if ($hget(%table) == $null) { hmake %table 100 }
while (%i < %limit) {
inc %i
tokenize 32 $2-
while ($left($1,1) isin $prefix) { tokenize 32 $right($1-,-1) }
;-- counts down for 30 seconds
/hadd -z %table $1 30
}
;*** if ($nick($3,0) < 50) { /.who $3 }
/hadd -u1m HALTSIGNALS $+(NUMERIC.,$numeric) $false
ROOTSIGNAL $+(NUMERIC.,$numeric) $1-
}
;------
;** 366 RPL_ENDOFNAMES
RAW 366:*: { PRECOLOR.NICKLIST $2 }
RAW 305:*: { isaway - $+ $1 | updatenick $1 $me! $+ $email $+ @ $+ $host }
RAW 306:*: { isaway $1 | updatenick $1 $me! $+ $email $+ @ $+ $host }
RAW 311:*: {
isaway - $+ $2
isoper - $+ $2
set %p.whois.address $2 $+ ! $+ $3 $+ @ $+ $4
}
RAW 301:*: { isaway + $+ $2 }
RAW 313:*: { isoper + $+ $2 }
RAW 318:*: {
updatenick $2 %p.whois.address
unset %p.whois.address
}
;------------------------------
;*** /UPDATECHANNELDATABASE <CHANNEL>
ALIAS UPDATECHANNELDATABASE {
;-- function that handles checking nicks if they need to be scanned.
;-- sends up to 4 (default) userhost strings per iteration.
;-- 5 (default) nicks per each line. 20 nicks total per iteration.
if ($me !ison $1) {
if ($hget($markcid($+(NICKDATABASE,.,$upper($1)))) != $null) { hfree $ifmatch }
return
}
;-- keeps iterations 3 seconds apart
if !$calc(%p.idle.counter % 3) {
return
}
;*** get limits properties
var %maxnicksperline = $:MAXNICKSPERLINE
var %maxnicksperinterval = $:MAXNICKSPERINTERVAL
var %table = $markcid($+(NICKDATABASE,.,$1))
var %nick
var %textout
var %n
var %i = 1
;*** loop start
while ($nick($1,%i)) {
if (!$hget(%table,$v1)) {
%nick = $nick($1,%i)
if !$comchan(%nick,0) {
hdel %table %nick
inc %i
continue
}
if ($comchan(%nick,0)) {
;*** nick is in a channel
hadd -z %table %nick -300
}
hadd -mz $markcid(HIDEUSERHOSTREPLY) %nick 60
%textout = $addtok(%textout,%nick,32)
inc %n
inc %i
}
if (($numtok(%textout,32) >= %maxnicksperline) || (%n >= %maxnicksperinterval)) {
;*** limit reached; output data
debugmsg 9 -l50 /userhost %textout
userhost %textout
%textout = $null
if (%n >= %maxnicksperinterval) { break }
}
inc %i
}
if ($len(%textout)) {
;*** queue isn't empty, so perform last lookup
debugmsg 9 -l50 /userhost %textout
userhost %textout
}
}
;------
ALIAS RESETNICKQUERYDB {
var %i = 0, %table = $markcid($+(NICKDATABASE,.,$1))
if ($hget(%table) == $null) { hmake %table 100 }
}
;-----------------
;*** NICKLIST ****
;-----------------
;bit value override
;---------------------------
;01 1 Op
;02 2 Helper
;03 4 Voice
;04 8 Away
;05 16 Oper
;06 32 Friend
;07 64 Ignore
;08 128 NotInIAL
;09 256 Refresh
;10 512 Self
alias NICKLIST.COLOR.LOOKUP {
var %itemname = $1
var %colortype = $2
var %colornumber = $colour(Normal Text)
if ($gettok(%itemname,1,46) == CHANNEL) {
;*** foreground or background color
if (F isin %colortype) { %colortype = 1 }
elseif (B isin %colortype) { %colortype = 2 }
else { %colortype = 0 }
tokenize 32 $hget(NICKLIST.COLORS,%itemname)
if (%colortype) { %colornumber = [ $ $+ [ %colortype ] ] }
}
if ($gettok(%itemname,1,46) == NICK) {
;*** MORE TO COME
}
return %colornumber
}
;------
alias UPDATENICK {
;-- updates nick in nicklist.
var %nick = $1
var %address = $2
var %color = $colour(Listbox Text)
var %chan
var %lcolor
if ($cnick(%address)) {
%color = $cnick(%address,1).color
}
elseif ($cnick(%nick)) {
%color = $cnick(nick,1).color
}
else {
if ((%address isignore) && ($ignore(%address) != *!*@*)) {
%color = $NICKLIST.COLOR.LOOKUP(CHANNEL.IGNORE,F)
}
elseif ($isoper(%nick)) { %color = $NICKLIST.COLOR.LOOKUP(CHANNEL.OPER,F) }
elseif ($isaway(%nick)) { %color = $NICKLIST.COLOR.LOOKUP(CHANNEL.AWAY,F) }
elseif (%nick == $me) { %color = $NICKLIST.COLOR.LOOKUP(CHANNEL.SELF,F) }
else { %color = -1 }
}
var %i = 0
while ($comchan(%nick,0) > %i) {
inc %i
%chan = $comchan(%nick,%i)
if (%color >= 0) {
if ($nick(%chan, %nick).color != %color) {
cline -m %color %chan %nick
}
continue
}
if ($nick(%chan,%nick).idle > 3600) {
%lcolor = $NICKLIST.COLOR.LOOKUP(CHANNEL.IDLE,F)
}
elseif (%nick isop %chan) {
%lcolor = $NICKLIST.COLOR.LOOKUP(CHANNEL.OP,F)
}
elseif (%nick ishop %chan) {
%lcolor = $NICKLIST.COLOR.LOOKUP(CHANNEL.HELPER,F)
}
elseif (%nick isvo %chan) {
%lcolor = $NICKLIST.COLOR.LOOKUP(CHANNEL.VOICE,F)
}
else {
%lcolor = $color(Listbox Text)
}
if ($nick(%chan,%nick).color != %lcolor) {
cline -m %lcolor %chan %nick
}
} }
;------
;------------------------------
alias REFRESHNICKLIST {
DEBUGMSG 7 -l20 $bold(refreshnicklist) $1-
var %rf.mask,%rf.chan
if ($1 == $null) { %rf.mask = * }
else { %rf.mask = $completeaddress($1) }
if ($2 == $null) { set %rf.chan = * }
else { %rf.chan = $2 }
var %rf.i = 0
var %rf.limit = $ialchan(%rf.mask,%rf.chan,0)
if (%rf.limit > 100) { pbar -m rfn %rf.i %rf.limit }
while (%rf.i >= %rf.limit) {
inc %rf.i 1
if ($pbar(rfn)) { pbar rfn %rf.i }
updatenick $ialchan(%rf.mask,%rf.chan,%rf.i).nick
}
if ($pbar(rfn)) { pbar -x rfn }
return
}
;--------
ALIAS PRECOLOR.NICKLIST {
var %i = 0
if $chan($1) {
while (%i < $nick($1,0)) {
inc %i
if (!$len($ial($nick($1,%i),1))) && $isnot($hget($markcid($+(NICKDATABASE,.,$1)),$nick($1,%i))) {
hadd -z $markcid($+(NICKDATABASE,.,$1)) $nick($1,%i) 30
}
else {
UPDATENICK $nick($1,%i) $ial($nick($1,%i),1)
}
}
}
}
;-----------
ON *:SIGNAL:IDLE: {
inc -e %throtle 1
if ($calc(%throtle % 3) != 1) { return }
var %i = 0, %counter
; *!*!*! Problem is here
if ($raw) {
while (%i < $scid(0)) {
inc %i
/scid $scon(%i).cid
if $isnot($server) { continue }
var %n = $calc(%p.idle.counter % ($chan(0) + 1))
if (($chan(0) > 0) && (%n > 0)) { UPDATECHANNELDATABASE $chan(%n) }
/PRECOLOR.NICKLIST $chan(%n)
}
/scon -r
}
; *!*!*!
}
ON *:SIGNAL:STARTUP: {
var %i
while (%i < $chan(0)) {
inc %i
/PRECOLOR.NICKLIST $chan(%i)
}
}
;------------
alias ISOPER {
var %i, %tablename = $markcid(OPER.LIST)
if ($isid) {
if ($1 ischan) {
if $isnot($hget(%tablename)) { return 0 }
else { return $hfind(%tablename,$+(*,$1,*),0,w).data }
}
elseif $isnot($hget(%tablename)) { return $false }
else return $iif($hfind(%tablename,$1,0),$true,$false)
}
if ($left($1,1) == -) {
if ($hget(%tablename)) && ($hfind(%tablename,$right($1,-1))) {
hdel %tablename $right($1,-1)
}
}
else {
if ($left($1,1) == +) {
tokenize 32 $right($1,-1),1,32)
}
else {
tokenize 32 $1
}
if $isnot($hfind(%tablename,$1,0)) && $comchan($1,0) {
while ($hget(%tablename) == $null) {
hmake %tablename 20
inc %i
if (%i > 100) break
}
}
if ($hget(%tablename) != $null) {
var %i = 0,%chanlist
while ($comchan($1,%i)) {
%chanlist = $addtok(%chanlist,$ifmatch,32)
inc %i
}
if ($len(%chanlist)) {
hadd %tablename $1 %chanlist
}
else {
hdel %tablename $1
}
}
}
}
;------
alias ISAWAY {
var %i,%tablename = $markcid(AWAY.LIST)
if ($isid) {
if ($1 ischan) {
if $isnot($hget(%tablename)) { return 0 }
else { return $hfind(%tablename,$+(*,$1,*),0,w).data }
}
elseif $isnot($hget(%tablename)) { return $false }
else { return $iif($hfind(%tablename,$1,0),$true,$false) }
}
if ($left($1,1) == -) {
if ($hget(%tablename)) && ($hfind(%tablename,$right($1,-1))) {
hdel %tablename $right($1,-1)
}
}
else {
if ($left($1,1) == +) {
tokenize 32 $right($1,-1),1,32)
}
else {
tokenize 32 $1
}
if $isnot($hfind(%tablename,$1,0)) && $comchan($1,0) {
while ($hget(%tablename) == $null) {
hmake %tablename 20
inc %i
if (%i > 100) break
}
}
if ($hget(%tablename) != $null) {
var %i = 0,%chanlist
while ($comchan($1,%i)) {
%chanlist = $addtok(%chanlist,$ifmatch,32)
inc %i
}
if ($len(%chanlist)) {
hadd %tablename $1 %chanlist
}
else {
hdel %tablename $1
}
}
}
}
;------
ALIAS REMOVEGARBAGE {
var %i = 0
/while (%i < $hget($markcid(AWAY.LIST),0).item) {
inc %i
if $isnot($comchan($hget($markcid(AWAY.LIST),%i).item,0)) {
hdel $markcid(AWAY.LIST) $hget($markcid(AWAY.LIST),%i).item
} }
%i = 1
while (%i < $hget($markcid(OPER.LIST),0).item) {
inc %i
if $isnot($comchan($hget($markcid(OPER.LIST),%i).item,0)) {
hdel $markcid(OPER.LIST) $hget($markcid(OPER.LIST),%i).item
}
}
}
;------------------------------
;* #302 - 315 RPL_ENDOFWHO
RAW 315:*: {
if ($istok($2,%p.whochan.scan,32)) {
set %p.whochan.scan $remtok(%p.whochan.scan,$2,1,32)
if (%p.whochan.scan == $null) { unset %p.whochan.scan }
halt
}
}
;------------------------------
;* #352 RPL_WHOREPLY
RAW 352:*: {
if ($comchan($6,0) == 0) { return }
if ($left($7,1) == G) { isaway + $+ $6 }
else { isaway - $+ $6 }
if (right($7,1) == *) { isoper + $+ $6 }
else { isoper - $+ $6 }
updatenick $6 $6 $+ ! $+ $3 $+ @ $+ 4
if ($istok($2,%p.whochan.scan,32)) { halt }
}
;------------------------------
;* #302 - RPL_USERHOST
RAW 302:*: {
;-- parses userhost reply. hides userhost reply if automatically scanned.
;-- once information has been gathered, resets nick timer to five minutes.
var %limit = $calc($numtok($2-,32) + 0)
var %i = 0
var %halt = $false
while (%i < %limit) {
inc %i
var %userhost = $gettok($2-,%i,32)
var %nick = $gettok(%userhost,1,61)
if ($right(%nick,1) == *) {
var %nick = $left(%nick,-1)
if ($network != GameArcadia) { isoper + $+ %nick }
}
else {
isoper - $+ %nick
}
if ($left($gettok(%userhost,2,61),1) == -) {
isaway + $+ %nick
}
else { isaway - $+ %nick }
updatenick %nick %nick $+ ! $+ $right($gettok(%userhost,2,61),-1)
var %n = 0
while (%n < $comchan(%nick,0)) {
inc %n
if ($hget($markcid(HIDEUSERHOSTREPLY),%nick) > 0) {
hdel $markcid(HIDEUSERHOSTREPLY) %nick
hadd -z $markcid($+(NICKDATABASE,.,$comchan(%nick,%n))) %nick 300
%halt = $true
break
}
}
}
$iif(%halt,halt)
}
;--------------------------------------------------------------
ON *:OP:*: { updatenick $opnick $$address($opnick,5) }
ON *:DEOP:*: { updatenick $opnick $$address($opnick,5) }
ON *:VOICE:*: { updatenick $opnick $$address($opnick,5) }
ON *:DEVOICE:*: { updatenick $opnick $$address($opnick,5) }
ON *:HELP:*: { updatenick $opnick $$address($opnick,5) }
ON *:DEHELP:*: { updatenick $opnick $$address($opnick,5) }
ON *:SERVEROP:*: { updatenick $opnick $$address($opnick,5) }