This code performs several functions:
1) Keeps tracks of channel keys. When the key of a channel that you are on changes, the script records that and saves the information in a file. This also saves the key of any channels that you join. Whenever you want to rejoin that channel, but you get an error saying you need a key, the script automatically joins the channel with the previously saved key.
2) If you cannot join a channel because it has mode +R set (registered users only), it automatically joins that channel if you identify yourself (with NickServ) within two minutes.
3) The /chanops command keeps a list of channels in which you have operator status or above. This list is used in case:
3a) You are banned from a channel. The script automatically asks ChanServ to unban you and automatically joins the channel upon being unbanned.
3b) Mode +i is set on a channel. The script automatically asks ChanServ to invite you and automatically joins upon receiving an invite.
Syntax:
/chanops - Views list of channels where the script's "automatically ask ChanServ to unban/invite you in case X happens" function activates
/chanops +<#channel> - Adds channel to list
/chanops -<#channel> - Removes channel from list
/chanops clearall - Clears list
The /clearops list automatically separates itself by network, so you can have ops in two channels named exactly the same on two different networks and be fine.
/chankeys - Opens the data file in Notepad.
This script is great when used in conjunction with an autojoin script of your choosing.
on *:JOIN:#:{
if ($chan($chan).key) { writeini chankeys.ini $network $chan $chan($chan).key }
}
on *:INVITE:#:{
if ($nick == ChanServ && %joinoninv) { join $replace(%joinoninv.chans,$chr(32),$chr(44)) }
}
on *:MODE:#:{
if (k isin $1) {
if ($chan($chan).key) { writeini chankeys.ini $network $chan $chan($chan).key }
else { remini chankeys.ini $network $chan }
}
}
on *:NOTICE:*You have been unbanned*:?:{
if ($nick == ChanServ && %joinonunb) {
if ($numtok(%joinonunb.chans,32) > 1 && !$timer(joinonub)) { timerjoinonunb 1 $calc(3 * $numtok(%joinonunb.chans,32)) join $replace(%joinonunb.chans,$chr(32),$chr(44)) }
else { join %joinonunb.chans }
}
}
on *:NOTICE:*Password accepted*:?:{
if ($nick == NickServ && %joinonident) { join $replace(%joinonident.chans,$chr(32),$chr(44)) }
}
raw 473:*(+i)*:{
if ($2 $+ $chr(44) isin $readini(chankeys.ini,$network,chanops)) {
msg chanserv invite $2
if (!%joinoninv) { inc -u10 %joinoninv }
set -u10 %joinoninv.chans %joinoninv.chans $2
}
}
raw 474:*(+b)*:{
if ($2 $+ $chr(44) isin $readini(chankeys.ini,$network,chanops)) {
msg chanserv unban $2
if (!%joinonunb) { inc -u120 %joinonunb }
set -u120 %joinonunb.chans %joinonunb.chans $2
}
}
raw 475:*(+k)*:{
if ($readini(chankeys.ini,$network,$2)) { join $2 $v1 }
}
raw 477:*registered*:{
if (!%joinonident) { inc -u120 %joinonident }
set -u120 %joinonident.chans %joinonident.chans $2
}
alias chankeys { run notepad.exe chankeys.ini }
alias chanops {
var %chan = $right($1,$calc($len($1) - 1))
if (!$1) { echo -e $me is an operator in: $iif($readini(chankeys.ini,$network,chanops),$left($replace($v1,$chr(44),$chr(44) $+ $chr(32)),$calc($len($replace($v1,$chr(44),$chr(44) $+ $chr(32))) - 2)) $+ .,No channels listed yet.) Type /chanops +<#chan> to add channels. Use the minus sign (-) or "/chanops clearall" to remove channels. }
if ($left($1,1) == +) {
if ($left($1,2) == +#) {
if (%chan $+ $chr(44) isin $readini(chankeys.ini,$network,chanops)) { echo -e The channel $v1 is already in the list of channels you are an operator in. }
else {
writeini chankeys.ini $network chanops $readini(chankeys.ini,$network,chanops) %chan $+ $chr(44)
echo -e The channel %chan has been added to the list of channels you are an operator in.
}
}
else { echo -e Insufficient parameters. Example of correct syntax: /chanops +#thecoolkidsclub }
}
if ($left($1,1) == -) {
if ($left($1,2) == -#) {
if (%chan $+ $chr(44) !isin $readini(chankeys.ini,$network,chanops)) { echo -e The channel %chan is not in the list of channels you are an operator in. }
else {
var %change = $remove($readini(chankeys.ini,$network,chanops),%chan $+ $chr(44))
if (%change) { writeini chankeys.ini $network chanops $v1 }
else { remini chankeys.ini $network chanops }
echo -e The channel %chan has been removed from the the list of channels you are an operator in.
}
}
else { echo -e Insufficient parameters. Example of correct syntax: /chanops -#underthebridge }
}
if ($1 == clearall) {
remini chankeys.ini $network chanops
echo -e The list of channels you are operator on for $network has been cleared.
}
}