Difference between revisions of "How to make a VIP script"

From Scriptwiki
Jump to: navigation, search
m (added category)
(added new version)
Line 1: Line 1:
How to check if a user is opped on some channel where you/your bot isn't.
+
How to check if a user has modes on some channel(s) where you/your bot isn't, and give him modes on your own channel(s).
We'll be using vipchannels.txt to store the VIP channels we want to check, each channel on their own line, ie:
+
We'll be using vipchannels.ini to store the VIP channels we want to check, each of your OWN channels works as a topic, and items are the VIP channels with modes you wanna check, and data is mode you wanna give
#myvipchannel
 
#somechannel
 
#help.script
 
  
On to the script:
+
== Overview ==
 +
'''Example of the file:'''
 +
[#my_very_own_channel]
 +
@#a-vip-channel=@
 +
+#a-vip-channel=+
 +
@#help.script=+
 +
+#someweirdchan=@
 +
 +
[#my_other_channel]
 +
@#vipvip=@
 +
 
 +
If you had the file like this, and user joins #my_very_own_channel, the bot then checks the channels from that section.
 +
* if user is opped in #a-vip-channel, he gets opped
 +
* if user is voiced in #a-vip-channel, he gets voiced
 +
* if user is opped in #help.script, he gets voiced
 +
* if user is voiced in #someweirdchan, he gets opped
 +
 
 +
And, if the user joins #my_other_channel
 +
* if user is opped in #vipvip, he gets opped
  
  on !*:join:#YOURCHAN:{
+
== the script ==
   ; We'll set a temporary global variable to indicate that we're checking the VIP, so we can halt the default /whois text from showing up
+
 
 +
; REMEMBER to change these channels too! so we can prevent the execution on useless channels
 +
  on !*:join:#my_very_own_channel,#my_other_channel:{
 +
   ; We'll set a temporary global variable to indicate that we're checking the VIP, so we can halt the default /whois text from showing up, at the same, we will store the channelname into that variable
 
   ; Then we'll do whois on the nick. Note the "!" in the join event: it prevents the script from triggering, if it is you who joined
 
   ; Then we'll do whois on the nick. Note the "!" in the join event: it prevents the script from triggering, if it is you who joined
   set %vipcheck 1
+
   ; the timer has a delay of "pendin vip check"^3, so it won't flood of the bot after a netsplit
   whois $nick
+
  .timer 1 $calc($var(%vipcheck*) ^3) whois $nick
 +
   set %vipcheck $+ $nick $chan
 
  }
 
  }
 
   
 
   
 
  raw 319:*:{
 
  raw 319:*:{
 
   ; Channels list
 
   ; Channels list
   ; In this raw we loop through the txt-file vipchannels.txt and see if the user is opped on any of these channels
+
   ; In this raw we loop through the ini-file to see check the channels and modes and compare them into the channels, the user is on
   ; This will only be done when the %vipcheck is set
+
   ; We put the channelname from %vipcheck [ $+ [ $2 ] ] into a bit more handy variable %checkchan ($2 is the nick).
   if (%vipcheck) {  
+
 +
  var %checkchan = %vipcheck [ $+ [ $2 ] ]
 +
   if (%checkchan) {  
 
     var %x = 1  
 
     var %x = 1  
 
     while ($read(vipchannels.txt,%x)) {  
 
     while ($read(vipchannels.txt,%x)) {  
       ; put the channel name into a variable %c
+
       ; put the channelname (prefixed with the mode, ie. @#channel) into a variable %c and the corresponding mode first into %m, and then into %mode, and replace @ with o etc.
 +
      ; so we can do /mode
 
       var %c = $v1
 
       var %c = $v1
 +
      var %m = $readini(vipchans.ini,%checkchan,$v1)
 +
      var %mode = $replace(%m,@,o,+,v,%,h)
 
   
 
   
       ; see if $+(@,%c) (equals: @ $+ #somevipchannel) is found from the users channels
+
        
      if ($istok($3-,$+(@,%c),32)) {  
+
      if ($istok($3-,%c,32)) {  
+
        ; so, he has sufficient access on some channel, we'll check that we're not setting the new mode for him, and if not, add it
        ; @#somevipchannel was found, so the user is opped on this channel, we tell the user that he's a vip, and set mode +o for him on another chan (note that $2 is the users nick here)
+
        ; (%modes string could be like +ov if he gets ops and voices)
        msg $2 you are opped on %c $+ , and that makes you a VIP.
+
        if (%mode !isin %modes) { var %modes = $+(%modes,%mode) }     
        mode #YOURCHAN +o $2
+
      }  
        break
 
      }  
 
 
       inc %x  
 
       inc %x  
 
     }
 
     }
+
    mode %checkchan $+(+,%modes) $str($+($2,$chr(32)),$len(%modes))
 
     ; haltdef so that you don't see the channels everytime someone joins
 
     ; haltdef so that you don't see the channels everytime someone joins
 
     haltdef  
 
     haltdef  
Line 42: Line 64:
 
  raw 318:*:{  
 
  raw 318:*:{  
 
   ; end of /whois
 
   ; end of /whois
   ; here we just unset the temporary variable %vipcheck, so we can use normal /whois again
+
   ; here we just unset the temporary variable %vipcheckNICK, so we can use normal /whois again
   if (%vipcheck) { unset %vipcheck | haltdef }  
+
   if (%vipcheck [ $+ [ $2 ] ]) { unset %vipcheck [ $+ [ $2 ] ] | haltdef }  
 
  }
 
  }
 
   
 
   
Line 49: Line 71:
 
  raw 301:*:{  
 
  raw 301:*:{  
 
   ; away
 
   ; away
   if (%vipcheck) { haltdef }  
+
   if (%vipcheck [ $+ [ $2 ] ]) { haltdef }  
 
  }
 
  }
 
  raw 311:*:{  
 
  raw 311:*:{  
 
   ; user's ident, host and realname
 
   ; user's ident, host and realname
   if (%vipcheck) { haltdef }  
+
   if (%vipcheck [ $+ [ $2 ] ]) { haltdef }  
 
  }
 
  }
 
  raw 312:*:{  
 
  raw 312:*:{  
 
   ; server information
 
   ; server information
   if (%vipcheck) { haltdef }  
+
   if (%vipcheck [ $+ [ $2 ] ]) { haltdef }  
 
  }
 
  }
 
  raw 313:*:{  
 
  raw 313:*:{  
 
   ; if the user is IRCop
 
   ; if the user is IRCop
   if (%vipcheck) { haltdef }  
+
   if (%vipcheck [ $+ [ $2 ] ]) { haltdef }  
 
  }
 
  }
 
  raw 317:*:{  
 
  raw 317:*:{  
 
   ; signon and idle time
 
   ; signon and idle time
   if (%vipcheck) { haltdef }  
+
   if (%vipcheck [ $+ [ $2 ] ]) { haltdef }  
 
  }
 
  }
 
  raw 330:*:{  
 
  raw 330:*:{  
 
   ; users auth
 
   ; users auth
   if (%vipcheck) { haltdef }  
+
   if (%vipcheck [ $+ [ $2 ] ]) { haltdef }  
 
  }
 
  }
  
 
[[Category:Tutorials]]
 
[[Category:Tutorials]]

Revision as of 14:02, 3 July 2007

How to check if a user has modes on some channel(s) where you/your bot isn't, and give him modes on your own channel(s). We'll be using vipchannels.ini to store the VIP channels we want to check, each of your OWN channels works as a topic, and items are the VIP channels with modes you wanna check, and data is mode you wanna give

Overview

Example of the file:

[#my_very_own_channel]
@#a-vip-channel=@
+#a-vip-channel=+
@#help.script=+
+#someweirdchan=@

[#my_other_channel]
@#vipvip=@

If you had the file like this, and user joins #my_very_own_channel, the bot then checks the channels from that section.

  • if user is opped in #a-vip-channel, he gets opped
  • if user is voiced in #a-vip-channel, he gets voiced
  • if user is opped in #help.script, he gets voiced
  • if user is voiced in #someweirdchan, he gets opped

And, if the user joins #my_other_channel

  • if user is opped in #vipvip, he gets opped

the script

; REMEMBER to change these channels too! so we can prevent the execution on useless channels
on !*:join:#my_very_own_channel,#my_other_channel:{
  ; We'll set a temporary global variable to indicate that we're checking the VIP, so we can halt the default /whois text from showing up, at the same, we will store the channelname into that variable
  ; Then we'll do whois on the nick. Note the "!" in the join event: it prevents the script from triggering, if it is you who joined
  ; the timer has a delay of "pendin vip check"^3, so it won't flood of the bot after a netsplit
  .timer 1 $calc($var(%vipcheck*) ^3) whois $nick
  set %vipcheck $+ $nick $chan
}

raw 319:*:{
  ; Channels list
  ; In this raw we loop through the ini-file to see check the channels and modes and compare them into the channels, the user is on
  ; We put the channelname from %vipcheck [ $+ [ $2 ] ] into a bit more handy variable %checkchan ($2 is the nick).

  var %checkchan = %vipcheck [ $+ [ $2 ] ]
  if (%checkchan) { 
    var %x = 1 
    while ($read(vipchannels.txt,%x)) { 
      ; put the channelname (prefixed with the mode, ie. @#channel) into a variable %c and the corresponding mode first into %m, and then into %mode, and replace @ with o etc.
      ; so we can do /mode
      var %c = $v1
      var %m = $readini(vipchans.ini,%checkchan,$v1)
      var %mode = $replace(%m,@,o,+,v,%,h)

      
     if ($istok($3-,%c,32)) { 
       ; so, he has sufficient access on some channel, we'll check that we're not setting the new mode for him, and if not, add it
       ; (%modes string could be like +ov if he gets ops and voices)
       if (%mode !isin %modes) { var %modes = $+(%modes,%mode) }      
     } 
      inc %x 
    }
    mode %checkchan $+(+,%modes) $str($+($2,$chr(32)),$len(%modes))
    ; haltdef so that you don't see the channels everytime someone joins
    haltdef 
  } 
}

raw 318:*:{ 
  ; end of /whois
  ; here we just unset the temporary variable %vipcheckNICK, so we can use normal /whois again
  if (%vipcheck [ $+ [ $2 ] ]) { unset %vipcheck [ $+ [ $2 ] ] | haltdef } 
}

;;; Halting other /whois information from showing up
raw 301:*:{ 
  ; away
  if (%vipcheck [ $+ [ $2 ] ]) { haltdef } 
}
raw 311:*:{ 
  ; user's ident, host and realname
  if (%vipcheck [ $+ [ $2 ] ]) { haltdef } 
}
raw 312:*:{ 
  ; server information
  if (%vipcheck [ $+ [ $2 ] ]) { haltdef } 
}
raw 313:*:{ 
  ; if the user is IRCop
  if (%vipcheck [ $+ [ $2 ] ]) { haltdef } 
}
raw 317:*:{ 
  ; signon and idle time
  if (%vipcheck [ $+ [ $2 ] ]) { haltdef } 
}
raw 330:*:{ 
  ; users auth
  if (%vipcheck [ $+ [ $2 ] ]) { haltdef } 
}