How to make a VIP script
From Scriptwiki
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 ($ini(vipchans.ini,%checkchan,%x)) { ; put the channelname (prefixed with the mode, ie. @#channel) into a variable %c and the corresponding mode into %mode, replacing @ with o etc. ; so we can use %mode in /mode var %c = $v1 var %mode = $replace($readini(vipchans.ini,%checkchan,$v1),@,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 } ; now, use $str to get the nickname as many times as there are modes (+o NICK or +ov NICK NICK) 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 } }