Difference between revisions of "$qauth alias"

From Scriptwiki
Jump to: navigation, search
m
m (update by shenghi)
 
Line 37: Line 37:
 
  ;  
 
  ;  
 
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
 
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
 
+
 
  ;;;;;;;;;; SLEEP ALIAS ;;;;;;;;;;  
 
  ;;;;;;;;;; SLEEP ALIAS ;;;;;;;;;;  
 
  ;; Syntax: /sleep N  
 
  ;; Syntax: /sleep N  
 
  ;; Causes a script to 'sleep' N miliseconds. During this time  
 
  ;; Causes a script to 'sleep' N miliseconds. During this time  
 
  ;; server and user raws are processed and events pass.  
 
  ;; server and user raws are processed and events pass.  
  alias -l sleep {  
+
  alias sleep {  
 
   ;; when called as an identifier or the number of miliseconds  
 
   ;; when called as an identifier or the number of miliseconds  
 
   ;; to sleep is 0, return  
 
   ;; to sleep is 0, return  
Line 59: Line 59:
 
  ;; Syntax: $qauth(nick)  
 
  ;; Syntax: $qauth(nick)  
 
  ;; Returns the qauth of a user or $null if the user is not authed -- QuakeNet only  
 
  ;; Returns the qauth of a user or $null if the user is not authed -- QuakeNet only  
  alias qauth {  
+
  alias qauth {
  ;; check if used as identifier and if the network used on is quakenet
+
   if (!$isid) || (*.??.quakenet.org !iswm $server) !return
   if (!$isid) || (*.??.quakenet.org !iswm $server) !return  
+
  if ($ial($1).host) if ($regex($ial($1).host,(.+?)\.users\.quakenet\.org)) !return $regml(1)
 +
  if ($ial($1).mark) !return $v1
 +
  !set %getQauth [ $+ [ $1 ] ] -
 +
  !.who $1 n%nat,101
 +
  !var %i = 10
 +
  while (%i) && (%getQauth [ $+ [ $1 ] ] == -) {
 +
    sleep 10
 +
    !dec %i
 +
  }
 +
  !var %return = $iif(%getQauth [ $+ [ $1 ] ] == -,$null,$v1)
 +
  !unset %getQauth [ $+ [ $1 ] ]
 +
  if (%return) !.ialmark $1 $v1
 +
  !return %return
 +
}
 
    
 
    
  ;; check if the Q auth could be extracted from the host
+
  ;;;;;;;;;; RAW 354 - SPECIAL WHO REPLY ;;;;;;;;;;
  if ($ial($1).host) if ($regex($ial($1).host,(.+?)\.users\.quakenet\.org)) !return $regml(1)
+
  raw 354:& 101 & *:{
 
+
   if (%getQauth [ $+ [ $3 ] ]) {
  ;; check if the Q auth could be extracted from the ialmark
+
     !set %getQauth [ $+ [ $3 ] ] $iif($4,$v1,$false)
  if ($ial($1).mark) !return $v1
+
    !set %haltRaw315 [ $+ [ $3 ] ] pom
 
+
     !haltdef
  ;; set a global var and send out a who to get the users Q auth
+
   }
  ;; the while loop waits for the server response
+
  !haltdef
  !set %getQauth [ $+ [ $1 ] ] $crlf
+
  }
  !.who $1 n%nat,101
+
  !var %i = 10
+
  ;;;;;;;;;; RAW 315 - END OF /WHO LIST ;;;;;;;;;;
  while (%i) && (%getQauth [ $+ [ $1 ] ] == $crlf) { 
+
  raw 315:*:{
    sleep 10 
+
   if (%haltRaw315 [ $+ [ $2 ] ]) {
    !dec %i
+
    !unset %haltRaw315 [ $+ [ $2 ] ]
  }
+
    !haltdef
 
+
  }
  ;; set local return var so the global var can be removed
+
  !haltdef
  !var %return = $iif(%getQauth [ $+ [ $1 ] ] == $crlf,$null,$v1)
 
  !unset %getQauth [ $+ [ $1 ] ]
 
 
 
  ;; add q auth to IAL mark
 
  if (%return != -) !.ialmark $1 $v1
 
 
 
  !return $iif(%return != -,$v1,$null)
 
}
 
 
 
  ;;;;;;;;;; RAW 354 - SPECIAL WHO REPLY ;;;;;;;;;;  
 
  raw 354:& 101 & *:{  
 
   if (%getQauth [ $+ [ $3 ] ]) {  
 
     !set %getQauth [ $+ [ $3 ] ] $iif($4,$v1,-)  
 
     !haltdef  
 
   }  
 
  }  
 
 
 
  ;;;;;;;;;; RAW 315 - END OF /WHO LIST ;;;;;;;;;;  
 
  raw 315:*:{  
 
  ;; see whether a Q auth was requested and if so, halt the default output
 
   if (%getQauth [ $+ [ $2 ] ]) !haltdef  
 
 
  }
 
  }
 +
  
 
[[Category:Script Archive]]
 
[[Category:Script Archive]]

Latest revision as of 16:11, 20 June 2010

This is a $qauth identifier for QuakeNet. It uses COM objects and Windows Scripting Shell to perform a 'sleep' action in order to wait for data sent by the server. This sleep alias causes the alias not to be very usefull in events, however, the script also offers a solution for this problem.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
; 
; Written by Shenghi
; Contact at irc.quakenet.org -> #help.script
;
; $qauth identifier. Will only work on QuakeNet. It will 
; first try to extract the Q auth from a users host, if 
; the user has usermode +x set. If it can't, it will then 
; attempt to get the Q auth from $ial(nick).mark. If the Q 
; auth is not set as a mark it will send /who nick n%na to 
; get the Q auth from the server. To prevent having to do this 
; more than once for each user, the Q auth is saved as ialmark 
; when it's received from the server.
;
; The sleep alias has one annoying side-effect. It prevents the
; identifier from working correctly in events. To go around this you
; can put whatever you were going to do in the event in an alias
; and use /timer 1 0 <alias>.
;
;
; A simple example:
; The following script might not work correctly.
; on *:JOIN:#help.script:{ echo -ag $qauth($nick) }
; 
; This will work guaranteed.
; alias echo_auth { echo -ag $qauth($1) }
; on *:JOIN:#help.script:{ timer 1 0 echo_auth $nick }
;
;
; Usage: 
; 
;  $qauth(nick) - Returns the qauth of a user or $null if 
;                 the user is not authed. 
; 
; 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 

;;;;;;;;;; SLEEP ALIAS ;;;;;;;;;; 
;; Syntax: /sleep N 
;; Causes a script to 'sleep' N miliseconds. During this time 
;; server and user raws are processed and events pass. 
alias sleep { 
  ;; when called as an identifier or the number of miliseconds 
  ;; to sleep is 0, return 
  if ($isid) || ($0 != 1) || ($1 !isnum) || ($1 < 1) !return 
 
  ;; otherwise set a unique filename to a var, write the remote script to 
  ;; that file and execute it using COM objects. 
  !var %f = $ticks $+ .wsf 
  !write %f <job id="js"><script language="jscript">WScript.Sleep( $+ $1 $+ );</script></job> 
  !.comopen %f WScript.Shell 
  if (!$comerr) .comclose %f $com(%f,Run,3,bstr,%f,uint,0,bool,true) 
  !.remove %f 
} 
 
;;;;;;;;;; QAUTH ALIAS ;;;;;;;;;; 
;; Syntax: $qauth(nick) 
;; Returns the qauth of a user or $null if the user is not authed -- QuakeNet only 
alias qauth {
  if (!$isid) || (*.??.quakenet.org !iswm $server) !return
  if ($ial($1).host) if ($regex($ial($1).host,(.+?)\.users\.quakenet\.org)) !return $regml(1)
  if ($ial($1).mark) !return $v1
  !set %getQauth [ $+ [ $1 ] ] -
  !.who $1 n%nat,101
  !var %i = 10
  while (%i) && (%getQauth [ $+ [ $1 ] ] == -) { 
    sleep 10 
    !dec %i
  }
  !var %return = $iif(%getQauth [ $+ [ $1 ] ] == -,$null,$v1)
  !unset %getQauth [ $+ [ $1 ] ]
  if (%return) !.ialmark $1 $v1
  !return %return
}
 
;;;;;;;;;; RAW 354 - SPECIAL WHO REPLY ;;;;;;;;;;
raw 354:& 101 & *:{
  if (%getQauth [ $+ [ $3 ] ]) {
    !set %getQauth [ $+ [ $3 ] ] $iif($4,$v1,$false)
    !set %haltRaw315 [ $+ [ $3 ] ] pom
    !haltdef
  }
  !haltdef
}

;;;;;;;;;; RAW 315 - END OF /WHO LIST ;;;;;;;;;;
raw 315:*:{
  if (%haltRaw315 [ $+ [ $2 ] ]) {
    !unset %haltRaw315 [ $+ [ $2 ] ]
    !haltdef
  }
  !haltdef
}