/*_____________________________________________________________________________ |/ / Channel info add-on by David "Saturn" van Moolenbroek | Version 2.1, released 09-03-2006 -- support on #help.script/Quakenet | Use/modify however you want, but please keep my name in it. Thank you! | | Keywords: io.dll, raws, multi-server, repeat-safe | | This script allows you to retrieve and display information about a channel | that you yourself are not on: the mode, creation time (age), topic, number | of users, and on some networks (currently only QuakeNet) the services | present on that channel. It uses io.dll in order to achieve this; not only | because that severely limits the amount of script code necessary, but also | to be able to get the number of users on a channel with /list, without | ending up with a "List Channels" window. | | You need io.dll v0.78 or higher in order to be able to use this script! | | Note that the script itself is completely stateless: it does not store any | data in global variables or hashtables or anything. Even then, multiple | chaninfo lookups can be started at the same time, and the received raws | will be processed correctly, although the results will sometimes be | displayed out of order - this is due to the fact that the IRC server | provides different amounts of information about channels with different | modes set. | | The lookup happens by first sending a MODE command to look up the mode (and | creation time) of the channel, and to determine what other information can | be looked up about it; after that, it may issue a NAMES (for services), and | LIST (for number of users and topic) or TOPIC (for just the topic). If the | LIST fails - some networks rate-limit LIST requests - then it will send a | TOPIC. With the current configuration, it will never send more than three | commands to request the information; however, keep in mind that these three | commands can still cause quite a bit of lag! | | What information exactly can be determined for each channel, depends on the | IRC software the server is running. Some networks need special settings in | the script; see the ci_net alias within the script code for details. The | top-10 from http://irc.netsplit.de/networks/ is supported by default. | | This script defines the following command: | | /chaninfo [flags [alias [param]]] | | This will start a lookup for , specifically for the channel | properties listed in , and when done it will call , or a | built-in display routine if no callback alias was supplied. can | be one or more of the following flags: | | m channel mode | c creation time | s services (nicknames) on the channel | t channel topic | u number of users | | The default is "mcsut", i.e. all flags. If you specify a callback alias, | you must also specify . If given, the callback alias will be | called when the lookup is completed (successful, partially successful or | failed); may be only one word; if omitted, "-" is used instead. | The callback alias will be called like this: | | / | | | Fields for which the lookup did not result in any data, will be set to | $null or 0; only rely on the field to see what data was actually | asked for! If is set to $null, the given channel did not exist. | is a nickname list where the nicknames are separated by a '/'; | like the others, this field can be "0" if no nicknames were found or the | 's' flag was not specified. | | You can call $ci_format(,, etc) to | format the second&onwards parameter into a human-readable form, using the | text (typically: color or bold codes) in and . See also | the second example below. | | Examples | | /chaninfo #help.script | /chaninfo #help msu | | on *:TEXT:!chaninfo &:#:chaninfo $gettok(#$2,1,44) mcstu mycallback $chan | alias mycallback msg $1 14[ $+ $2 $+ 14]0 $ci_format(,14,$2-) \ _\_____________________________________________________________________________ */ alias -l io return $dll($scriptdir $+ io.dll,$$1,$2-) alias -l ci_net { ; :[:] ; bit 1: no creation time (329) with mode (324) [ircnet] ; bit 2: can not do /topic on +p channels [ircnet,bahamut,CR] ; bit 3: can not do /topic on non +p/+s channels [ircnet] ; bit 4: can not do /list on channels at all [CR] ; bit 5: no end of list (323) if /list fails [plexus] ; (note: bit 2 is only for efficiency, the rest is really necessary) ; serviceregex is an anchored nickname regex (e.g. "." for one-letter nicks) ; undernet:0 efnet:0 freenode:0 unibg:0 gamesurge:0 return quakenet:0:. ircnet:7 dalnet:2 rizon:16 webnet:10 } alias -l ci_opt { var %o = $wildtok($ci_net,$remove($network,:) $+ :*,1,32) if ($prop == names) return $gettok(%o,3-,58) return $isbit($gettok(%o,2,58),$1) } alias chaninfo { tokenize 32 $1 $iif($2,$2,mcstu) $iif($3,$3,ci_echo) $iif($4 != $null,$4,-) if (!$ci_opt(1)) { io add -im 324 ci_mode 1 io add -i $result 329 ci_mcre } else io add -im 324 ci_mode 2 io add -i $result 403 ci_mres 1 io add -i $result 442 ci_mnxs io set groupdata $result $3-4 $1-2 io send MODE $1 } alias -l ci_u return $replace($1,$chr(123),[,|,\,$chr(125),],^,`) alias -l ci_chan { if ($ci_u($gettok($1,$iif($2,$2,4),32)) == $& $ci_u($gettok($io(get,groupdata),3,32))) return 1 } alias ci_mode { if (!$ci_chan($1)) return 0 io set groupdata $2 $io(get,groupdata) $gettok($1,5,32) 0 if ($ci_opt(1)) ci_mres return $3 } alias ci_mcre { if (!$ci_chan($1)) return 0 io set groupdata $2 $puttok($io(get,groupdata),$gettok($1,5,32),6,32) return $ci_mres } alias ci_mnxs { if (!$ci_chan($1)) return 0 io set groupdata $2 $io(get,groupdata) 0 return $ci_mres } alias -l ci_mask { var %list = 0, %topic = 0, %names = 0 if (!$2) return 0 if (s !isincs $2) { if (u isincs $1) %list = 1 elseif (t isincs $1) %topic = 1 if (s isincs $1) %names = 1 } if (p isincs $2) { if (%list) { %list = 0 if (t isincs $1) && (!$ci_opt(2)) %topic = 1 } elseif ($ci_opt(2)) %topic = 0 %names = 0 } elseif ($ci_opt(3)) && (%topic) { %topic = 0 if (!$ci_opt(4)) %list = 1 } elseif ($ci_opt(4)) && (%list) { %list = 0 if (!$ci_opt(3)) %topic = 1 } if ($ci_opt().names == $null) %names = 0 return $calc(%names * 4 + %topic * 2 + %list) } alias -l ci_topic { var %group = $io(add,$iif($2,-i $2,-im) 332 ci_tset) io add -i %group 331 ci_tclr io add -i %group 333 ci_tres 1 io add -i %group 442 ci_tres 1 io send TOPIC $1 return %group } alias ci_mres { if ($3) && (!$ci_chan($1)) return 0 tokenize 32 $io(get,groupdata) var %group, %mask = $ci_mask($4,$5) if (!%mask) { $1- return 2 } if ($and(%mask,4)) { %group = $io(add,-im 353 ci_nset) io add -i %group 366 ci_nres $iif($and(%mask,3),1,2) io send NAMES $3 } if ($and(%mask,1)) { %group = $io(add,$iif(%group,-i $v1,-im) 321) io add -i %group 322 ci_lset io add -in %group 323 ci_lres io add -i $+ $iif($ci_opt(5),n) %group 263 ci_lerr io send LIST $3 } elseif ($and(%mask,2)) %group = $ci_topic($3,%group) io set groupdata %group $1-6 0 0 return 2 } alias ci_nset { if (!$ci_chan($1,5)) return 0 var %i = 1, %s, %r = /(?<=[\s:\Q $+ $prefix $+ \E]) $+ $& ( $+ $ci_opt().names $+ )(?:[\s!]|$)/gi if ($regex($gettok($1,6-,32),%r)) { while (%i <= $regml(0)) { %s = $addtok(%s,$regml(%i),47) inc %i } } tokenize 32 $2 $io(get,groupdata) %s = $iif($addtok($8,%s,47) != 0,$remtok($v1,0,1,47),0) io set groupdata $1-7 %s $9- return 1 } alias ci_nres { if (!$ci_chan($1)) return 0 if ($3 == 2) $io(get,groupdata) return $3 } alias ci_lerr { tokenize 32 $2 $io(get,groupdata) io set groupdata $1 if (t isincs $5) io set groupdata $ci_topic($4) $2- else $2- return 1 } alias ci_lset { if ($ci_chan($1)) io set groupdata $2 $gettok($io(get,groupdata),1-7,32) $& $gettok($1,5,32) 1 $right($gettok($1,6-,32),-1) return 1 } alias ci_lres { if ($io(get,groupdata) != $null) $v1 return 2 } alias ci_tset { if (!$ci_chan($1)) return 0 io set groupdata $2 $gettok($io(get,groupdata),1-8,32) 1 $& $right($gettok($1,5-,32),-1) return 1 } alias ci_tclr { if (!$ci_chan($1)) return 0 io set groupdata $2 $gettok($io(get,groupdata),1-8,32) 1 return $ci_tres } alias ci_tres { if ($3) && (!$ci_chan($1)) return 0 return $ci_lres } alias -l ci_echo { ; $1 = callback data, $2 = chan, $3 = flags, $4 = mode, $5 = ctime, ; $6 = services, $7 = users, $8 = topicflag, $9- = topic echo -acti2 $+ $iif($active == status window,e) info $& * $2 $+ : $ci_format(10,,$2-) } alias ci_format { ; $1 = color1, $2 = color2, $3- = chan flags mode ctime etc.. var %s, %c1 = $1, %c2 = $2 tokenize 32 $3- if ($3 != $null) { if (u isincs $2) && ($6) { %s = %s %c1 $+ $6 $+ %c2 $iif($6 == 1,user,users) } if (s isincs $2) && ($5) { if (%s != $null) %s = %s including else %s = contains %s = %s %c1 $+ $replace($sorttok($5,47),/,%c2 $+ / $+ %c1) $+ %c2 } if (m isincs $2) && ($3) { if (%s != $null) %s = %s $+ , %s = %s mode %c1 $+ $3 $+ %c2 } if (c isincs $2) && ($4) { if (%s != $null) %s = %s $+ , var %n = $iif($calc($ctime - $4) < 0,1) var %d = $gettok($duration($remove($v1,-)),1,32) if (*wks iswm %d) && ($int($calc($remove(%d,wks) / 52.18)) >= 1) $& %d = $v1 $+ $iif($v1 > 1,yrs,yr) %s = %s created %c1 $+ $iif(%n,minus %d,%d) $+ %c2 ago } if (t isincs $2) && ($7 != $null) { if (%s != $null) %s = %s $+ , if ($8- != $null) %s = %s topic %c1 $+ $strip($8-) $+ %c2 else %s = %s no topic } if (%s == $null) %s = no data } else %s = no such channel return %s }