Difference between revisions of "Auth-Update2"
From Scriptwiki
m (added some ^ to events, to make sure they're processed before other scripts) |
m (typo) |
||
(7 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
This snippet is a new version of [[Auth-Update|Auth_update]] | This snippet is a new version of [[Auth-Update|Auth_update]] | ||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AUTH_UPDATE2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AUTH_UPDATE2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
− | ; | + | ; |
− | ; by Vliedel -- #vliedel @ QuakeNet | + | ; by Vliedel -- #vliedel @ QuakeNet |
− | ; version | + | ; version 2.3 (written and tested on mIRC 6.35) |
− | ; made for networks supporting WHOX | + | ; made for networks supporting WHOX |
− | ; | + | ; |
− | ; | + | ; |
− | ;What does this script do? | + | ;What does this script do? |
− | ; | + | ; |
− | ; - updates the auths of nicks and stores them in a hash table | + | ; - updates the auths of nicks and stores them in a hash table |
− | ; - if a channel is too big, /who nick1,nick2,nick3 etc is done | + | ; - if a channel is too big, /who nick1,nick2,nick3 etc is done until the auths for the channel is updated |
− | ; - users who have a site with the auth in it will be saved without a /who | + | ; - users who have a site with the auth in it will be saved without a /who |
− | ; ie: "Vliedel" in "Vliedel.users.quakenet.org" will be treated as auth on the QuakeNet network | + | ; ie: "Vliedel" in "Vliedel.users.quakenet.org" will be treated as auth on the QuakeNet network |
− | ; - users who are not authed (auth 0) will be checked every x time to see if they are authed yet | + | ; - users who are not authed (auth 0) will be checked every x time to see if they are authed yet |
− | ; - script updates from largest to the smallest channel | + | ; - script updates from largest to the smallest channel |
− | ; | + | ; |
− | ; | + | ; |
− | ;How to use this script? | + | ;How to use this script? |
− | ; | + | ; |
− | ; - config the options below | + | ; - config the options below |
− | ; - /load - | + | ; - /load -rs1 auth_update2.mrc to load the script (make sure the script it loaded on top) |
− | ; - script starts on load or on join | + | ; - script starts on load or on join |
− | ; - to get the auth of a nick use: $auth(nick) or $auth(nick,cid) | + | ; - to get the auth of a nick use: $auth(nick) or $auth(nick,cid) |
− | ; - to get a nick from an auth use: $auth-nick(auth) or $auth-nick(auth,cid) | + | ; - to get a nick from an auth use: $auth-nick(auth) or $auth-nick(auth,cid) |
− | ; - to recheck a nick that was not authed by command use: /auth.update <nick> | + | ; - to recheck a nick that was not authed by command use: /auth.update <nick> |
− | ; note that rechecking is done automatically, only use this command if you really want to recheck quickly | + | ; note that rechecking is done automatically, only use this command if you really want to recheck quickly |
− | ; | + | ; - this script should be loaded as last script in your list for optimal usage |
− | ; - You can use the following example script to see when a nicks auth is updated | + | ; |
− | ; on *:SIGNAL:authupdate.new:{ | + | ; - You can use the following example script to see when a nicks auth is updated |
− | ; if (!$2) { echo -ag $1 is not authed } | + | ; on *:SIGNAL:authupdate.new:{ |
− | ; else { echo -ag $1 is authed as $2 } | + | ; if (!$2) { echo -ag $1 is not authed } |
− | ; } | + | ; else { echo -ag $1 is authed as $2 } |
− | ; | + | ; } |
− | ; - The following signal is send when a requested auth is updated (with /auth.update <nick>) | + | ; |
− | ; on *:SIGNAL:authupdate.req:{ | + | ; - The following signal is send when a requested auth is updated (with /auth.update <nick>) |
− | ; if ($2 == $null) { echo -ag requested: $1 is not on a common chan } | + | ; on *:SIGNAL:authupdate.req:{ |
− | ; elseif ($2 == 0) { echo -ag requested: $1 is not authed } | + | ; if ($2 == $null) { echo -ag requested: $1 is not on a common chan } |
− | ; else { echo -ag requested: $1 is authed as $2 } | + | ; elseif ($2 == 0) { echo -ag requested: $1 is not authed } |
− | ; } | + | ; else { echo -ag requested: $1 is authed as $2 } |
− | ; | + | ; } |
− | ; Note that these signals return $2 == $null when someone isn't on a common channel. | + | ; |
− | ; This may occur for example when someone parted a channel between the /who and the who reply. | + | ; Note that these signals return $2 == $null when someone isn't on a common channel. |
− | ; | + | ; This may occur for example when someone parted a channel between the /who and the who reply. |
− | ; | + | ; |
− | ;Why is this script good? | + | ; |
− | ; | + | ;Why is this script good? |
− | ; - compared with my first auth_update, this script uses less resources, at the cost of a little bit more traffic | + | ; |
− | ; - sending /who chan for every channel is not needed and goes slow (lag) | + | ; - compared with my first auth_update, this script uses less resources, at the cost of a little bit more traffic |
− | ; - sending /who chan on join may cause Excess Flood or Max sendQ exceeded | + | ; - sending /who chan for every channel is not needed and goes slow (lag) |
− | ; - sending /who chan1,chan2,chan3 can be much faster, but only if there are not too many results (Max sendQ exceeded) | + | ; - sending /who chan on join may cause Excess Flood or Max sendQ exceeded |
− | ; - unauthed users can auth without you knowing, so you need to check if they're authed every so many time. | + | ; - sending /who chan1,chan2,chan3 can be much faster, but only if there are not too many results (Max sendQ exceeded) |
− | ; | + | ; - unauthed users can auth without you knowing, so you need to check if they're authed every so many time. |
− | ; | + | ; |
− | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | + | ; |
− | + | ;Since some people do not understand how to use this script on join, here is an example: | |
− | + | ; | |
− | + | ; on *:JOIN:#:{ | |
− | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SETTINGS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | + | ; newuser $chan $nick |
− | + | ; } | |
− | ; maximum number of replies in a WHO, too high may cause 'Max sendQ exceeded' disconnection | + | ; |
− | ; too low may take the script a long time to update the auths, 1000 should be fine for most situations | + | ; ; $1 = nick $2 = auth |
− | alias -l max.replies { return 1000 } | + | ; on *:SIGNAL:authupdate.new:{ |
− | + | ; if (*.users.quakenet.org iswm $ial($1)) { return } | |
− | ; maximum length of the /who <string>, too long may cause the server to ignore the command | + | ; var %i = 1 |
− | ; too low may slow things down, 400 should be fine in most cases | + | ; while ($comchan($1,%i)) { |
− | alias -l max.len { return 400 } | + | ; newuser $v1 $1 |
− | + | ; inc %i | |
− | ; minimum time (seconds) between two /who commands (default 10) | + | ; } |
− | alias -l delay { return 10 } | + | ; } |
− | + | ; | |
− | ; time (seconds) between the checking if any unauthed users should be rechecked (default 120) | + | ; ; $1 = chan $2 = nick |
− | alias -l queue.delay { return 120 } | + | ; alias -l newuser { |
− | + | ; var %auth = $auth($2) | |
− | ; time (seconds) to recheck if an unauthed user is now authed (default 600) | + | ; if (%auth) { echo 4 -tg $1 $2 is authed as %auth } |
− | alias -l queue.check { return 600 } | + | ; elseif (%auth == 0) { echo 4 -tg $1 $2 is not authed } |
− | + | ; } | |
− | ; minimum ratio of (nicks with unknown auth) / (total nicks) in a channel to do /who #channel rather then /who nick,nick, (default 0.09) | + | ; |
− | alias -l min.ratio { return 0.09 } | + | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
− | + | ||
− | ; minimum nr of nicks with unknown auth in a channel to do /who #channel rather then /who nick,nick, (default 10) | + | |
− | alias -l min.nicks { return 10 } | + | |
− | + | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SETTINGS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
− | ; The networks the script is supposed to work on (case sensitive) | + | |
− | ; NOTE that the script ONLY works on networks supporting WHOX (ircu 2.10.* should work) | + | ; maximum number of replies in a WHO, too high may cause 'Max sendQ exceeded' disconnection |
− | alias -l used.network { | + | ; too low may take the script a long time to update the auths, 1000 should be fine for most situations |
− | + | [[alias]] -l max.replies { [[return]] 1000 } | |
− | } | + | |
− | + | ; maximum length of the /who <string>, too long may cause the server to ignore the command | |
− | ; For every network a check to see if a user has a site where his authname is in | + | ; too low may slow things down, 400 should be fine in most cases |
− | ; $1 is the site | + | [[alias]] -l max.len { [[return]] 400 } |
− | alias -l auth.in.site { | + | |
− | + | ; minimum time (seconds) between two /who commands (default 10) | |
− | + | [[alias]] -l delay { [[return]] 10 } | |
− | + | ||
− | + | ; time (seconds) between the checking if any unauthed users should be rechecked (default 120) | |
− | + | [[alias]] -l queue.delay { [[return]] 120 } | |
− | + | ||
− | + | ; time (seconds) to recheck if an unauthed user is now authed (default 600) | |
− | } | + | [[alias]] -l queue.check { [[return]] 600 } |
− | + | ||
− | ; For every network the method to return the auth from the site | + | ; minimum ratio of (nicks with unknown auth) / (total nicks) in a channel to do /who #channel rather then /who nick,nick, (default 0.09) |
− | ; $1 is the site | + | [[alias]] -l min.ratio { [[return]] 0.09 } |
− | alias -l auth.from.site { | + | |
− | + | ; minimum nr of nicks with unknown auth in a channel to do /who #channel rather then /who nick,nick, (default 10) | |
− | + | [[alias]] -l min.nicks { [[return]] 10 } | |
− | + | ||
− | + | ; The networks the script is supposed to work on (case sensitive) | |
− | + | ; NOTE that the script ONLY works on networks supporting WHOX (ircu 2.10.* should work) | |
− | + | [[alias]] -l used.network { | |
− | + | [[return]] [[$istokcs]](QuakeNet UnderNet GameSurge HanIRC NetGamers OGameNet,[[$network]],32) | |
− | } | + | } |
− | + | ||
− | ; $auth(nick [,cid]) returns the auth of the nick | + | ; For every network a check to see if a user has a site where his authname is in |
− | alias auth { | + | ; $1 is the site |
− | + | [[alias]] -l auth.in.site { | |
− | + | [[Local_Variables|var]] %n = [[$network]] | |
− | + | [[If-Then-Else|if]] (%n === QuakeNet) { [[return]] [[$iif]](*.users.quakenet.org iswm [[$1-|$1]],[[$true]]) } | |
− | } | + | [[If-Then-Else|elseif]] (%n === UnderNet) { [[return]] [[$iif]](*.users.undernet.org iswm [[$1-|$1]],[[$true]]) } |
− | + | [[If-Then-Else|elseif]] (%n === GameSurge) { [[return]] [[$iif]](*.*.GameSurge iswm [[$1-|$1]],[[$true]]) } | |
− | ; $auth-nick(auth [,cid]) returns the first nick with that auth | + | [[If-Then-Else|elseif]] (%n === HanIRC) { [[return]] [[$iif]](*.users.HanIRC.org iswm [[$1-|$1]],[[$true]]) } |
− | alias auth-nick { | + | [[If-Then-Else|elseif]] (%n === NetGamers) { [[return]] [[$iif]](*.users.netgamers.org iswm [[$1-|$1]],[[$true]]) } |
− | + | [[If-Then-Else|elseif]] (%n === OGameNet) { [[return]] [[$iif]](*.user.OGameNet iswm [[$1-|$1]],[[$true]]) } | |
− | + | } | |
− | } | + | |
− | + | ; For every network the method to return the auth from the site | |
− | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AUTH.UPDATE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | + | ; $1 is the site |
− | + | [[alias]] -l auth.from.site { | |
− | ; /auth.update nick | + | [[Local_Variables|var]] %n = [[$network]] |
− | alias auth.update { | + | [[If-Then-Else|if]] (%n === QuakeNet) { [[return]] [[$gettok]]([[$1-|$1]],1,46) } |
− | + | [[If-Then-Else|elseif]] (%n === UnderNet) { [[return]] [[$gettok]]([[$1-|$1]],1,46) } | |
− | + | [[If-Then-Else|elseif]] (%n === GameSurge) { [[return]] [[$gettok]]([[$1-|$1]],1,46) } | |
− | + | [[If-Then-Else|elseif]] (%n === HanIRC) { [[return]] [[$gettok]]([[$1-|$1]],1,46) } | |
− | + | [[If-Then-Else|elseif]] (%n === NetGamers) { [[return]] [[$gettok]]([[$1-|$1]],1,46) } | |
− | + | [[If-Then-Else|elseif]] (%n === OGameNet) { [[return]] [[$gettok]]([[$1-|$1]],1,46) } | |
− | } | + | } |
− | + | ||
− | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AU.UPDATE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | + | ; $auth(nick [,cid]) returns the auth of the nick |
− | + | [[alias]] auth { | |
− | ; $1 = t/n/c/r (timer nick chan repeat) | + | [[If-Then-Else|if]] (![[$isid]]) { [[$iif]]([[$show]],.auth,auth) [[$1-|$1-]] | [[return]] } |
− | ; [$1- = n nick] | + | [[If-Then-Else|if]] ([[$1-|$1]] == [[$null]]) || ([[$1-|$2]] !== [[$null]] && (![[$scid]]([[$1-|$2]]) || ![[$1-|$2]])) { [[return]] } |
− | alias -l au.update { | + | [[return]] [[$gettok]]([[$hget]]([[$iif]]([[$1-|$2]],[[$1-|$2]],[[$cid]]) [[DollarPlus|$+]] .auths,[[DollarPlus|$+]](auth.,[[$comchan]]([[$1-|$1]],1),[[$chr]](44),[[$1-|$1]])),1,32) |
− | + | } | |
− | + | ||
− | + | ; $auth-nick(auth [,cid]) returns the first nick with that auth | |
− | + | [[alias]] auth-nick { | |
− | + | [[If-Then-Else|if]] ([[$1-|$1]] == [[$null]]) || ([[$1-|$2]] !== [[$null]] && (![[$scid]]([[$1-|$2]]) || ![[$1-|$2]])) { [[return]] } | |
− | + | [[return]] [[$gettok]]([[$hfind]]([[$iif]]([[$1-|$2]],[[$1-|$2]],[[$cid]]) [[DollarPlus|$+]] .auths,[[$1-|$1]],1,n).data,-1,44) | |
− | + | } | |
− | + | ||
− | + | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AUTH.UPDATE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
− | ; | + | |
− | + | ; /auth.update nick | |
− | + | [[alias]] auth.update { | |
− | + | [[If-Then-Else|if]] (!$used.network) || (![[$comchan]]([[$1-|$1]],1)) { [[return]] } | |
− | + | [[Local_Variables|var]] %t = [[$cid]] [[DollarPlus|$+]] .auths , %a = [[$hget]](%t,[[DollarPlus|$+]](auth.,[[$comchan]]([[$1-|$1]],1),[[$chr]](44),[[$1-|$1]])) | |
− | + | [[If-Then-Else|if]] (0 * iswm %a) { [[hdel]] -w %t [[DollarPlus|$+]](auth.,*,[[$chr]](44),[[$1-|$1]]) } | |
− | + | [[If-Then-Else|if]] (!%a) || (0 * iswm %a) { au.update n [[$1-|$1]] | [[hadd]] %t req. [[DollarPlus|$+]] [[$1-|$1]] 1 } | |
− | + | [[If-Then-Else|else]] { .[[signal]] authupdate.req [[$1-|$1]] %a } | |
− | + | } | |
− | + | ||
− | + | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AU.UPDATE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
− | + | ||
− | + | ; $1 = t/n/c/r/d (timer nick chan repeat delay) | |
− | + | ; [$1- = n nick] | |
− | + | [[alias]] -l au.update { | |
− | + | [[Local_Variables|var]] %t = [[$cid]] [[DollarPlus|$+]] .auths | |
− | + | [[If-Then-Else|if]] (![[$hget]](%t)) { [[hmake]] %t } | |
− | + | [[Local_Variables|var]] %tim = au.update.delay. [[DollarPlus|$+]] [[$cid]] , %w = [[$hget]](%t,who) , %l = [[$hget]](%t,wholock) | |
− | + | ; when not called by repeat or delay, we probably have something to /who | |
− | + | [[If-Then-Else|if]] (([[$1-|$1]] != r) && ([[$1-|$1]] != d)) { [[hadd]] %t who 1 } | |
− | + | ; if we're waiting for reply, don't set timer or /who | |
− | + | [[If-Then-Else|if]] (%l) { [[return]] } | |
− | + | ; if called by delay timer and we probably have something to /who, then /who | |
− | + | [[If-Then-Else|if]] (([[$1-|$1]] == d) && (%w)) { au.who | [[return]] } | |
− | + | ; if delay timer hasn't been set already, we want to /who or set the timer | |
− | + | [[If-Then-Else|if]] (!$timer(%tim)) { | |
− | + | ; if we just joined a chan or just finished a /who, then set delay timer | |
− | + | [[If-Then-Else|if]] (([[$1-|$1]] == c) || ([[$1-|$1]] == r)) { .[[timer]] [[DollarPlus|$+]] %tim 1 $delay au.update d } | |
− | + | [[If-Then-Else|else]] { au.who [[$iif]]([[$1-|$1]] == n,[[$1-|$2]]) } | |
− | + | } | |
− | + | } | |
− | + | ||
− | + | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; NICKLIST CHANGING EVENTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
− | + | on ^*:JOIN:#:{ | |
− | + | [[Local_Variables|var]] %t = [[$cid]] [[DollarPlus|$+]] .auths | |
− | + | [[If-Then-Else|if]] (!$used.network) { [[return]] } | |
− | + | [[If-Then-Else|if]] ([[$nick_(remote)|$nick]] == [[$me]]) { | |
− | + | au.start | |
− | + | [[return]] | |
− | + | } | |
− | + | [[If-Then-Else|if]] (![[$hget]](%t)) { [[return]] } | |
− | + | [[If-Then-Else|if]] ([[$hfind]](%t,[[DollarPlus|$+]](auth.*,[[$chr]](44),[[$nick_(remote)|$nick]]),1,w)) { [[hadd]] %t [[DollarPlus|$+]](auth.,[[$chan_(remote)|$chan]],[[$chr]](44),[[$nick_(remote)|$nick]]) [[$hget]](%t,[[$v1]]) } | |
− | + | [[If-Then-Else|elseif]] ($auth.in.site($site)) { au.upd.nick [[$nick_(remote)|$nick]] $site } | |
− | + | [[If-Then-Else|else]] { au.update n [[$nick_(remote)|$nick]] } | |
− | + | } | |
− | + | ||
− | + | ;366 Vliedel #vliedel :End of /NAMES list. | |
− | + | RAW 366:*:{ | |
− | + | [[Local_Variables|var]] %c = [[$1-|$2]], %i = [[$nick_(nick)|$nick(]]%c,0), %w = auth.* [[DollarPlus|$+]] [[$chr]](44), %it = [[DollarPlus|$+]](auth.,%c,[[$chr]](44)), %t = [[$cid]] [[DollarPlus|$+]] .auths | |
− | + | [[while]] (%i) { | |
− | + | [[Local_Variables|var]] %n = [[$nick_(nick)|$nick(]]%c,%i) | |
− | + | [[If-Then-Else|if]] ([[$hfind]](%t,%w [[DollarPlus|$+]] %n,1,w)) { | |
− | } | + | [[tokenize]] 32 [[$hget]](%t,[[$v1]]) |
− | + | [[hadd]] %t %it [[DollarPlus|$+]] %n [[$1-|$1]] [[$iif]]([[$1-|$2]],%c) [[$1-|$3]] | |
− | + | } | |
− | + | [[dec]] %i | |
− | + | } | |
− | + | au.update c | |
− | + | } | |
− | + | ||
− | + | on *:PART:#:{ au.part [[$chan_(remote)|$chan]] [[$nick_(remote)|$nick]] | au.upd.nick [[$nick_(remote)|$nick]] $site [[$chan_(remote)|$chan]] } | |
− | + | on *:KICK:#:{ au.part [[$chan_(remote)|$chan]] $knick | au.upd.nick [[$nick_(remote)|$nick]] $site } | |
− | + | ||
− | + | ; $1 = chan $2 = nick | |
− | + | [[alias]] -l au.part { | |
− | + | [[Local_Variables|var]] %t = [[$cid]] [[DollarPlus|$+]] .auths | |
− | + | [[If-Then-Else|if]] (![[$hget]](%t)) { [[return]] } | |
− | + | [[If-Then-Else|if]] ([[$1-|$2]] == [[$me]]) { | |
− | + | [[hdel]] -w %t auth. [[DollarPlus|$+]] [[$chan_(remote)|$chan]] [[DollarPlus|$+]] ,* | |
− | + | [[hdel]] %t ctime. [[DollarPlus|$+]] [[$chan_(remote)|$chan]] | |
− | + | [[Local_Variables|var]] %i = [[$hfind]](%t,req.*,0,w) | |
− | + | [[while]] (%i) { | |
− | + | [[Local_Variables|var]] %it = [[$hfind]](%t,req.*,%i,w) , %n = [[$gettok]](%it,2,46) | |
− | + | [[If-Then-Else|if]] (%n ison [[$1-|$1]]) && (![[$comchan]](%n,2)) { [[hdel]] %t %it | .[[signal]] authupdate.req %n } | |
− | + | [[dec]] %i | |
− | + | } | |
− | + | } | |
− | + | [[If-Then-Else|else]] { | |
− | + | [[hdel]] %t [[DollarPlus|$+]](auth.,[[$1-|$1]],[[$chr]](44),[[$1-|$2]]) | |
− | + | [[If-Then-Else|if]] ([[$hget]](%t,req. [[DollarPlus|$+]] [[$1-|$2]])) && (![[$comchan]]([[$1-|$2]],2)) { [[hdel]] %t req. [[DollarPlus|$+]] [[$1-|$2]] | .[[signal]] authupdate.req [[$1-|$2]] } | |
− | + | } | |
− | + | } | |
− | + | ||
− | + | on *:QUIT:{ | |
− | + | [[Local_Variables|var]] %t = [[$cid]] [[DollarPlus|$+]] .auths | |
− | + | [[If-Then-Else|if]] (![[$hget]](%t)) { [[return]] } | |
− | + | [[hdel]] -w %t [[DollarPlus|$+]](auth.,*,[[$chr]](44),[[$nick_(remote)|$nick]]) | |
− | + | [[If-Then-Else|if]] ([[$hget]](%t,req. [[DollarPlus|$+]] [[$nick_(remote)|$nick]])) { [[hdel]] %t req. [[DollarPlus|$+]] [[$nick_(remote)|$nick]] | .[[signal]] authupdate.req [[$nick_(remote)|$nick]] } | |
− | + | } | |
− | + | ||
− | + | on ^*:NICK:{ | |
− | + | [[Local_Variables|var]] %i = [[$comchan]]($newnick,0) , %t = [[$cid]] [[DollarPlus|$+]] .auths | |
− | + | [[If-Then-Else|if]] ([[$nick_(remote)|$nick]] == $newnick) || (![[$hget]](%t)) { [[return]] } | |
− | + | [[while]] (%i) { | |
− | + | [[Local_Variables|var]] %it = [[DollarPlus|$+]](auth.,[[$comchan]]($newnick,%i),[[$chr]](44)) | |
− | + | [[$iif]]([[$hget]](%t,%it [[DollarPlus|$+]] [[$nick_(remote)|$nick]]),hadd,hdel) %t %it [[DollarPlus|$+]] $newnick [[$v1]] | |
− | + | [[hdel]] %t %it [[DollarPlus|$+]] [[$nick_(remote)|$nick]] | |
− | + | [[dec]] %i | |
− | + | } | |
− | + | [[If-Then-Else|if]] ([[$hget]](%t,req. [[DollarPlus|$+]] [[$nick_(remote)|$nick]])) { [[hadd]] %t req. [[DollarPlus|$+]] $newnick 1 | [[hdel]] %t req. [[DollarPlus|$+]] [[$nick_(remote)|$nick]] } | |
− | + | [[If-Then-Else|if]] ($auth.in.site($site)) { au.upd.nick $newnick $site } | |
− | + | } | |
− | + | ||
− | + | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AU.WHO ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
− | + | ||
− | + | ; [$1 = nick] | |
− | + | [[alias]] -l au.who { | |
− | + | [[Local_Variables|var]] %t = [[$cid]] [[DollarPlus|$+]] .auths , %t2 = [[$cid]] [[DollarPlus|$+]] .au.who | |
− | + | [[If-Then-Else|if]] ([[$hget]](%t2)) { [[hfree]] %t2 } | |
− | + | [[hmake]] %t2 | |
− | + | [[hdel]] %t who | |
− | + | [[If-Then-Else|if]] ([[$1-|$1]]) { | |
− | + | [[Local_Variables|var]] %who = [[$1-|$1]] [[DollarPlus|$+]] ,,, [[DollarPlus|$+]] 137 | |
− | + | [[hadd]] %t2 -mask %who | |
− | + | [[hadd]] %t wholock 1 | |
− | + | who %who n%nat,137 | |
− | + | [[return]] | |
− | + | } | |
− | + | [[Local_Variables|var]] %i = [[$comchan]]([[$me]],0) , %sort , %ticks = [[$ticks]] | |
− | + | [[while]] (%i) { | |
− | + | [[Local_Variables|var]] %sort = %sort [[$nick_(nick)|$nick(]][[$comchan]]([[$me]],%i),0) [[DollarPlus|$+]] . [[DollarPlus|$+]] %i | |
− | + | [[dec]] %i | |
− | + | } | |
− | + | [[Local_Variables|var]] %sort = [[$sorttok]](%sort,32,n) , %i = [[$numtok]](%sort,32) , %maxlen = $max.len , %n.max = $max.replies , %time = [[$calc]]([[$ctime]] - $queue.check) , %ids , %n.w , %len, %chans | |
− | + | [[while]] (%i) { | |
− | + | [[Local_Variables|var]] %c = [[$comchan]]([[$me]],[[$gettok]]([[$gettok]](%sort,%i,32),2,46)) , %n.0 = [[$hfind]](%t,0 %c &,0,w).data , %n.c = [[$nick_(nick)|$nick(]]%c,0) | |
− | + | [[Local_Variables|var]] %n.l = [[$calc]](%n.c - [[$hfind]](%t,[[DollarPlus|$+]](auth.,%c,[[$chr]](44),*),0,w) + [[$iif]](%time < [[$hget]](%t,ctime. [[DollarPlus|$+]] %c),0,%n.0)) | |
− | + | [[If-Then-Else|if]] ([[$calc]](%len + [[$len]](%c) +1) > %maxlen) || ([[$calc]](%n.w + %n.c) > %n.max) { [[dec]] %i | [[continue]] } | |
− | + | [[If-Then-Else|if]] (%n.l > 1) && ((%n.l >= $min.nicks) || ([[$calc]](%n.l / %n.c) >= $min.ratio)) { | |
− | + | [[Local_Variables|var]] %chans = %chans %c | |
− | + | [[hadd]] %t ctime. [[DollarPlus|$+]] %c [[$ctime]] | |
− | + | [[Local_Variables|var]] %j = [[$nick_(nick)|$nick(]]%c,0) | |
− | + | [[while]] (%j) { | |
− | + | [[Local_Variables|var]] %n = [[$nick_(nick)|$nick(]]%c,%j) | |
− | + | [[If-Then-Else|if]] (![[$hget]](%t2,%n)) { [[hadd]] %t2 %n 1 | [[inc]] %n.w } | |
− | + | [[dec]] %j | |
− | + | } | |
− | + | [[inc]] %len [[$calc]]([[$len]](%c) +1) | |
− | + | } | |
− | + | [[dec]] %i | |
− | + | } | |
− | + | [[Local_Variables|var]] %i = [[$comchan]]([[$me]],0) , %nicks | |
− | + | [[while]] (%i) { | |
− | + | [[Local_Variables|var]] %c = [[$comchan]]([[$me]],%i) | |
− | + | [[If-Then-Else|if]] (![[$istok]](%chans,%c,32)) { | |
− | + | [[If-Then-Else|if]] ([[$calc]]([[$nick_(nick)|$nick(]]%c,0) - [[$hfind]](%t,[[DollarPlus|$+]](auth.,%c,[[$chr]](44),*),0,w)) > 0) { | |
− | + | [[Local_Variables|var]] %j = [[$nick_(nick)|$nick(]]%c,0) | |
− | + | [[while]] (%j) { | |
− | + | [[Local_Variables|var]] %n = [[$nick_(nick)|$nick(]]%c,%j) | |
− | + | [[If-Then-Else|if]] ([[$calc]](%len + [[$len]](%n) +1) > %maxlen) { [[goto]] end } | |
− | + | [[Local_Variables|var]] %val = [[$hget]](%t,[[DollarPlus|$+]](auth.,%c,[[$chr]](44),%n)) | |
− | + | [[If-Then-Else|if]] (![[$hget]](%t2,%n)) && ((%val == [[$null]]) || ([[$gettok]](%val,3,32) < %time)) { [[Local_Variables|var]] %nicks = %nicks %n | [[hadd]] %t2 %n 1 | [[inc]] %n.w | [[inc]] %len [[$len]](%n) } | |
− | + | [[If-Then-Else|if]] (%n.w >= %n.max) { [[goto]] end } | |
− | + | [[dec]] %j | |
− | + | } | |
− | + | } | |
− | + | [[If-Then-Else|else]] { | |
− | + | [[Local_Variables|var]] %j = [[$hfind]](%t,0 %c &,0,w).data | |
− | } | + | [[while]] (%j) { |
− | + | [[Local_Variables|var]] %it = [[$hfind]](%t,0 %c &,%j,w).data , %n = [[$gettok]](%it,2,44) | |
− | + | [[If-Then-Else|if]] ([[$calc]](%len + [[$len]](%n) +1) > %maxlen) { [[goto]] end } | |
− | + | [[If-Then-Else|if]] (![[$hget]](%t2,%n)) && ([[$gettok]]([[$hget]](%t,%it),3,32) < %time) && (auth.* iswm %it) { [[Local_Variables|var]] %nicks = %nicks %n | [[hadd]] %t2 %n 1 | [[inc]] %n.w | [[inc]] %len [[$len]](%n) } | |
− | + | [[If-Then-Else|if]] (%n.w >= %n.max) { [[goto]] end } | |
− | + | [[dec]] %j | |
− | + | } | |
− | + | } | |
− | + | } | |
− | + | [[dec]] %i | |
− | + | } | |
− | + | :end | |
− | + | [[Local_Variables|var]] %who = [[$replace]](%chans %nicks,[[$chr]](32),[[$chr]](44)) | |
− | + | [[If-Then-Else|if]] (%who) { | |
− | + | [[Local_Variables|var]] %who = %who [[DollarPlus|$+]] ,,, [[DollarPlus|$+]] 137 | |
− | + | [[hadd]] %t2 -mask %who | |
− | + | [[hadd]] %t wholock 1 | |
− | + | who %who n%nat,137 | |
− | + | [[If-Then-Else|if]] (%len > [[$calc]](%maxlen * 0.7)) || (%n.w > [[$calc]](%n.max * 0.7)) { [[hadd]] %t who 1 } | |
− | + | } | |
− | + | [[If-Then-Else|else]] { au.update r } | |
− | + | } | |
− | + | ||
− | + | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RAW REPLIES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
− | + | ; RAW 354 SPECIAL WHO REPLY | |
− | + | ; 354 <you> <nr> <nick> <auth> | |
− | + | ; 354 Vliedel 137 sy rry | |
− | + | RAW 354:& 137 & &:{ | |
− | + | [[haltdef]] | |
− | + | [[Local_Variables|var]] %i = [[$comchan]]([[$1-|$3]],0) , %t = [[$cid]] [[DollarPlus|$+]] .auths | |
− | + | [[If-Then-Else|if]] ([[$hget]](%t,req. [[DollarPlus|$+]] [[$1-|$3]])) { [[hdel]] %t req. [[DollarPlus|$+]] [[$1-|$3]] | .[[signal]] authupdate.req [[$1-|$3]] [[$iif]](%i,[[$1-|$4]]) } | |
− | + | [[If-Then-Else|if]] (!%i) || (![[$hget]](%t)) { [[return]] } | |
− | + | [[If-Then-Else|if]] ([[$gettok]]([[$hget]](%t,[[DollarPlus|$+]](auth.,[[$comchan]]([[$1-|$3]],1),[[$chr]](44),[[$1-|$3]])),1,32) !== [[$1-|$4]]) { .[[signal]] authupdate.new [[$1-|$3]] [[$1-|$4]] } | |
− | + | [[while]] (%i) { | |
− | + | [[Local_Variables|var]] %c = [[$comchan]]([[$1-|$3]],%i) | |
− | + | [[hadd]] %t [[DollarPlus|$+]](auth.,%c,[[$chr]](44),[[$1-|$3]]) [[$1-|$4]] [[$iif]](![[$1-|$4]],%c [[$ctime]]) | |
− | + | [[dec]] %i | |
− | + | } | |
− | + | } | |
− | + | ||
− | + | ; RAW 315 WHO END | |
− | + | ; 315 <you> <requested> :End of /who list. | |
− | + | ; 315 Vliedel #vliedel,,,137 :End of /WHO list. | |
− | + | RAW 315:& *,,,137 end of /WHO list.: { | |
− | + | [[If-Then-Else|if]] ([[$hget]]([[$cid]] [[DollarPlus|$+]] .au.who,-mask) == [[$1-|$2]]) { | |
− | + | [[Local_Variables|var]] %who = [[$left]]([[$1-|$2]],-6) , %i = [[$wildtok]](%who,#*,0,44) , %t = [[$cid]] [[DollarPlus|$+]] .auths | |
− | + | [[while]] (%i) { | |
− | } | + | [[hadd]] %t ctime. [[DollarPlus|$+]] [[$wildtok]](%who,#*,%i,44) [[$ctime]] |
− | + | [[dec]] %i | |
− | ;;;;;; | + | } |
− | + | [[hfree]] [[$cid]] [[DollarPlus|$+]] .au.who | |
− | + | [[hdel]] %t wholock | |
− | + | au.update r | |
− | + | [[haltdef]] | |
− | + | } | |
− | + | } | |
− | + | ||
− | + | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; STARTING AND STOPPING ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
− | + | on *:LOAD:{ scon -at1 au.load l } | |
− | + | [[alias]] -l au.load { | |
− | + | au.stop | |
− | + | au.start | |
− | ; TIMER au.update.<cid> | + | au.update t |
+ | } | ||
+ | |||
+ | [[alias]] -l au.stop { | ||
+ | .[[timer]] [[DollarPlus|$+]] au.update. [[DollarPlus|$+]] [[$cid]] off | ||
+ | .[[timer]] [[DollarPlus|$+]] au.update.delay. [[DollarPlus|$+]] [[$cid]] off | ||
+ | [[If-Then-Else|if]] ([[$hget]]([[$cid]] [[DollarPlus|$+]] .auths)) { [[hfree]] [[$v1]] } | ||
+ | [[If-Then-Else|if]] ([[$hget]]([[$cid]] [[DollarPlus|$+]] .au.who)) { [[hfree]] [[$v1]] } | ||
+ | } | ||
+ | |||
+ | [[alias]] -l au.start { | ||
+ | [[If-Then-Else|if]] (!$used.network) { [[return]] } | ||
+ | [[If-Then-Else|if]] (![[$hget]]([[$cid]] [[DollarPlus|$+]] .auths)) { [[hmake]] [[$cid]] [[DollarPlus|$+]] .auths } | ||
+ | [[If-Then-Else|if]] (!$timer(au.update. [[DollarPlus|$+]] [[$cid]])) { .[[timer]] [[DollarPlus|$+]] au.update. [[DollarPlus|$+]] [[$cid]] 0 $queue.delay au.update t } | ||
+ | } | ||
+ | |||
+ | on *:DISCONNECT:{ au.stop } | ||
+ | on *:UNLOAD:{ scon -a au.stop } | ||
+ | |||
+ | |||
+ | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IAL-UPDATING EVENTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
+ | on ^*:TEXT:*:*:{ au.upd.nick [[$nick_(remote)|$nick]] $site } | ||
+ | on ^*:ACTION:*:*:{ au.upd.nick [[$nick_(remote)|$nick]] $site } | ||
+ | on ^*:NOTICE:*:*:{ au.upd.nick [[$nick_(remote)|$nick]] $site } | ||
+ | on ^*:RAWMODE:#:{ au.upd.nick [[$nick_(remote)|$nick]] $site } | ||
+ | on ^*:TOPIC:#:{ au.upd.nick [[$nick_(remote)|$nick]] $site } | ||
+ | on ^*:INVITE:#:{ au.upd.nick [[$nick_(remote)|$nick]] $site } | ||
+ | [[CTCP]] *:*:*:{ au.upd.nick [[$nick_(remote)|$nick]] $site } | ||
+ | RAW 352:& & & & & & & & *:{ au.upd.nick [[$1-|$6]] [[$1-|$4]] } | ||
+ | |||
+ | ; $1 = nick $2 = site [ $3 = chan (exclude it)] | ||
+ | [[alias]] -l au.upd.nick { | ||
+ | [[If-Then-Else|if]] (!$auth.in.site([[$1-|$2]])) || (![[$hget]]([[$cid]] [[DollarPlus|$+]] .auths)) { [[return]] } | ||
+ | [[Local_Variables|var]] %i = [[$comchan]]([[$1-|$1]],0) , %t = [[$cid]] [[DollarPlus|$+]] .auths , %au = $auth.from.site([[$1-|$2]]) | ||
+ | [[If-Then-Else|if]] (!%i) || (%i == 1 && [[$1-|$3]]) || ([[$hget]](%t,[[DollarPlus|$+]](auth.,[[$comchan]]([[$1-|$1]],1),[[$chr]](44),[[$1-|$1]])) == %au) { [[return]] } | ||
+ | [[while]] (%i) { | ||
+ | [[If-Then-Else|if]] ([[$comchan]]([[$1-|$1]],%i) !== [[$1-|$3]]) { [[hadd]] %t [[DollarPlus|$+]](auth.,[[$v1]],[[$chr]](44),[[$1-|$1]]) %au } | ||
+ | [[dec]] %i | ||
+ | } | ||
+ | .[[signal]] authupdate.new [[$1-|$1]] %au | ||
+ | } | ||
+ | |||
+ | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; USED DATA/TIMERS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
+ | |||
+ | ; TABLE <cid>.auths | ||
+ | ;auth.<chan>,<nick> --> <auth> [chan ctime] | ||
+ | ;req.<nick> --> 1 | ||
+ | ;ctime.<chan> --> <ctime> | ||
+ | ;who --> <1/null> | ||
+ | ;wholock --> <1/null> | ||
+ | |||
+ | ; TABLE <cid>.au.who | ||
+ | ; nick --> 1 | ||
+ | ; -mask --> /who string | ||
+ | |||
+ | ; TIMER au.update.delay.<cid> | ||
+ | ; TIMER au.update.<cid> | ||
[[Category:Script_Archive]] | [[Category:Script_Archive]] |
Latest revision as of 15:40, 6 August 2013
This snippet is a new version of Auth_update
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AUTH_UPDATE2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; by Vliedel -- #vliedel @ QuakeNet ; version 2.3 (written and tested on mIRC 6.35) ; made for networks supporting WHOX ; ; ;What does this script do? ; ; - updates the auths of nicks and stores them in a hash table ; - if a channel is too big, /who nick1,nick2,nick3 etc is done until the auths for the channel is updated ; - users who have a site with the auth in it will be saved without a /who ; ie: "Vliedel" in "Vliedel.users.quakenet.org" will be treated as auth on the QuakeNet network ; - users who are not authed (auth 0) will be checked every x time to see if they are authed yet ; - script updates from largest to the smallest channel ; ; ;How to use this script? ; ; - config the options below ; - /load -rs1 auth_update2.mrc to load the script (make sure the script it loaded on top) ; - script starts on load or on join ; - to get the auth of a nick use: $auth(nick) or $auth(nick,cid) ; - to get a nick from an auth use: $auth-nick(auth) or $auth-nick(auth,cid) ; - to recheck a nick that was not authed by command use: /auth.update <nick> ; note that rechecking is done automatically, only use this command if you really want to recheck quickly ; - this script should be loaded as last script in your list for optimal usage ; ; - You can use the following example script to see when a nicks auth is updated ; on *:SIGNAL:authupdate.new:{ ; if (!$2) { echo -ag $1 is not authed } ; else { echo -ag $1 is authed as $2 } ; } ; ; - The following signal is send when a requested auth is updated (with /auth.update <nick>) ; on *:SIGNAL:authupdate.req:{ ; if ($2 == $null) { echo -ag requested: $1 is not on a common chan } ; elseif ($2 == 0) { echo -ag requested: $1 is not authed } ; else { echo -ag requested: $1 is authed as $2 } ; } ; ; Note that these signals return $2 == $null when someone isn't on a common channel. ; This may occur for example when someone parted a channel between the /who and the who reply. ; ; ;Why is this script good? ; ; - compared with my first auth_update, this script uses less resources, at the cost of a little bit more traffic ; - sending /who chan for every channel is not needed and goes slow (lag) ; - sending /who chan on join may cause Excess Flood or Max sendQ exceeded ; - sending /who chan1,chan2,chan3 can be much faster, but only if there are not too many results (Max sendQ exceeded) ; - unauthed users can auth without you knowing, so you need to check if they're authed every so many time. ; ; ;Since some people do not understand how to use this script on join, here is an example: ; ; on *:JOIN:#:{ ; newuser $chan $nick ; } ; ; ; $1 = nick $2 = auth ; on *:SIGNAL:authupdate.new:{ ; if (*.users.quakenet.org iswm $ial($1)) { return } ; var %i = 1 ; while ($comchan($1,%i)) { ; newuser $v1 $1 ; inc %i ; } ; } ; ; ; $1 = chan $2 = nick ; alias -l newuser { ; var %auth = $auth($2) ; if (%auth) { echo 4 -tg $1 $2 is authed as %auth } ; elseif (%auth == 0) { echo 4 -tg $1 $2 is not authed } ; } ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SETTINGS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; maximum number of replies in a WHO, too high may cause 'Max sendQ exceeded' disconnection ; too low may take the script a long time to update the auths, 1000 should be fine for most situations alias -l max.replies { return 1000 } ; maximum length of the /who <string>, too long may cause the server to ignore the command ; too low may slow things down, 400 should be fine in most cases alias -l max.len { return 400 } ; minimum time (seconds) between two /who commands (default 10) alias -l delay { return 10 } ; time (seconds) between the checking if any unauthed users should be rechecked (default 120) alias -l queue.delay { return 120 } ; time (seconds) to recheck if an unauthed user is now authed (default 600) alias -l queue.check { return 600 } ; minimum ratio of (nicks with unknown auth) / (total nicks) in a channel to do /who #channel rather then /who nick,nick, (default 0.09) alias -l min.ratio { return 0.09 } ; minimum nr of nicks with unknown auth in a channel to do /who #channel rather then /who nick,nick, (default 10) alias -l min.nicks { return 10 } ; The networks the script is supposed to work on (case sensitive) ; NOTE that the script ONLY works on networks supporting WHOX (ircu 2.10.* should work) alias -l used.network { return $istokcs(QuakeNet UnderNet GameSurge HanIRC NetGamers OGameNet,$network,32) } ; For every network a check to see if a user has a site where his authname is in ; $1 is the site alias -l auth.in.site { var %n = $network if (%n === QuakeNet) { return $iif(*.users.quakenet.org iswm $1,$true) } elseif (%n === UnderNet) { return $iif(*.users.undernet.org iswm $1,$true) } elseif (%n === GameSurge) { return $iif(*.*.GameSurge iswm $1,$true) } elseif (%n === HanIRC) { return $iif(*.users.HanIRC.org iswm $1,$true) } elseif (%n === NetGamers) { return $iif(*.users.netgamers.org iswm $1,$true) } elseif (%n === OGameNet) { return $iif(*.user.OGameNet iswm $1,$true) } } ; For every network the method to return the auth from the site ; $1 is the site alias -l auth.from.site { var %n = $network if (%n === QuakeNet) { return $gettok($1,1,46) } elseif (%n === UnderNet) { return $gettok($1,1,46) } elseif (%n === GameSurge) { return $gettok($1,1,46) } elseif (%n === HanIRC) { return $gettok($1,1,46) } elseif (%n === NetGamers) { return $gettok($1,1,46) } elseif (%n === OGameNet) { return $gettok($1,1,46) } } ; $auth(nick [,cid]) returns the auth of the nick alias auth { if (!$isid) { $iif($show,.auth,auth) $1- | return } if ($1 == $null) || ($2 !== $null && (!$scid($2) || !$2)) { return } return $gettok($hget($iif($2,$2,$cid) $+ .auths,$+(auth.,$comchan($1,1),$chr(44),$1)),1,32) } ; $auth-nick(auth [,cid]) returns the first nick with that auth alias auth-nick { if ($1 == $null) || ($2 !== $null && (!$scid($2) || !$2)) { return } return $gettok($hfind($iif($2,$2,$cid) $+ .auths,$1,1,n).data,-1,44) } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AUTH.UPDATE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; /auth.update nick alias auth.update { if (!$used.network) || (!$comchan($1,1)) { return } var %t = $cid $+ .auths , %a = $hget(%t,$+(auth.,$comchan($1,1),$chr(44),$1)) if (0 * iswm %a) { hdel -w %t $+(auth.,*,$chr(44),$1) } if (!%a) || (0 * iswm %a) { au.update n $1 | hadd %t req. $+ $1 1 } else { .signal authupdate.req $1 %a } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AU.UPDATE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; $1 = t/n/c/r/d (timer nick chan repeat delay) ; [$1- = n nick] alias -l au.update { var %t = $cid $+ .auths if (!$hget(%t)) { hmake %t } var %tim = au.update.delay. $+ $cid , %w = $hget(%t,who) , %l = $hget(%t,wholock) ; when not called by repeat or delay, we probably have something to /who if (($1 != r) && ($1 != d)) { hadd %t who 1 } ; if we're waiting for reply, don't set timer or /who if (%l) { return } ; if called by delay timer and we probably have something to /who, then /who if (($1 == d) && (%w)) { au.who | return } ; if delay timer hasn't been set already, we want to /who or set the timer if (!$timer(%tim)) { ; if we just joined a chan or just finished a /who, then set delay timer if (($1 == c) || ($1 == r)) { .timer $+ %tim 1 $delay au.update d } else { au.who $iif($1 == n,$2) } } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; NICKLIST CHANGING EVENTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; on ^*:JOIN:#:{ var %t = $cid $+ .auths if (!$used.network) { return } if ($nick == $me) { au.start return } if (!$hget(%t)) { return } if ($hfind(%t,$+(auth.*,$chr(44),$nick),1,w)) { hadd %t $+(auth.,$chan,$chr(44),$nick) $hget(%t,$v1) } elseif ($auth.in.site($site)) { au.upd.nick $nick $site } else { au.update n $nick } } ;366 Vliedel #vliedel :End of /NAMES list. RAW 366:*:{ var %c = $2, %i = $nick(%c,0), %w = auth.* $+ $chr(44), %it = $+(auth.,%c,$chr(44)), %t = $cid $+ .auths while (%i) { var %n = $nick(%c,%i) if ($hfind(%t,%w $+ %n,1,w)) { tokenize 32 $hget(%t,$v1) hadd %t %it $+ %n $1 $iif($2,%c) $3 } dec %i } au.update c } on *:PART:#:{ au.part $chan $nick | au.upd.nick $nick $site $chan } on *:KICK:#:{ au.part $chan $knick | au.upd.nick $nick $site } ; $1 = chan $2 = nick alias -l au.part { var %t = $cid $+ .auths if (!$hget(%t)) { return } if ($2 == $me) { hdel -w %t auth. $+ $chan $+ ,* hdel %t ctime. $+ $chan var %i = $hfind(%t,req.*,0,w) while (%i) { var %it = $hfind(%t,req.*,%i,w) , %n = $gettok(%it,2,46) if (%n ison $1) && (!$comchan(%n,2)) { hdel %t %it | .signal authupdate.req %n } dec %i } } else { hdel %t $+(auth.,$1,$chr(44),$2) if ($hget(%t,req. $+ $2)) && (!$comchan($2,2)) { hdel %t req. $+ $2 | .signal authupdate.req $2 } } } on *:QUIT:{ var %t = $cid $+ .auths if (!$hget(%t)) { return } hdel -w %t $+(auth.,*,$chr(44),$nick) if ($hget(%t,req. $+ $nick)) { hdel %t req. $+ $nick | .signal authupdate.req $nick } } on ^*:NICK:{ var %i = $comchan($newnick,0) , %t = $cid $+ .auths if ($nick == $newnick) || (!$hget(%t)) { return } while (%i) { var %it = $+(auth.,$comchan($newnick,%i),$chr(44)) $iif($hget(%t,%it $+ $nick),hadd,hdel) %t %it $+ $newnick $v1 hdel %t %it $+ $nick dec %i } if ($hget(%t,req. $+ $nick)) { hadd %t req. $+ $newnick 1 | hdel %t req. $+ $nick } if ($auth.in.site($site)) { au.upd.nick $newnick $site } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AU.WHO ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; [$1 = nick] alias -l au.who { var %t = $cid $+ .auths , %t2 = $cid $+ .au.who if ($hget(%t2)) { hfree %t2 } hmake %t2 hdel %t who if ($1) { var %who = $1 $+ ,,, $+ 137 hadd %t2 -mask %who hadd %t wholock 1 who %who n%nat,137 return } var %i = $comchan($me,0) , %sort , %ticks = $ticks while (%i) { var %sort = %sort $nick($comchan($me,%i),0) $+ . $+ %i dec %i } var %sort = $sorttok(%sort,32,n) , %i = $numtok(%sort,32) , %maxlen = $max.len , %n.max = $max.replies , %time = $calc($ctime - $queue.check) , %ids , %n.w , %len, %chans while (%i) { var %c = $comchan($me,$gettok($gettok(%sort,%i,32),2,46)) , %n.0 = $hfind(%t,0 %c &,0,w).data , %n.c = $nick(%c,0) var %n.l = $calc(%n.c - $hfind(%t,$+(auth.,%c,$chr(44),*),0,w) + $iif(%time < $hget(%t,ctime. $+ %c),0,%n.0)) if ($calc(%len + $len(%c) +1) > %maxlen) || ($calc(%n.w + %n.c) > %n.max) { dec %i | continue } if (%n.l > 1) && ((%n.l >= $min.nicks) || ($calc(%n.l / %n.c) >= $min.ratio)) { var %chans = %chans %c hadd %t ctime. $+ %c $ctime var %j = $nick(%c,0) while (%j) { var %n = $nick(%c,%j) if (!$hget(%t2,%n)) { hadd %t2 %n 1 | inc %n.w } dec %j } inc %len $calc($len(%c) +1) } dec %i } var %i = $comchan($me,0) , %nicks while (%i) { var %c = $comchan($me,%i) if (!$istok(%chans,%c,32)) { if ($calc($nick(%c,0) - $hfind(%t,$+(auth.,%c,$chr(44),*),0,w)) > 0) { var %j = $nick(%c,0) while (%j) { var %n = $nick(%c,%j) if ($calc(%len + $len(%n) +1) > %maxlen) { goto end } var %val = $hget(%t,$+(auth.,%c,$chr(44),%n)) if (!$hget(%t2,%n)) && ((%val == $null) || ($gettok(%val,3,32) < %time)) { var %nicks = %nicks %n | hadd %t2 %n 1 | inc %n.w | inc %len $len(%n) } if (%n.w >= %n.max) { goto end } dec %j } } else { var %j = $hfind(%t,0 %c &,0,w).data while (%j) { var %it = $hfind(%t,0 %c &,%j,w).data , %n = $gettok(%it,2,44) if ($calc(%len + $len(%n) +1) > %maxlen) { goto end } if (!$hget(%t2,%n)) && ($gettok($hget(%t,%it),3,32) < %time) && (auth.* iswm %it) { var %nicks = %nicks %n | hadd %t2 %n 1 | inc %n.w | inc %len $len(%n) } if (%n.w >= %n.max) { goto end } dec %j } } } dec %i } :end var %who = $replace(%chans %nicks,$chr(32),$chr(44)) if (%who) { var %who = %who $+ ,,, $+ 137 hadd %t2 -mask %who hadd %t wholock 1 who %who n%nat,137 if (%len > $calc(%maxlen * 0.7)) || (%n.w > $calc(%n.max * 0.7)) { hadd %t who 1 } } else { au.update r } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RAW REPLIES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; RAW 354 SPECIAL WHO REPLY ; 354 <you> <nr> <nick> <auth> ; 354 Vliedel 137 sy rry RAW 354:& 137 & &:{ haltdef var %i = $comchan($3,0) , %t = $cid $+ .auths if ($hget(%t,req. $+ $3)) { hdel %t req. $+ $3 | .signal authupdate.req $3 $iif(%i,$4) } if (!%i) || (!$hget(%t)) { return } if ($gettok($hget(%t,$+(auth.,$comchan($3,1),$chr(44),$3)),1,32) !== $4) { .signal authupdate.new $3 $4 } while (%i) { var %c = $comchan($3,%i) hadd %t $+(auth.,%c,$chr(44),$3) $4 $iif(!$4,%c $ctime) dec %i } } ; RAW 315 WHO END ; 315 <you> <requested> :End of /who list. ; 315 Vliedel #vliedel,,,137 :End of /WHO list. RAW 315:& *,,,137 end of /WHO list.: { if ($hget($cid $+ .au.who,-mask) == $2) { var %who = $left($2,-6) , %i = $wildtok(%who,#*,0,44) , %t = $cid $+ .auths while (%i) { hadd %t ctime. $+ $wildtok(%who,#*,%i,44) $ctime dec %i } hfree $cid $+ .au.who hdel %t wholock au.update r haltdef } } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; STARTING AND STOPPING ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; on *:LOAD:{ scon -at1 au.load l } alias -l au.load { au.stop au.start au.update t } alias -l au.stop { .timer $+ au.update. $+ $cid off .timer $+ au.update.delay. $+ $cid off if ($hget($cid $+ .auths)) { hfree $v1 } if ($hget($cid $+ .au.who)) { hfree $v1 } } alias -l au.start { if (!$used.network) { return } if (!$hget($cid $+ .auths)) { hmake $cid $+ .auths } if (!$timer(au.update. $+ $cid)) { .timer $+ au.update. $+ $cid 0 $queue.delay au.update t } } on *:DISCONNECT:{ au.stop } on *:UNLOAD:{ scon -a au.stop } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IAL-UPDATING EVENTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; on ^*:TEXT:*:*:{ au.upd.nick $nick $site } on ^*:ACTION:*:*:{ au.upd.nick $nick $site } on ^*:NOTICE:*:*:{ au.upd.nick $nick $site } on ^*:RAWMODE:#:{ au.upd.nick $nick $site } on ^*:TOPIC:#:{ au.upd.nick $nick $site } on ^*:INVITE:#:{ au.upd.nick $nick $site } CTCP *:*:*:{ au.upd.nick $nick $site } RAW 352:& & & & & & & & *:{ au.upd.nick $6 $4 } ; $1 = nick $2 = site [ $3 = chan (exclude it)] alias -l au.upd.nick { if (!$auth.in.site($2)) || (!$hget($cid $+ .auths)) { return } var %i = $comchan($1,0) , %t = $cid $+ .auths , %au = $auth.from.site($2) if (!%i) || (%i == 1 && $3) || ($hget(%t,$+(auth.,$comchan($1,1),$chr(44),$1)) == %au) { return } while (%i) { if ($comchan($1,%i) !== $3) { hadd %t $+(auth.,$v1,$chr(44),$1) %au } dec %i } .signal authupdate.new $1 %au } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; USED DATA/TIMERS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; TABLE <cid>.auths ;auth.<chan>,<nick> --> <auth> [chan ctime] ;req.<nick> --> 1 ;ctime.<chan> --> <ctime> ;who --> <1/null> ;wholock --> <1/null> ; TABLE <cid>.au.who ; nick --> 1 ; -mask --> /who string ; TIMER au.update.delay.<cid> ; TIMER au.update.<cid>