Difference between revisions of "WHO usage and numeric events"

From Scriptwiki
Jump to: navigation, search
m (Events -> Category:Events)
 
(6 intermediate revisions by 3 users not shown)
Line 3: Line 3:
 
Covers the usage of raw events and the /who command.
 
Covers the usage of raw events and the /who command.
  
  <nowiki>; A simple little alias that returns the time interval for the flood protection (in seconds).
+
  ; A simple little alias that returns the time interval for the flood protection (in seconds).
; We make this alias local (-l switch), since we wont need it outside this script.
+
; We make this [[:Category:Aliases|alias]] local (-l switch), since we wont need it outside this script.
 
+
alias -l authflood {
+
alias -l authflood {
return 3
+
  [[return]] 3
}
+
}
 
+
; Basic On Text event to trigger the script.
+
; Basic [[On_text|On Text]] [[:Category:Events|event]] to trigger the script.
 
+
on *:Text:!auth *:#: {
+
on *:Text:!auth *:#: {
 
+
; Flood protection so that noone can abuse the command and flood you off the server.
+
  ; Flood protection so that noone can abuse the command and flood you off the server.
; If the variable %authflood doesnt exist, the script continues.
+
  ; If the variable %authflood doesnt exist, the script continues.
 
+
if (!%authflood) {
+
  [[If-Then-Else|if]] (!%authflood) {
 
+
  ; Check if there really is a nick to get the auth of, by making sure $2 exists.
+
    ; Check if there really is a nick to get the auth of, by making sure $2 exists.
 
+
  if ($2) {
+
    if ($2) {
 
+
    ; At first, we will save $2 in a variable, since we need it later on.
+
      ; At first, we will save $2 in a variable, since we need it later on.
 
+
    set %nickname $2
+
      [[set]] %nickname $2
 
+
    ; Preform a /who request of the nick with the appropriate flags (n%nat). For more info on /who command, read:
+
      ; Perform a /who request of the nick with the appropriate flags (n%nat). For more info on /who command, read:
    ; http://www.mircscripts.org/showdoc.php?type=tutorial&id=2412
+
      ; http://www.mircscripts.org/showdoc.php?type=tutorial&id=2412
    ; the t flag is to identify the reply, which we assign a random number, in this case 465 (later on being used in the "raw 354"-event)
+
      ; the t flag is to identify the reply, which we assign a random number, in this case 465 (later on being used in the "raw 354"-event)
 
+
    who $2 n%nat,465   
+
      [[who]] $2 n%nat,465   
 
+
    ; Assign %authchan the value of $chan so we can access it later
+
      ; Assign %authchan the value of $chan so we can access it later
 
+
    set %authchan $chan
+
      set %authchan $chan
 
+
  }
+
    }
 
+
  ; if there is no $2, show the syntax
+
    ; if there is no $2, show the syntax
 
+
  else {
+
    else {
    msg $chan To use it correctly, type !auth
+
      msg $chan To use it correctly, type !auth <nickname>
  }
+
    }
 
+
  ; Set the %authflood variable (in order to prevent abuse of the command) to $authflood seconds using the -u switch.
+
    ; Set the %authflood variable (in order to prevent abuse of the command) to $authflood seconds using the -u switch.
 
+
  set -u [ $+ [ $authflood ] ] %authflood 1
+
    set -u [ $+ [ $authflood ] ] %authflood 1
 +
  }
 
  }
 
  }
}
+
 
+
; Raw numeric 354 is the servers reply of the /who request. We check if "465" is in the reply
; Raw numeric 354 is the servers reply of the /who request. We check if "465" is in the reply
+
; to be sure its the reply we are looking for.
; to be sure its the reply we are looking for.
 
;
 
