mIRC Homepage
Posted By: Garou exempt op - 20/07/07 12:31 PM
Why is my script banning op on join?

raw 319:*:{
if (%drone != off) && (%options.exempt != on) && ($nick(#chat,$me,~&@%)) {
if $numtok($3-,32) > 12 {
if ($wildtok($3-,#*,$numtok($3-,32),32)) ban -ku3600 #chat $2 2 14Drone Bot - Excess Channels
}
}
}
Posted By: maroon Re: exempt op - 20/07/07 12:47 PM
perhaps you are doing this before the op has a chance to actually be given op level?
Posted By: Garou Re: exempt op - 20/07/07 12:58 PM
No it banned after he got op, thats what I dont get...
Posted By: SladeKraven Re: exempt op - 20/07/07 12:59 PM
maroon is right, you need to add some kind of safe list to make them exempt.
Posted By: Garou Re: exempt op - 20/07/07 01:08 PM
If I was to add this line, would this help?

if (($nick isop $chan) || (exempt isin $level($fulladdress))) halt
Posted By: SladeKraven Re: exempt op - 20/07/07 01:11 PM
No because $chan doesn't work in Raw events, you're better off using $level or adding the nicknames in a hash table and having something like:

Code:
raw 319:*:{
  if (%drone != off) && (%options.exempt != on) && ($nick(#chat,$me,~&@%)) {
    if $numtok($3-,32) > 12 {
      if ($wildtok($3-,#*,$numtok($3-,32),32)) && (!$hget(exempt,$2)) ban -ku3600 #chat $2 2 14Drone Bot - Excess Channels
    }
  }
}
Posted By: Garou Re: exempt op - 20/07/07 01:13 PM
I see ok I make a file named exempt with nicks to be exempted right? Or add the nicks to my script exempt list?
Posted By: maroon Re: exempt op - 20/07/07 01:37 PM
If your /whois is done inside the ON JOIN event, the /whois reply comes before the op is given their OP status, but the resulting ban comes after they've been given OP status.

If you're trying to prevent spammers, it's possible for someone to blurt out their spam before the ban takes effect. One method some channels do is to make the channel +m moderated, then give everyone voice except the spammers.

You'll probably want to give OP based on address mask, instead of nick. Anyone could use a non-registered nick, and even a registered nick for the few seconds needed to join a channel. It's harder for them to be ident@*.some-ISP.com
Posted By: SladeKraven Re: exempt op - 20/07/07 01:43 PM
Code:
On *:Start: {
  hmake exempt 10
  if ($isfile(exempt.hsh)) hload -i exempt exempt.hsh
}

alias isexempt { return $iif($hget(exempt,$1),$true,$false) }
alias exempt {
  if (!$hget(exempt)) hmake exempt 10
  if ($1 == -r) {
    if (!$2) echo 2 * /exempt: insufficient parameters
    elseif (!$hget(exempt,$2)) echo 3 * /exempt: $2 not in list
    else { hdel exempt $2 | echo 3 * Removed $2 from exempt list }
  }
  elseif ($1 == -l) {
    if ($hget(exempt,0) < 1) echo 2 * Exempt list empty
    else {
      echo 2 * Exempt list:
      var %x = 1
      while (%x <= $hget(exempt,0).item) {
        echo 3 $hget(exempt,%x).item
        inc %x
      }
    }
  }
  else {
    if (!$hget(exempt,$1)) { hadd exempt $1 $1 | echo 3 * Added $1 to exempt list }
    else { echo 3 * /exempt: $1 is already in list }
  }
  hsave -i exempt exempt.hsh
}

raw 319:*:{
  if (%drone != off) && (%options.exempt != on) && ($nick(#chat,$me,~&@%)) {
    if $numtok($3-,32) > 12 {
      if ($wildtok($3-,#*,$numtok($3-,32),32)) && (!$isexempt($2)) ban -ku3600 #chat $2 2 14Drone Bot - Excess Channels
    }
  }
}


The only thing I tested was the exempt list, which seems to work ok. I haven't actually tested out the Raw though. Hopefully it works.

/exempt <Nick> Adds a nickname to the exempt list.
/exempt -r <Nick> Removes a nickname from the exempt list.
/exempt -l Lists the exempt list.

It should also save the exempt list after using the command too and then reload it when mIRC starts up.
Posted By: Garou Re: exempt op - 20/07/07 01:57 PM
wow cool stuff...thx very much....Last question please...I want to save exempt.hsh in my mirc/sys/ folder?
Posted By: SladeKraven Re: exempt op - 20/07/07 02:04 PM
Code:
On *:Start: {
  hmake exempt 10
  if ($isfile(exempt.hsh)) hload -i exempt $qt($mircdirsys\exempt.hsh)
}

alias isexempt { return $iif($hget(exempt,$1),$true,$false) }
alias exempt {
  if (!$isdir(sys)) mkdir Sys
  if (!$hget(exempt)) hmake exempt 10
  if ($1 == -r) {
    if (!$2) echo 2 * /exempt: insufficient parameters
    elseif (!$hget(exempt,$2)) echo 3 * /exempt: $2 not in list
    else { hdel exempt $2 | echo 3 * Removed $2 from exempt list }
  }
  elseif ($1 == -l) {
    if ($hget(exempt,0) < 1) echo 2 * Exempt list empty
    else {
      echo 2 * Exempt list:
      var %x = 1
      while (%x <= $hget(exempt,0).item) {
        echo 3 $hget(exempt,%x).item
        inc %x
      }
    }
  }
  else {
    if (!$hget(exempt,$1)) { hadd exempt $1 $1 | echo 3 * Added $1 to exempt list }
    else { echo 3 * /exempt: $1 is already in list }
  }
  hsave -i exempt $qt($mircdirsys\exempt.hsh)
}

raw 319:*:{
  if (%drone != off) && (%options.exempt != on) && ($nick(#chat,$me,~&@%)) {
    if $numtok($3-,32) > 12 {
      if ($wildtok($3-,#*,$numtok($3-,32),32)) && (!$isexempt($2)) ban -ku3600 #chat $2 2 14Drone Bot - Excess Channels
    }
  }
} 


I would of said which lines to change but I thought it'd be easier for you just to post the updated code.
Posted By: Garou Re: exempt op - 20/07/07 02:22 PM
Its working great....Thank you sir. smile
Posted By: Garou Re: exempt op - 20/07/07 06:09 PM
Just noticed when I exit or disc that its not saving...any ideal why?
Posted By: SladeKraven Re: exempt op - 20/07/07 06:46 PM
Ooops, sorry mate. Try this.

Code:
On me:*:Disconnect: exempt.sv
On *:Exit: exempt.sv
On *:Start: {
  hmake exempt 10
  if ($isfile(exempt.hsh)) hload -i exempt $qt($mircdirsys\exempt.hsh)
}

alias isexempt { return $iif($hget(exempt,$1),$true,$false) }
alias exempt.sv { hsave -i exempt $qt($mircdirsys\exempt.hsh) }
alias exempt {
  if (!$isdir(sys)) mkdir Sys
  if (!$hget(exempt)) hmake exempt 10
  if ($1 == -r) {
    if (!$2) echo 2 * /exempt: insufficient parameters
    elseif (!$hget(exempt,$2)) echo 3 * /exempt: $2 not in list
    else { hdel exempt $2 | echo 3 * Removed $2 from exempt list }
  }
  elseif ($1 == -l) {
    if ($hget(exempt,0) < 1) echo 2 * Exempt list empty
    else {
      echo 2 * Exempt list:
      var %x = 1
      while (%x <= $hget(exempt,0).item) {
        echo 3 $hget(exempt,%x).item
        inc %x
      }
    }
  }
  else {
    if (!$hget(exempt,$1)) { hadd exempt $1 $1 | echo 3 * Added $1 to exempt list }
    else { echo 3 * /exempt: $1 is already in list }
  }
  exempt.sv
}

raw 319:*:{
  if (%drone != off) && (%options.exempt != on) && ($nick(#chat,$me,~&@%)) {
    if $numtok($3-,32) > 12 {
      if ($wildtok($3-,#*,$numtok($3-,32),32)) && (!$isexempt($2)) ban -ku3600 #chat $2 2 14Drone Bot - Excess Channels
    }
  }
}
Posted By: Garou Re: exempt op - 20/07/07 06:57 PM
Still wont save what I added on exit :P
I also get this error when I save the dialog:
* /hmake: table 'exempt' exists (line 4, dialog22.op)
Posted By: SladeKraven Re: exempt op - 20/07/07 09:48 PM
Code:
On me:*:Disconnect: exempt save
On *:Exit: exempt save
On *:Start: {
  hmake exempt 10
  if ($isfile(exempt.hsh)) hload -i exempt $qt($mircdirsys\exempt.hsh)
}

alias isexempt { return $iif($hget(exempt,$1),$true,$false) }
alias exempt {
  if (!$isdir(sys)) mkdir Sys
  if (!$hget(exempt)) hmake exempt 10
  if ($1 == -r) {
    if (!$2) echo 2 * /exempt: insufficient parameters
    elseif (!$hget(exempt,$2)) echo 3 * /exempt: $2 not in list
    else { hdel exempt $2 | echo 3 * Removed $2 from exempt list }
  }
  elseif ($1 == -l) {
    if ($hget(exempt,0).item < 1) echo 2 * Exempt list empty
    else {
      echo 2 * Exempt list:
      var %x = 1
      while (%x <= $hget(exempt,0).item) {
        echo 3 $hget(exempt,%x).item
        inc %x
      }
    }
  }
  elseif ($1 == save) hsave -i exempt $qt($mircdirsys\exempt.hsh)
  else {
    if (!$hget(exempt,$1)) { hadd exempt $1 $1 | echo 3 * Added $1 to exempt list }
    else { echo 3 * /exempt: $1 is already in list }
  }
  hsave -i exempt $qt($mircdirsys\exempt.hsh)
}

raw 319:*:{
  if (%drone != off) && (%options.exempt != on) && ($nick(#chat,$me,~&@%)) {
    if $numtok($3-,32) > 12 {
      if ($wildtok($3-,#*,$numtok($3-,32),32)) && (!$isexempt($2)) ban -ku3600 #chat $2 2 14Drone Bot - Excess Channels
    }
  }
} 


I think the only reason you got that error is because On Start also works the same way On Load does.

From the help file:

The on START event uses the same format, and triggers the first time a script is loaded and every time after that when mIRC is run.

I hope this sorts out the save problem.
Posted By: RusselB Re: exempt op - 20/07/07 10:34 PM
1) No need for the me prefix in the ON DISCONNECT event, since that event only responds when you disconnect.

2) I avoid the 'table exists' error by using this format in the ON START event
Code:
on *:start:{
  if !$hget(exempt)  .hmake exempt 10
  if $exists($mircdirsys\exempt.hsh) hload -i exempt $mircdirsys\exempt.hsh
}

My preference is to use $exists rather than $isfile, since $exists will return false if the file has a 0 byte size, but $isfile will return true.

Also, the directory where the file is stored has to be contained in the $exists/$isfile otherwise mIRC will only check the installation directory.

The $qt isn't required, even if there are spaces in $mircdir
If there were spaces in the sub-directory name off of $mircdir
eg: $mircdirRussel Bairstow\exempt.hsh
does require the $qt so that it reads $qt($mircdirRussel Bairstow\exempt.hsh)
Posted By: SladeKraven Re: exempt op - 20/07/07 10:42 PM
Quote:

1) No need for the me prefix in the ON DISCONNECT event, since that event only responds when you disconnect.


The OP wanted to save it when he disconnected.

Quote:

2) I avoid the 'table exists' error by using this format in the ON START event
Code:
on *:start:{
  if !$hget(exempt)  .hmake exempt 10
  if $exists($mircdirsys\exempt.hsh) hload -i exempt $mircdirsys\exempt.hsh
}



That usually only happens when you overwrite your old script with a new script. Your code is fine if you're going to be loading/unloading it alot but that's about it.
Posted By: RusselB Re: exempt op - 20/07/07 10:52 PM
The ON DISCONNECT event will only trigger when the OP (presuming the OP is running the script) disconnects. A disconnection by anyone else triggers the ON QUIT event
Posted By: SladeKraven Re: exempt op - 20/07/07 10:54 PM
Originally Posted By: RusselB

The ON DISCONNECT event will only trigger when the OP (presuming the OP is running the script) disconnects.

Yes, and that's exactly what he wanted.

Originally Posted By: Garou

Just noticed when I exit or disc that its not saving...any ideal why?
Posted By: Garou Re: exempt op - 21/07/07 01:48 AM
Thx guys...I finally got it to work this way with no more error:

Code:

On me:*:Disconnect: exempt save
On *:Exit: exempt save
on *:start:{
  if (!$isdir($mircdirsys)) mkdir $qt($mircdirsys)
  if !$hget(exempt)  { .hmake exempt 10 }
  if $exists($mircdirsys\exempt.hsh) { .hload -i exempt $mircdirsys\exempt.hsh }
}

 
Posted By: Garou Re: exempt op - 21/07/07 02:10 AM
Is it possible to apply this same exempt code for this rev door script to also exempt op?
If yes how?

Code:
 

on @*:join:#:{
  if ( %door == off ) || ( %door == $null ) || ($nick isop $chan) { return }
  if (% [ $+ [ $wildsite ] $+ ] .rd == $null) { set -u30 % [ $+ [ $wildsite ] $+ ] .rd on }
}
on @*:PART:#:{
  if ( %door == off ) || ( %door == $null ) || ($nick isop $chan) { return }
  if (% [ $+ [ $wildsite ] $+ ] .rd != $null) { ban -u600 # $mask($fulladdress,2) }
}


Posted By: RusselB Re: exempt op - 21/07/07 04:47 AM
You'll need to put a small delay into your ON JOIN event, as any nick that joins is a regular user (no ops, no half-ops, no voice, etc.) at the time of joining.

Personally, I would leave your events as is, but add the following
Code:
on *:op:#:{
  if $($+(%,$wildsite,.rd),2) {
    unset $+(%,$wildsite,.rd)
  }
}
on *:serverop:#:{
  if $($+(%,$wildsite,.rd),2) {
    unset $+(%,$wildsite,.rd)
  }
}


That will unset the variable when the person is opped, if it hasn't already been unset via the -u switch.

One little note, and this is just my preference, for the BAN command in the ON PART event, I like to use
Code:
ban -u600 $nick 2
The usage of the 2 parameter in the $mask identifier, realistically nullifies the usage of $fulladdress, since you end up with the wildcarded address for the ban.

The reason I like doing it the way I showed, is that the $bnick identifier is filled when using that method, however, using your method, it is not.
Posted By: Garou Re: exempt op - 21/07/07 06:30 AM
Ok cool Ill try it thx.
Posted By: SladeKraven Re: exempt op - 21/07/07 01:07 PM
Code:
on @*:join:#:{
  if (%door == off) || (!%door) || ($isexempt($nick)) { return }
  if (% [ $+ [ $wildsite ] $+ ] .rd == $null) { set -u30 % [ $+ [ $wildsite ] $+ ] .rd on }
}
on @*:PART:#:{
  if (%door == off) || (!%door) { return }
  if (% [ $+ [ $wildsite ] $+ ] .rd != $null) { ban -u600 # $mask($fulladdress,2) }
}


Use my $isexempt alias to check if they're in the list or not.

I didn't add it for the On Part event because if the var isnt set for them when they join it's not going to be there if/when they part.
Posted By: Garou Re: exempt op - 21/07/07 05:37 PM
SladeKraven cool stuff thx mate.
Posted By: SladeKraven Re: exempt op - 21/07/07 05:58 PM
Glad it works for ya, have fun! smile
© mIRC Discussion Forums