mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 21
L
listner Offline OP
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Dec 2002
Posts: 21
I have written a small alias that does a kick/ban of users from all channels where I have ops. I have set it up with multiple loops:
The first loop sets the channel ban on all channels where I have ops.
The second loop creates a list of common channels where I have ops (using $comchan).
The third loop goes through the 'cached' list created by the second loop and does the actual kicks.

(I needed to keep in mind that although we may have common channels, I might not have channel ops in all of them.)

My reasoning for doing this, is that if I only used $comchan and not cache that information first, then whenever I did the kicks wouldnt the $comchan list change as I'm going along?

The coding is not that hard to do, but thought I would get someone else's opinion on this.

Thanks!

Listner


Morals: When the p0rn shop gives you too much change, and you don't keep it.
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
The trick is to perform the kicks (and bans, really) backwards through $comchan(nick,%i). Also, it's faster if you send both the MODE command and the KICK command in the same data packet (less flooding and much faster). You didn't say exactly how you're triggering this script, so I'm going to assume it's an alias for this example. Note: I'll use the variables %nick and %chan since you are probably used to looking at $nick and $chan in $comchan() so $comchan(%nick,%i) and MODE %chan won't be too unusual to look at.
Code:

alias kball {
  ;  A raw KICK reason needs to start with a colon if it contains multiple words.
  if ($2) var %reason = $+(:,$2-)
  else var %reason = :Get out!
  var %nick = $1
  var %i = $comchan(%nick,0)
  while ($comchan($1,%i)) {
    var %chan = $ifmatch
    if ($me isop %chan) .raw $+(MODE %chan +b $address(%nick,2),$crlf,KICK %chan %nick %reason)
    dec %i
  }
}
  • /kball Nickname
  • /kball Hammer


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
Joined: Dec 2002
Posts: 21
L
listner Offline OP
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Dec 2002
Posts: 21
I'll give that a shot and see how it works. Yes, I'm familiar with the normal mode for bans and the kick command as well, but I've never really done anything with the raw commands.

What's amazing is that it never occured to me, to go 'backwards' through the $comchan list. (duhh) I guess that's one of those things that's too obvious to see?

Thanks for the info Hammer; you've been very helpful. smile

Listner


Morals: When the p0rn shop gives you too much change, and you don't keep it.
Joined: Dec 2002
Posts: 76
A
Babel fish
Offline
Babel fish
A
Joined: Dec 2002
Posts: 76
3 No such channel
what wrong ???

Joined: Dec 2002
Posts: 774
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Dec 2002
Posts: 774
$comchan is not updated while the script is running, so it's same in what order you make the kicks.
About the "3 No such channel", are you sure you don't have some other script making that?


Code:
alias kball {
  ;  A raw KICK reason needs to start with a colon if it contains multiple words.
  if ($2) var %reason = $+(:,$2-)
  else var %reason = :Get out!
  var %nick = $1
  var %i = $comchan(%nick,0)
  while (%i) {
    var %chan = $comchan(%nick,%i)
    if ($me isop %chan) .raw $+(MODE %chan +b $address(%nick,2),$crlf,KICK %chan %nick %reason)
    dec %i
  }
}



Code:
//if ( khaled isgod ) echo yes | else echo no
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
In the original code, I had %i decrementing, but was still using it inside $comchan(). When %i got to 0, it returned the number of common channels (3) in the while condition, which got set to %chan.
Code:

  ;  Original code
  var %i = $comchan(%nick,0)
  while ($comchan($1,%i)) {
    var %chan = $ifmatch
You can fix this at least 2 ways. Still going backwards, you'd use:
Code:

  var %i = $comchan(%nick,0)
  while (%i) {
    var %chan = $comchan(%nick,%i)
    if ($me isop %chan) .raw $+(MODE %chan +b $address(%nick,2),$crlf,KICK %chan %nick %reason)
    dec %i
  }
or going forwards, you'd use:
Code:

  var %i = 1
  while ($comchan(%nick,%i)) {
    var %chan = $ifmatch
    if ($me isop %chan) .raw $+(MODE %chan +b $address(%nick,2),$crlf,KICK %chan %nick %reason)
    inc %i
  }


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C

Link Copied to Clipboard