; (To read more about raws, have a look at: http://script.quakenet.org/index.php?p=raws)
 
 
 
raw 354:& 465 & *: {
 
 
 
; syntax of raw 354 (with our flags): "me 465 nick authname" for authed people or
 
; "me 465 nick 0" for non-authed ones.
 
; but for now we will just assign %authname the value of $4 without checking if is 0 or not
 
 
 
set %authname $4
 
 
 
}
 
 
 
; Raw numeric 315 notifies us that the /who request is over. Now is the time to
 
; process whatever data we have.
 
 
 
raw 315:*: {
 
 
 
; syntax of raw 315: "me nick End of /WHO list."
 
 
  ;
 
  ;
  ; We check if its really our reply by comparing the nickname ($2) against requested nickname (%nickname)
+
  ; (To read more about raws, have a look at: [[:Category:Raws|Raws]]
 
+
if ($2 == %nickname) {
+
[[Raw_354|raw 354]]:& 465 & *: {
 
+
  ; At this stage %nickname should contain the nick of the requested nick, %authname the authname of %authnick
+
  ; syntax of raw 354 (with our flags): "me 465 nick authname" for authed people or
  ; and %authchan the channel to which we should send the information.
+
  ; "me 465 nick 0" for non-authed ones.
  ;
+
  ; but for now we will just assign %authname the value of $4 without checking if is 0 or not
  ; We have to check if %authname isnt 0, since "!%authname" would return $true if %authname is 0
+
 
+
  set %authname $4
  if (!%authname) && (%authname != 0) {
+
    msg %authchan There is noone with the nick %nickname $+ .
+
}
  }
+
 
+
; Raw numeric 315 notifies us that the /who request is over. Now is the time to
  ; if %authname is set to 0 the nick isnt authed.
+
; process whatever data we have.
 
+
  elseif (%authname == 0) {
+
[[Raw_315|raw 315]]:*: {
    msg %authchan %nickname is currently not authed.
+
  }
+
  ; syntax of raw 315: "me nick End of /WHO list."
 
+
  ;
  ; else we assume the user is authed and print the authname
+
  ; We check if its really our reply by comparing the nickname ($2) against requested nickname (%nickname)
 
+
  else {
+
  if ($2 == %nickname) {
    msg %authchan %nickname is authed as %authname $+ .
+
 +
    ; At this stage %nickname should contain the nick of the requested nick, %authname the authname of %authnick
 +
    ; and %authchan the channel to which we should send the information.
 +
    ;
 +
    ; We have to check if %authname isnt 0, since "!%authname" would return $true if %authname is 0
 +
 +
    if (!%authname) && (%authname != 0) {
 +
      [[msg]] %authchan There is noone with the nick %nickname $+ .
 +
    }
 +
 +
    ; if %authname is set to 0 the nick isnt authed.
 +
 +
    elseif (%authname == 0) {
 +
      msg %authchan %nickname is currently not authed.
 +
    }
 +
 +
    ; else we assume the user is authed and print the authname
 +
 +
    else {
 +
      msg %authchan %nickname is authed as %authname $+ .
 +
 +
    }
 +
 +
    ; Unset the used variables
 +
 +
    [[unset]] %authname
 +
    unset %authchan
 +
    unset %nickname
 +
 +
  }
 +
}
  
  }
 
 
  ; Unset the used variables
 
 
  unset %authname
 
  unset %authchan
 
  unset %nickname
 
 
}
 
}</nowiki>
 
 
[[Category:Script Archive]]
 
[[Category:Script Archive]]

Latest revision as of 23:08, 30 October 2008

This script is supposed to show everyone how easy it is to get someones Q-authname, save it in a variable and/or return it.

Covers the usage of raw events and the /who command.

; A simple little alias that returns the time interval for the flood protection (in seconds).
; We make this alias local (-l switch), since we wont need it outside this script.

alias -l authflood {
 return 3
}

; Basic On Text event to trigger the script.

on *:Text:!auth *:#: {

 ; Flood protection so that noone can abuse the command and flood you off the server.
 ; If the variable %authflood doesnt exist, the script continues.

 if (!%authflood) {

   ; Check if there really is a nick to get the auth of, by making sure $2 exists.

   if ($2) {

     ; At first, we will save $2 in a variable, since we need it later on.

     set %nickname $2

     ; Perform a /who request of the nick with the appropriate flags (n%nat). For more info on /who command, read:
     ; http://www.mircscripts.org/showdoc.php?type=tutorial&id=2412
     ; the t flag is to identify the reply, which we assign a random number, in this case 465 (later on being used in the "raw 354"-event)

     who $2 n%nat,465  

     ; Assign %authchan the value of $chan so we can access it later

     set %authchan $chan

   }

   ; if there is no $2, show the syntax

   else {
     msg $chan To use it correctly, type !auth <nickname>
   }

   ; Set the %authflood variable (in order to prevent abuse of the command) to $authflood seconds using the -u switch.

   set -u [ $+ [ $authflood ] ] %authflood 1
 }
}

; Raw numeric 354 is the servers reply of the /who request. We check if "465" is in the reply
; to be sure its the reply we are looking for.
;
; (To read more about raws, have a look at: Raws

raw 354:& 465 & *: {

 ; syntax of raw 354 (with our flags): "me 465 nick authname" for authed people or
 ; "me 465 nick 0" for non-authed ones.
 ; but for now we will just assign %authname the value of $4 without checking if is 0 or not

 set %authname $4

}

; Raw numeric 315 notifies us that the /who request is over. Now is the time to
; process whatever data we have.

raw 315:*: {

 ; syntax of raw 315: "me nick End of /WHO list."
 ;
 ; We check if its really our reply by comparing the nickname ($2) against requested nickname (%nickname)

 if ($2 == %nickname) {

   ; At this stage %nickname should contain the nick of the requested nick, %authname the authname of %authnick
   ; and %authchan the channel to which we should send the information.
   ;
   ; We have to check if %authname isnt 0, since "!%authname" would return $true if %authname is 0

   if (!%authname) && (%authname != 0) {
     msg %authchan There is noone with the nick %nickname $+ .
   }

   ; if %authname is set to 0 the nick isnt authed.

   elseif (%authname == 0) {
     msg %authchan %nickname is currently not authed.
   }

   ; else we assume the user is authed and print the authname

   else {
     msg %authchan %nickname is authed as %authname $+ .

   }

   ; Unset the used variables

   unset %authname
   unset %authchan
   unset %nickname

 }
}