Advertisement
Seb

/whoischan by Ook

Seb
Jun 9th, 2015
665
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 9.13 KB | None | 0 0
  1. ; Script to display whois information in an @window
  2. ; Ook @ #mircscripting on undernet
  3. ;
  4. ; All the whois raws are captured but only the nick, address, idle, server, channels info is shown
  5. ; with a little tinkering more can easily be added.
  6. ;
  7. ; v1.0
  8. ; - First release
  9. ; v1.1
  10. ; - fixed possible error in endofwhois when $address fails.
  11. ; - added some more error output.
  12. ; - changed tabs to cut off text that exceeds limits.
  13. ; - changed code to update horiz scrollbar on end of whois (doesnt display whole line still, this is mircs fault)
  14. ; - channel name no longer needed, will take active window as channel if no channel name given.
  15. ;
  16. ; /whoischan <chan>
  17. ; $1 = chan
  18. alias whoischan {
  19.   if ($0 > 1) { echo -aqmlbfti2 [whoischan] Usage: /whoischan <#channel> | halt }
  20.   var %i = 1, %c = $iif($0,$1,$active)
  21.   window -lM -t20,100,130,170 @whoischan
  22.   clear @whoischan
  23.   aline @whoischan $+( Nick,$chr(9),Address,$chr(9),Idle Time,$chr(9),Server,$chr(9),Channels)
  24.   aline @whoischan 
  25.   while ($nick(%c,%i) != $null) {
  26.     var %n = $v1
  27.     aline @whoischan $+(%n,$chr(9),$iif($address(%n,5) != $null,$v1,unknown),$chr(9),0,$chr(9),-,$chr(9),$chr(160))
  28.     _pushwhois %n %n
  29.     inc %i
  30.   }
  31.   !return
  32.   :error
  33.   !echo 4 -s whoischan: $error
  34. }
  35. alias -l _nnet {
  36.   !if ($network != $null) return $v1
  37.   !elseif ($server($server).group != $null) {
  38.     !if ($v1 !isnum) return $v1
  39.   }
  40.   !return Default
  41.   :error
  42.   !echo 4 -s _nnet: $error
  43. }
  44. ; start temp data hashtable functs
  45. ; $1 = var (delete temp var)
  46. alias -l tdel !if ($hget(whoischan)) hdel whoischan $1
  47. ; $1 = var wildcard (del temp vars that matcvh wildcard)
  48. alias -l twdel !if ($hget(whoischan)) hdel -w whoischan $1
  49. ; $1 = var, $2- = data (add a temp var)
  50. alias -l tadd !hadd whoischan $1-
  51. ; $1 = var (get the contents of a temp var)
  52. alias -l tget !return $hget(whoischan,$1-)
  53. ; end temp data hashtable functs
  54. alias -l _pushwhois {
  55.   !var %cid = $cid
  56.   !hadd -m $+(%cid,-whois-queue) $1 $1-
  57.   if (!$timer($+(%cid,-pushwhois))) $+(.timer,%cid,-pushwhois) 1 0 _pushwhois.dump
  58.   !return
  59.   :error
  60.   !echo 4 -s _pushwhois: $error
  61. }
  62. alias -l _pushwhois.dump {
  63.   !var %cid = $cid, %limit = $tget($+(%cid,-maxtarget-WHOIS))
  64.   !if (!%limit) var %limit = 1
  65.   !if ($tget($+(%cid,enable_combined_whois))) {
  66.     ; if the network supports it combine the /whois into one
  67.     !while ($hget($+(%cid,-whois-queue),1).data != $null) {
  68.       !var %n = $v1
  69.       !if ($numtok(%n,32) == 1) {
  70.         ; single nick /whois nick style, these can be combined.
  71.         !var %whois = $addtok(%whois,%n,44)
  72.         !hdel $+(%cid,-whois-queue) $hget($+(%cid,-whois-queue),1).item
  73.         !if ($numtok(%whois,44) == %limit) break
  74.       }
  75.       ; otherwise its /whois nick nick style, these can't be combined.
  76.       !elseif (%whois != $null) break
  77.       !else {
  78.         !var %whois = %n
  79.         !hdel $+(%cid,-whois-queue) $hget($+(%cid,-whois-queue),1).item
  80.         !break
  81.       }
  82.       !inc %cnt
  83.     }
  84.   }
  85.   !else {
  86.     ; otherwise do a single whois & pause before next
  87.     !var %whois = $hget($+(%cid,-whois-queue),1).data
  88.     !hdel $+(%cid,-whois-queue) $hget($+(%cid,-whois-queue),1).item
  89.   }
  90.   if ($hget($+(%cid,-whois-queue),0).item > 0) $+(.timer,%cid,-pushwhois) 1 2 _pushwhois.dump
  91.   else hfree $+(%cid,-whois-queue)
  92.   if (%whois != $null) whois %whois
  93.   !return
  94.   :error
  95.   !echo 4 -s _pushwhois.dump: $error
  96. }
  97. RAW 5:*: {
  98.   !if ($hget(whoischan) == $null) hmake whoischan 100
  99.   !var %cid = $cid, %tmp = $matchtokcs($1-,SILENCE,1,32)
  100.   if (%tmp) tadd $+(%cid,-silence) $gettok(%tmp,2,61)
  101.   else tadd $+(%cid,-silence) 0
  102.   !var %tmp = $matchtokcs($1-,TOPICLEN,1,32)
  103.   if (%tmp) tadd $+(%cid,-topiclen) $gettok(%tmp,2,61)
  104.   else tadd $+(%cid,-topiclen) 0
  105.   !var %tmp = $matchtokcs($1-,NICKLEN,1,32)
  106.   if (%tmp) tadd $+(%cid,-nicklen) $gettok(%tmp,2,61)
  107.   else tadd $+(%cid,-nicklen) 0
  108.   !var %tmp = $matchtokcs($1-,UHNAMES,1,32)
  109.   if (%tmp) tadd $+(%cid,-uhnames) 1
  110.   else tadd $+(%cid,-uhnames) 0
  111.   !var %tmp = $matchtokcs($1-,TARGMAX,1,32)
  112.   !if (%tmp) {
  113.     !var %cnt = 1, %tmp = $gettok(%tmp,2,61)
  114.     !while ($gettok(%tmp,%cnt,44) != $null) {
  115.       tadd $+(%cid,-maxtarget-,$gettok($v1,1,58)) $gettok($v1,2,58)
  116.       !inc %cnt
  117.     }
  118.   }
  119.   else twdel $+(%cid,-maxtarget-*)
  120.   !var %tmp = $matchtokcs($1-,MAXLIST,1,32)
  121.   !if (%tmp) {
  122.     !var %cnt = 1, %tmp = $gettok(%tmp,2,61)
  123.     !while ($gettok(%tmp,%cnt,44) != $null) {
  124.       !var %t = $+(%cid,-maxlist-,$gettok($v1,1,58))
  125.       tadd %t $gettok($v1,2,58)
  126.       if ($tget(%t) == $null) tadd %t 1
  127.       !inc %cnt
  128.     }
  129.   }
  130.   else twdel $+(%cid,-maxlist-*)
  131.   !var %tmp = $matchtokcs($1-,AWAYLEN,1,32)
  132.   if (%tmp) tadd $+(%cid,-awaylen) $gettok(%tmp,2,61)
  133.   else tadd $+(%cid,-awaylen) 0
  134.   !var %tmp = $matchtokcs($1-,KICKLEN,1,32)
  135.   if (%tmp) tadd $+(%cid,-kicklen) $gettok(%tmp,2,61)
  136.   else tadd $+(%cid,-kicklen) 0
  137.   !var %nnet = $_nnet
  138.   !if ($istok(DALnet UnderNet BeyondIRC IRCHighway SwiftIRC Genscripts,%nnet,32)) {
  139.     ; net supports combined whois
  140.     tadd $+(%cid,enable_combined_whois) 1
  141.     !if ($tget($+(%cid,-maxtarget-WHOIS)) == $null) {
  142.       ; max targets wasn't set for some reason, try a known value for that network.
  143.       if (%nnet == Undernet) tadd $+(%cid,-maxtarget-WHOIS) 12
  144.       elseif (%nnet == Genscripts) tadd $+(%cid,-maxtarget-WHOIS) 20
  145.       else tadd $+(%cid,-maxtarget-WHOIS) 4
  146.     }
  147.   }
  148.   else tdel $+(%cid,enable_combined_whois)
  149. }
  150. ; output line = nick address idle-time server channels
  151. ;275 HighwayIRC RPL_WHOISSECURE "<TheirNick> is using a secure connection (SSL)"
  152. raw 275:*: !if ($fline(@whoischan,$+($2,$chr(9),*),0,1) != $null) haltdef
  153. ;301 RPL_AWAY "<nick> :<away message>"
  154. raw 301:*: !if ($fline(@whoischan,$+($2,$chr(9),*),0,1) != $null) haltdef
  155. ;307 DALnet RPL_WHOISREGNICK Registered Nick  â€œ:<nick> is a registered nick
  156. raw 307:*: !if ($fline(@whoischan,$+($2,$chr(9),*),0,1) != $null) haltdef
  157. ;308 DALnet RPL_WHOISADMIN Server Admin (may be dropped)
  158. raw 308:*: !if ($fline(@whoischan,$+($2,$chr(9),*),0,1) != $null) haltdef
  159. ;309 DALnet RPL_WHOISSADMIN Services Admin (may be dropped) “: <nick> is a services adminstrator
  160. raw 309:*: !if ($fline(@whoischan,$+($2,$chr(9),*),0,1) != $null) haltdef
  161. ;310 DALnet RPL_WHOISHELPOP "%s :looks very helpful.", “<nick> <help status msg>" - A sample reply is: “White_Dragon looks very helpful.”
  162. raw 310:*: !if ($fline(@whoischan,$+($2,$chr(9),*),0,1) != $null) haltdef
  163. ;311 RPL_WHOISUSER "<nick> <user> <host> * :<real name>" - The '*' in RPL_WHOISUSER is there as the literal character and not as a wild card
  164. raw 311:*: {
  165.   !if ($fline(@whoischan,$+($2,$chr(9),*),1,1) != $null) {
  166.     var %l = $v1
  167.     haltdef
  168.     rline @whoischan %l $puttok($line(@whoischan,%l),$chr(160),5,9)
  169.   }
  170. }
  171. ;312 RPL_WHOISSERVER "<nick> <server> :<server info>"
  172. raw 312:*: {
  173.   ;echo -s whoischan312: $1-
  174.   !if ($fline(@whoischan,$+($2,$chr(9),*),1,1) != $null) {
  175.     var %l = $v1
  176.     haltdef
  177.     rline @whoischan %l $puttok($line(@whoischan,%l),$chr(160) $3,4,9)
  178.   }
  179. }
  180. ;313 RPL_WHOISOPERATOR "<nick> :is an IRC operator"
  181. raw 313:*: !if ($fline(@whoischan,$+($2,$chr(9),*),0,1) != $null) haltdef
  182. ;316 RPL_WHOISCHANOP
  183. raw 316:*: !if ($fline(@whoischan,$+($2,$chr(9),*),0,1) != $null) haltdef
  184. ;317 RPL_WHOISIDLE "<nick> <integer> :seconds idle"
  185. raw 317:*: {
  186.   ;echo -s whoischan317: $1-
  187.   !if ($fline(@whoischan,$+($2,$chr(9),*),1,1) != $null) {
  188.     var %l = $v1
  189.     haltdef
  190.     rline @whoischan %l $puttok($line(@whoischan,%l),$chr(160) $duration($3),3,9)
  191.   }
  192. }
  193. ;318 RPL_ENDOFWHOIS "<nick>(,nick,nick,...) :End of /WHOIS list"
  194. raw 318:*: {
  195.   ;echo -s whoischan318: $1-
  196.   !var %i = 1
  197.   !while ($gettok($2,%i,44) != $null) {
  198.     !var %n = $v1
  199.     !if ($fline(@whoischan,$+(%n,$chr(9),*),1,1) != $null) {
  200.       var %l = $v1
  201.       haltdef
  202.       if ($address(%n,5) != $null) rline @whoischan %l $puttok($line(@whoischan,%l),$chr(160) $v1,2,9)
  203.     }
  204.     inc %i
  205.   }
  206. }
  207. ;319 RPL_WHOISCHANNELS "<nick> :{[@|+]<channel><space>}"
  208. raw 319:*: {
  209.   !if ($fline(@whoischan,$+($2,$chr(9),*),1,1) != $null) {
  210.     var %l = $v1
  211.     haltdef
  212.     var %txt = $line(@whoischan,%l)
  213.     rline @whoischan %l $puttok(%txt,$addtok($gettok(%txt,5,9),$3-,32),5,9)
  214.     window -b @whoischan
  215.   }
  216. }
  217. ;330 Undernet/Quakenet RPL_WHOISACCOUNT "<source> 330 <target> <nick> <account> :is authed as" returned when using the WHOIS command on UnderNet "is logged in as" is shown as text
  218. raw 330:*: !if ($fline(@whoischan,$+($2,$chr(9),*),0,1) != $null) haltdef
  219. ;335 RPL_WHOISBOT
  220. raw 335:*: !if ($fline(@whoischan,$+($2,$chr(9),*),0,1) != $null) haltdef
  221. ;338 RPL_WHOISACTUALLY ":%s 338 %s :%s is actually %s@%s [%s]"
  222. raw 338:*: !if ($fline(@whoischan,$+($2,$chr(9),*),0,1) != $null) haltdef
  223. ;615 HighwayIRC RPL_WHOISMODES "<TheirNick> is using modes <modes>"
  224. raw 615:*: !if ($fline(@whoischan,$+($2,$chr(9),*),0,1) != $null) haltdef
  225. ;616 HighwayIRC RPL_WHOISREALHOST "<TheirNick> real hostname <host> <ip>"
  226. raw 616:*: !if ($fline(@whoischan,$+($2,$chr(9),*),0,1) != $null) haltdef
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement