mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2005
Posts: 91
T
truguce Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Oct 2005
Posts: 91
I have this unban script that only will tell me who is banned in the room asked like !unban #help list, will list all bans in that room. Is there a way to grab the bans from all the open channels the bot has open like
<me>!ban list
<bot>Names banned in $chan
<bot>...Nothing in this room
<bot>Names banned in $chan
<bot> *!*@comcast.net
<bot>Names banned in $chan

and so on. this is what i got so far
Code:
on +Op:text:!unban *:?:{
  if ($3 == list) {
    if ($ibl($2,0) != 0) {
      msg $nick Ban list for $2:
      var %i = 1
      while (%i &lt;= $ibl($2,0)) {
        msg $nick %i $+ : $ibl($2,%i) set by $ibl($2,%i).by on $ibl($2,%i).date 
        inc %i 
      }
    }
    else { msg $nick $2 has no bans! }
  }
  else if ( ! isin $3 &amp;&amp; @ isin $3) {
    if ($3 isban $2) {
      mode $2 -b $3
      msg $nick Ban $3 removed from $2
    }
    else {
      msg $nick $3 was not found on $2 ban list.
    }
  }
  else { msg $nick $3 is not a valid banmask. }
}

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
You could loop through the channels that the bot has open

Code:
 on op:text:!unban*:*:{
if $2 == list {
var %a = $comchan($me,0)
while %a {
unban $comchan($me,%a) list
inc %a
}
}
else { unban $2- }
}
alias unban {
  if ($2 == list) {
    if $ibl($1,0) {
      msg $nick Ban list for $1 $+ :
      var %i = 1
      while (%i &lt;= $ibl($1,0)) {
        msg $nick %i $+ : $ibl($1,%i) set by $ibl($1,%i).by on $ibl($1,%i).date 
        inc %i 
      }
    }
    else { msg $nick $1 has no bans! }
  }
  elseif ((! isin $2) &amp;&amp; (@ isin $2)) {
    if ($2 isban $1) &amp;&amp; ($me isop $1) {
      mode $1 -b $2
      msg $nick Ban $2 removed from $1
    }
  }
  elseif ($me isop $1) {    msg $nick $2 was not found on $1 ban list.  }
  else {    msg $nick I don't have authorization to unban $2 from $1 $+ .  I need ops to do that.  }
  else { msg $nick $2 is not a valid banmask. }
}
 


I added a couple of little things that I think are nice, but by no means required. Examples: The check to ensure that the bot is opped on the channel before it tries to unban someone, and the message if it isn't opped.

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
/help $comchan
in this case $comchan($me) to get the list of channels the bot is in and use that to send the list with a loop to where you have $2


Link Copied to Clipboard