Difference between revisions of "How to make a VIP script"
From Scriptwiki
m (added category) |
(added new version) |
||
Line 1: | Line 1: | ||
− | How to check if a user | + | 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. | + | 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 | ||
− | on !*:join:# | + | == 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 | ||
− | + | ; 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:*:{ | raw 319:*:{ | ||
; Channels list | ; Channels list | ||
− | ; In this raw we loop through the | + | ; 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). |
− | if (% | + | |
+ | 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 | + | ; 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) | ||
− | + | ||
− | + | 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 | 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 % | + | ; 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 13: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 } }