This snippet allows you to part all channels matching a wildcard mask. Example: If I was in #Random, #Random_Sonic, and #RandomIRC, I could simply type /partwild Random to get out of those channels. This alias also supports a part message, which is the same for each channel. You can place this in your aliases.ini file (remove alias from the snippet), or in your remotes.
;PARTWILD v1.0 by Cinos Modnar
alias partwild {
if (!$1) { echo $color(info) -a * /partwild: No channel given. | halt }
var %n 1
while ($chan(%n)) {
if ($1 iswm $chan(%n)) {
part $chan(%n) $2-
}
inc %n
}
}
I read your script incorrectly at first glance. I wasn't aware you have to specify * to enclose a partially matched channel name in order to part the rest.
$v1 and $v2 can be used to return the targeted value:
var %n 1
while ($chan(%n)) {
if ($1 iswm $v1) {
part $v2 $2-
}
inc %n
}
Edit - my mistake. I just realize the $2- is used for the part message. Perhaps $v1 and $v2 don't do much good either, 'cause if someone uses a very old copy of mIRC, they won't work. Nice work, I suppose. ^^
If you type an invalid channel or a channel you're not on, the script wouldn't find any matches and would not do anything. I'm not 100% sure what you mean though. Also, it is not meant to be multiple target (IE /partwild random sonic), but an idea for a future revision would be to parse the channel list to part instead of doing manual /parts for each matching channel (making a list like #channel1,#channel2,#channel3 and parting them in that way). This would prevent excess flooding and lagging due to sending so many requests at once.
Well, this script will result an error if you enter something phantom, meaning you can enter: /part <#This is the actual channel you're on> <#Something Imagainative> Or <#Nonexistent channel>
I'm not saying that is likely to happen to be abused, but the $2- can be anything you want them to be.
And you may need to specify the comma separating each channel to part. That's how multiple targets work in most irc networks I've come across.