|
|
Joined: Jan 2003
Posts: 5
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Jan 2003
Posts: 5 |
Basically, need a way for a script to iterate though all a user's open channels, and not just on one server (the one where the event fired).
Perhaps an N/servername after the first N/# ?
|
|
|
|
Joined: Dec 2002
Posts: 1,321
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,321 |
Let's assume you want to do a kick/ban on all networks at one time. Here's the strategy:
- alias KBAN {
Name your alias something distinctive.
KBAN stands for Kick/Ban All Networks. This alias will expect at least one parameter, the nick to kick/ban, and will also accept a reason in $2- or provides a default reason of "Get out!"
- var %wildsite = $address($1,2)
- var %reason = $iif($2,$2-,Get out!)
Store their current site and the kick reason.
You have to get this address saved before you switch out of this connection because $address($1,2) might not be the same on another connection, and likely won't be. nick!userid can be changed on a per-connection basis with /server -m irc.bleh.com -i nick anick userid fullname, so only the *!*@site needs to be kept the same. If they are using a proxy or BNC on the other connections, you're out of luck...your script won't be able to detect that. Different people can and do use the same nick on different networks, so you can't go by that...same for userid.
- var %activeCID = $activecid
Store the currently active cid
You'll want to rejoin the same CID after your script completes, but you'll need to change the active cid as you loop through each connection. You'll want to use scon over scid because scon is always sequential, scid frequently isn't. However, you'll return to your regularly scheduled channel at script completion by resetting your cid to %activecid.
- var %s = 1
- while ($scon(%s)) {
Loop through each connection you have.
- scon %s
Switch to the nth (%s) connection
- var %n = 1
- while ($ial(%wildsite,%n).nick)) {
Loop through each nick they have on that connection that your Internal Address List (IAL) knows about.
- var %nick = $ifmatch
Set %nick as whichever nick we found.
This makes looking at such things as $comchan(%nick,%i) easier since scripters are used to looking at $comchan($nick,%i). We'll do the same thing with %chan in a minute.
- var %i = 1
- while ($comchan(%nick,%i)) {
Loop through each common channel with that nick.
- var %chan = $ifmatch
Use %chan the same way we use %nick.
- if ($me isop %chan) {
Check to make sure we're opped in a that common channel before we kick & ban him.
- mode %chan +b %wildsite
- kick %chan %nick %reason
- }
Ban the *!*@wild.site and then kick that nick from that channel.
- inc %i
- }
Go on to the next channel for this nick on this connection.
- inc %n
- }
Go on to the next nick on that connection and repeat the channel search.
- inc %s
- }
Go on to the next connection and repeat the entire process for that connection.
- scid %activeCID
- }
Done with the work; switch back to the active window.
And now, for a formatted version in [[/b]code] [[/b]/code] form without all the comments:
alias KBAN {
var %wildsite = $address($1,2)
var %reason = $iif($2,$2-,Get out!)
var %activeCID = $activecid
var %s = 1
while ($scon(%)) {
scon %s
var %n = 1
while ($ial(%wildsite,%n).nick)) {
var %nick = $ifmatch
var %i = 1
while ($comchan(%nick,%i)) {
var %chan = $ifmatch
if ($me isop %chan) {
mode %chan +b %wildsite
kick %chan %nick %reason
}
inc %i
}
inc %n
}
inc %s
}
scid %activeCID
} Change the mode and kick command lines and insert your own code to do whatever it is to %nick on %chan.
DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
|
|
|
|
|
|