mIRC Homepage
Posted By: listner Question about kickban concept - 31/12/02 09:45 PM
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
Posted By: Hammer Re: Question about kickban concept - 31/12/02 10:15 PM
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
Posted By: listner Re: Question about kickban concept - 31/12/02 10:33 PM
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
Posted By: aZnLupin Re: Question about kickban concept - 01/01/03 10:29 AM
3 No such channel
what wrong ???
Posted By: theRat Re: Question about kickban concept - 01/01/03 04:45 PM
$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
  }
}

Posted By: Hammer Re: Question about kickban concept - 02/01/03 05:04 AM
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
  }
© mIRC Discussion Forums