mIRC Homepage
Posted By: Garou not working - 06/02/07 11:20 PM
Can anyone see why this is not working?

on *:start:{
if !$hget(BadWords) { .hmake BadWords 10 }
if $exists(BadWords.hsh) { .hload BadWords BadWords.hsh }
}
on *:exit:{
.hsave -o BadWords BadWords.hsh
}
on *:disconnect:{
.hsave -o BadWords BadWords.hsh
}

menu menubar {
-
Private Offensive Message
.Turn $iif($hget(BadWords,0),Off,On) : .hadd -m BadWords 0 $iif($hget(BadWords,0),$false,$true
.-
.Add a word : .hadd -m BadWords $$?="Bad Word to be added" $true
.-
.Remove a word : .hdel BadWords $$?="Bad Word to be removed"
.-
.List Spam Words : bad_words_list
.-
}
alias -l bad_words_list {
var %a = 1, %b = $hget(BadWords,0).item
unset %badwords
while %a <= %b {
set %badwords $addtok(%badwords,$hget(BadWords,%a).item,32)
if $numtok(%badwords,32) + $len(%badwords) > 900 {
echo -a $replace(%badwords,$chr(32),$+($chr(44),$chr(32)))
unset %badwords
}
inc %a
}
if %badwords {
echo -a $replace(%badwords,$chr(32),$+($chr(44),$chr(32)))
unset %badwords
}
}
on *:open:?:{
if $ulevel != op && $hget(BadWords,0) {
var %cnt = 1
while (%cnt <= $hget(BadWords,0).item) {
if $hget(BadWords,%cnt).item isin $1- {
close -m $nick
spamdetect $nick
}
else { inc %cnt }
}
}
}

on ^*:notice:*:?: {
if (!$istok(ChanServ NickServ MemoServ,$nick,32)) && $hget(BadWords,0) {
var %cnt = 1
while (%cnt <= $hget(BadWords,0).item) {
if $hget(BadWords,%cnt).item isin $1- {
spamdetect $nick
haltdef
}
else { inc %cnt }
}
}
}

alias spamdetect {
var %a = 1
while $comchan($1,%a).op {
ban -ku3600 $v1 $1 2 14Private Offensive Language
}
inc %a
}
Posted By: Riamus2 Re: not working - 06/02/07 11:44 PM
Would you like to explain what exactly isn't working? And are there errors you see?

Just as a quick, miscellaneous note... /hmake, /hsave, and /hload are already silent except if there is an error message. So there isn't a need to put a . there. If there IS an error message, it would be good to actually SEE it. smile

Also, here is your code inside code tags so that it can be read more easily. Please use code tags whenever you post code on the forum. smile

Code:
on *:start:{
  if !$hget(BadWords) { .hmake BadWords 10 }
  if $exists(BadWords.hsh) { .hload BadWords BadWords.hsh }
}
on *:exit:{
  .hsave -o BadWords BadWords.hsh
}
on *:disconnect:{
  .hsave -o BadWords BadWords.hsh
}

menu menubar {
  -
  Private Offensive Message
  .Turn $iif($hget(BadWords,0),Off,On) : .hadd -m BadWords 0 $iif($hget(BadWords,0),$false,$true
  .-
  .Add a word : .hadd -m BadWords $$?="Bad Word to be added" $true
  .-
  .Remove a word : .hdel BadWords $$?="Bad Word to be removed"
  .-
  .List Spam Words : bad_words_list
  .-
}
alias -l bad_words_list {
  var %a = 1, %b = $hget(BadWords,0).item
  unset %badwords
  while %a <= %b {
    set %badwords $addtok(%badwords,$hget(BadWords,%a).item,32)
    if $numtok(%badwords,32) + $len(%badwords) > 900 {
      echo -a $replace(%badwords,$chr(32),$+($chr(44),$chr(32)))
      unset %badwords
    }
    inc %a
  }
  if %badwords {
    echo -a $replace(%badwords,$chr(32),$+($chr(44),$chr(32)))
    unset %badwords
  }
}
on *:open:?:{
  if $ulevel != op && $hget(BadWords,0) {
    var %cnt = 1
    while (%cnt <= $hget(BadWords,0).item) {
      if $hget(BadWords,%cnt).item isin $1- {
        close -m $nick
        spamdetect $nick
      }
      else {        inc %cnt      }
    }
  }
}

on ^*:notice:*:?: {
  if (!$istok(ChanServ NickServ MemoServ,$nick,32)) && $hget(BadWords,0) {
    var %cnt = 1
    while (%cnt <= $hget(BadWords,0).item) {
      if $hget(BadWords,%cnt).item isin $1- {
        spamdetect $nick
        haltdef
      }
      else {        inc %cnt      }
    }
  }
}

alias spamdetect {
  var %a = 1
  while $comchan($1,%a).op {
    ban -ku3600 $v1 $1 2 14Private Offensive Language
  }
  inc %a
}
Posted By: learn3r Re: not working - 07/02/07 01:52 AM
Isn't it because he didn't included the " auser "
Posted By: Garou Re: not working - 07/02/07 04:09 AM
Ya sorry its adding auto op to my userlist. I dont need the auser stuff in it but i tink it was there to exempt op but its acting weird on me.
Posted By: Riamus2 Re: not working - 07/02/07 02:10 PM
I don't see any reason to use /auser. He's just banning anyone, other than people who have the op user level, who uses specific words.

Again, Garou... what isn't working with it?
Posted By: Garou Re: not working - 07/02/07 02:44 PM
I dont use /auser and thats is whats not working. Its auto adding op that are in my channel to my auto op list and this is my problem I am having.

I also get this error * Invalid format: $iif
Posted By: Scripto Re: not working - 07/02/07 04:42 PM
In your alias bad_words_list...

if $numtok(%badwords,32) + $len(%badwords) > 900 <~~~ This line requires the use of the $calc identifier, it will not add without it.

if ($calc($numtok(%badwords,32) + $len(%badwords)) > 900)
Posted By: Garou Re: not working - 07/02/07 05:15 PM
I still get this error when I click ON
* Invalid format: $iif
Posted By: Scripto Re: not working - 07/02/07 05:19 PM
.hadd -m BadWords 0 $iif($hget(BadWords,0),$false,$true <~~~ close it, on the end here.


The lack of 'close' parenthesis would deem it as having invalid format/parameters.

.hadd -m BadWords 0 $iif($hget(BadWords,0),$false,$true)
Posted By: Garou Re: not working - 07/02/07 05:40 PM
Ok cool, why is it when I turn it on it also adds 0 in the listing and when I cycle the channel when its turn ON it freezing my irc.
Posted By: Scripto Re: not working - 07/02/07 05:43 PM
Because your line states, hadd -m BadWords 0 $iif($hget(BadWords,0),$false,$true)

you have 0 listed as the item behind BadWords, that is format for /hadd. Whatever you list behind BadWords is the item its going to add to, if 0 is not an item, its going to create it as a new item in the table.
Posted By: Garou Re: not working - 07/02/07 05:46 PM
when I cycle the channel when its turn ON its freezing my irc.
Posted By: Scripto Re: not working - 07/02/07 05:51 PM
I dont see any text, join, or part commands, there is nothing that a cycle would trigger to freeze...

Are you sure its this script doing it?

...usually freezes come from bad loops. Loops are a good place to start looking anyhow. This script doesn't have any that would trigger on a cycle though.
Posted By: Garou Re: not working - 07/02/07 05:54 PM
Yes am sure cause it only freeze when its turn ON
Posted By: Scripto Re: not working - 07/02/07 06:04 PM
Are you disconnecting, and then connecting, or just doing a channel /hop?

the on notice...

...hmm, let me look... the channel notice, that might be doing it. Is there an onjoin channel notice?
Posted By: Garou Re: not working - 07/02/07 06:06 PM
both, if I cycle or re-login when its turn ON it will freeze my irc.
I also got this error now * /ban: invalid parameters (line 73, dialog55.op)
Posted By: Scripto Re: not working - 07/02/07 06:27 PM
You are trying to execute two while loops at the same time.

Code:
 
on ^*:notice:*:?: {
  if (!$istok(ChanServ NickServ MemoServ,$nick,32)) && $hget(BadWords,0) {
    var %cnt = 1
    while (%cnt <= $hget(BadWords,0).item) {
      if $hget(BadWords,%cnt).item isin $1- {
        spamdetect $nick
        haltdef
      }
      else {        inc %cnt      }
    }
  }
}

alias spamdetect {
  var %a = 1
  while $comchan($1,%a).op {
    ban -ku3600 $v1 $1 2 14Private Offensive Language
  }
  inc %a
}


First your !$istok line is not evaluating properly... change it to this:

Code:
  var %oknames = ChanServ NickServ MemoServ
  if ($nick !isin %oknames) && $hget(BadWords,0) {


Then you will have to ban and kick the nick in the first loop. You have spamdetect $nick as a second loop that would be trying to operate while the first one is still working, this will freeze your mIRC.

Code:
 on ^*:notice:*:?: {
  var %oknames = ChanServ NickServ MemoServ
  if ($nick !isin %oknames) && $hget(BadWords,0) {
    var %cnt = 1
    while (%cnt <= $hget(BadWords,0).item) {
      if $hget(BadWords,%cnt).item isin $1- {
        if ($me isop $chan) {
        /ban -ku3600 $chan $nick
        halt
        }
      }
      else inc %cnt 
    }
  }
}
 


Posted By: Garou Re: not working - 07/02/07 06:34 PM
ok cool now i got this error * /ban: invalid parameters (line 77, dialog55.op)
Posted By: Scripto Re: not working - 07/02/07 06:50 PM
If you want to kick the user from all the channels youre on, you will have to break out of the while loop before you can use another loop for kicking. You could try to set this up by triggering a timer instead of the /ban -ku.

Instead of saying /ban -ku3600 $chan $nick, say:

set %kicknick $nick
.timer.allkick $comchan($nick,0) 1 kickalias

Then just write a kick alias that will kick %kicknick from all channels that youre an op on. It will halt the loop, and start a timer, instead of trying to execute two loops within one another.

I would write it out for ya, but i have to get scootin here. If you can't get it, Ill stop back in tomorrow, or perhaps one of the commorades here will jump in and fix this thing up for ya. Its almost there cool

Good luck
Posted By: Garou Re: not working - 07/02/07 06:56 PM
ok here wat i have so far.

Code:
 on *:start:{
  if !$hget(BadWords) { .hmake BadWords 10 }
  if $exists(BadWords.hsh) { .hload BadWords BadWords.hsh }
}
on *:exit:{
  .hsave -o BadWords BadWords.hsh
}
on *:disconnect:{
  .hsave -o BadWords BadWords.hsh
}

menu menubar {
  -
  Private Offensive Message                      
  .Turn $iif($hget(BadWords,0),Off,On) : .hadd -m BadWords 0 $iif($hget(BadWords,0),$false,$true)
  .-
  .Add a word : .hadd -m BadWords $$?="Bad Word to be added" $true
  .-
  .Remove a word : .hdel BadWords $$?="Bad Word to be removed"
  .-
  .List Spam Words : .bad_words_list
  .-
}
alias -l bad_words_list {
  var %a = 1, %b = $hget(BadWords,0).item
  unset %badwords
  while %a <= %b {
    set %badwords $addtok(%badwords,$hget(BadWords,%a).item,32)
    if ($calc($numtok(%badwords,32) + $len(%badwords)) > 900) {
      echo -a $replace(%badwords,$chr(32),$+($chr(44),$chr(32)))
      unset %badwords
    }
    inc %a
  }
  if %badwords {
    echo -a $replace(%badwords,$chr(32),$+($chr(44),$chr(32)))
    unset %badwords
  }
}
on *:open:?:{
  if $ulevel != op && $hget(BadWords,0) {
    var %cnt = 1
    while (%cnt <= $hget(BadWords,0).item) {
      if $hget(BadWords,%cnt).item isin $1- {
        close -m $nick
        spamdetect $nick
      }
      else {        inc %cnt      }
    }
  }
}

 on ^*:notice:*:?: {
  var %oknames = ChanServ NickServ MemoServ
  if ($nick !isin %oknames) && $hget(BadWords,0) {
    var %cnt = 1
    while (%cnt <= $hget(BadWords,0).item) {
      if $hget(BadWords,%cnt).item isin $1- {
        if ($me isop $chan) {
        /ban -ku3600 $chan $nick
        halt
        }
      }
      else inc %cnt 
    }
  }
}


alias spamdetect {
  var %a = 1
  while $comchan($1,%a).op {
    ban -ku3600 $v1 $1 2 14Private Offensive Language 
  }
  inc %a
} 
Posted By: Scripto Re: not working - 07/02/07 07:01 PM
your statement here ~~> on *:open:?:{


...also refers to a second while loop within its commands

spamdetect $nick, must be changed. mIRC cant execute the second loop when the first one is still running, it will crash (freeze) you every time guaranteed.

Ill be back tommorrow my friend smile
Posted By: Scripto Re: not working - 08/02/07 02:55 PM
Give this a shot.

You will have to test it...

Let me know what errors you get, we will go from there.


Code:

on *:start:{
  if !$hget(BadWords) { .hmake BadWords 10 }
  if $exists(BadWords.hsh) { .hload BadWords BadWords.hsh }
}
on *:exit:{
  .hsave -o BadWords BadWords.hsh
}
on *:disconnect:{
  .hsave -o BadWords BadWords.hsh
}

menu menubar {
  -
  Private Offensive Message                      
  .Turn $iif($hget(BadWords,0),Off,On) : .hadd -m BadWords 0 $iif($hget(BadWords,0),$false,$true)
  .-
  .Add a word : .hadd -m BadWords $$?="Bad Word to be added" $true
  .-
  .Remove a word : .hdel BadWords $$?="Bad Word to be removed"
  .-
  .List Spam Words : .bad_words_list
  .-
}
alias -l bad_words_list {
  var %a = 1, %b = $hget(BadWords,0).item
  unset %badwords
  while %a <= %b {
    set %badwords $addtok(%badwords,$hget(BadWords,%a).item,32)
    if ($calc($numtok(%badwords,32) + $len(%badwords)) > 900) {
      echo -a $replace(%badwords,$chr(32),$+($chr(44),$chr(32)))
      unset %badwords
    }
    inc %a
  }
  if %badwords {
    echo -a $replace(%badwords,$chr(32),$+($chr(44),$chr(32)))
    unset %badwords
  }
}
on *:open:?:{
  if ($ulevel != op) && ($hget(BadWords,0)) {
    var %cnt = 1
    while (%cnt <= $hget(BadWords,0).item) {
      if ($hget(BadWords,%cnt).item isin $1-) {
        close -m $nick
        .timer. $+ $nick 1 1 spamdetect $nick
        halt
      }
      inc %cnt      
    }
  }
}

on ^*:notice:*:?: {
  var %oknames = ChanServ NickServ MemoServ
  if ($nick !isin %oknames) && ($hget(BadWords,0)) {
    var %cnt = 1
    while (%cnt <= $hget(BadWords,0).item) {
      if ($hget(BadWords,%cnt).item isin $1-) {
        .timer. $+ $nick 1 1 spamdetect $nick
        halt
      }
      inc %cnt 
    }
  }
}


alias spamdetect {
  var %a = $comchan($1,0).op
  while (%a > 0) {
    ban -ku3600 $comchan($1,%a).op $1 2 14Private Offensive Language 
  }
  dec %a
}  
 


Copy and paste the whole thing, i did change the spamdetect alias a little... its on a timer now, so it wont crash your mIRC.

Ill try to watch the board later on, I have some calculus homework to attend to
Posted By: Garou Re: not working - 08/02/07 03:10 PM
ok thx,
got this error
* /ban: invalid parameters (line 72, dialog55.op)
Posted By: Scripto Re: not working - 08/02/07 03:25 PM
Ok...

try changing your spamdetect alias to this

Code:

alias spamdetect {
  var %a = $comchan($1,0).op
  while (%a > 0) {
    ban -ku3600 $comchan($1,%a).op $1 14Private Offensive Language 
  }
  dec %a
}  

 


Im not particularly fond of using a while loop to ban and kick, but that is the format you had, so that is what we will use for now. Loops are fast, it could have the potential to flood you off of the server. I prefer to use a .timer -m 250 on an alias to kick, it slows things down a little. But for now, lets just use what you have until it doesnt work... lol
Posted By: Garou Re: not working - 08/02/07 03:27 PM
same error

* /ban: invalid parameters (line 72, dialog55.op)
Posted By: Scripto Re: not working - 08/02/07 03:33 PM
hmm, i havent installed 6.21 (shame on me) but im not sure what the dialog55.op error is referring to. There must be an issue with the $comchan identifier... let me write this loop slightly different, to see if we can go around it.
Posted By: Scripto Re: not working - 08/02/07 03:36 PM
Code:
 
alias spamdetect {
  var %a = $comchan($1,0)
  while (%a > 0) {
    if ($me isop $comchan($1,%a)) {
      ban -ku3600 $comchan($1,%a) $1 14Private Offensive Language 
    }
    dec %a
  } 
}
Posted By: Garou Re: not working - 08/02/07 03:43 PM
Cool its working now but its not exempting op anyway to exempt op?
Posted By: Scripto Re: not working - 08/02/07 04:26 PM
you mean to not kick other ops?

Code:
alias spamdetect {
  var %a = $comchan($1,0)
  while (%a > 0) {
    if ($me isop $comchan($1,%a)) && (($1 !isop $comchan($1,%a)) || ($1 !ishop $comchan($1,%a)))  {
      ban -ku3600 $comchan($1,%a) $1 14Private Offensive Language 
    }
    dec %a
  } 
}
 


This is set up so that ($me isop $chan) and when $nick does not have (ops or halfops)
Posted By: Garou Re: not working - 08/02/07 04:31 PM
Thank you very much bro, All is working fine :P
Posted By: Scripto Re: not working - 08/02/07 04:34 PM
cool cool

youre welcome
Posted By: learn3r Re: not working - 08/02/07 04:38 PM
Quote:
(($1 !isop $comchan($1,%a)) || ($1 !ishop $comchan($1,%a)))


why not use

Code:
$1 isreg $comchan($1,%a)


Code:
alias spamdetect {
  var %i = 1
  if $comchan($nick,0) {
    while $comchan($nick,%i) {
      var %c = $v1
      if $me isop %c && $nick isreg %c { ban -ku600 %c $nick 2  14Private Offensive Language  }
      inc %i
    }
  }
}
Posted By: Scripto Re: not working - 08/02/07 04:43 PM
that would work smile

$nick would have to be $1 though, $nick is evalutated directly in the original script and its identifying value would be lost in transition from timer to alias.
Posted By: learn3r Re: not working - 10/02/07 01:30 AM
Code:
on *:start:{
  if !$hget(BadWords) { .hmake BadWords 10 }
  if $exists(BadWords.hsh) { .hload BadWords BadWords.hsh }
}
on *:exit:{
  .hsave -o BadWords BadWords.hsh
}
on *:disconnect:{
  .hsave -o BadWords BadWords.hsh
}

menu menubar {
  -
  Private Offensive Message
  .Turn $iif($hget(BadWords,0),Off,On) : .hadd -m BadWords 0 $iif($hget(BadWords,0),$false,$true)
  .-
  .Add a word : .hadd -m BadWords $$?="Bad Word to be added" $true
  .-
  .Remove a word : .hdel BadWords $$?="Bad Word to be removed"
  .-
  .List Spam Words : .bad_words_list
  .-
}
alias -l bad_words_list {
  var %a = 1, %b = $hget(BadWords,0).item
  unset %badwords
  while %a <= %b {
    set %badwords $addtok(%badwords,$hget(BadWords,%a).item,32)
    if ($calc($numtok(%badwords,32) + $len(%badwords)) > 900) {
      echo -a $replace(%badwords,$chr(32),$+($chr(44),$chr(32)))
      unset %badwords
    }
    inc %a
  }
  if %badwords {
    echo -a $replace(%badwords,$chr(32),$+($chr(44),$chr(32)))
    unset %badwords
  }
}
on *:open:?:{
  if ($ulevel != op) && ($hget(BadWords,0)) {
    var %cnt = 1
    while (%cnt <= $hget(BadWords,0).item) {
      if ($hget(BadWords,%cnt).item isin $1-) {
        close -m $nick
        .timer. $+ $nick 1 1 spamdetect
        halt
      }
      inc %cnt
    }
  }
}
on ^*:notice:*:?: {
  var %oknames = ChanServ NickServ MemoServ
  if ($nick !isin %oknames) && ($hget(BadWords,0)) {
    var %cnt = 1
    while (%cnt <= $hget(BadWords,0).item) {
      if ($hget(BadWords,%cnt).item isin $1-) {
        .timer. $+ $nick 1 1 spamdetect
        halt
      }
      inc %cnt
    }
  }
}
alias spamdetect {
  var %i = 1
  if $comchan($nick,0) {
    while $comchan($nick,%i) {
      var %c = $v1
      if $me isop %c && $nick isreg %c { ban -ku600 %c $nick 2  14Private Offensive Language  }
      inc %i
    }
  }
}
Posted By: Scripto Re: not working - 10/02/07 05:39 AM
"$nick" has to be "$1" in the spamdetect alias... all the way through it. Otherwise it will not identify. The information in "$nick" is lost in the transition from timer to alias.

The isreg identifier wont moderate voiced users. He said he wanted only op exempt and isreg would do that, however, it would not include voiced users on the channel. It would result in the same length of that line to catch voices as well, which is why i submitted it that way.
Posted By: learn3r Re: not working - 11/02/07 10:15 AM
Code:
"$nick" has to be "$1" 


did you tried it and didn't worked?
Posted By: Scripto Re: not working - 11/02/07 05:05 PM


No, I did not test it, identifiers have always been formatted in that manner. It will not work as $nick.

$nick will not retain its value through the transition of time into the .timer's command when set up like this. It will retain it within the original script, but once you use a timer for a custom alias like this, the value of "$nick" is lost and becomes "$1" to the custom alias. Once that timer is set... the value of $1 is filled to that specific timer alias command, until that timer is either performed, or reset, or shut off.

In other words, (I'll see if i can explain it a little better) the value of $nick is filled when an event occurs. (join, notice, part.. etc. etc) While commands are being performed under that event, directly in that script, $nick will have whatever value it was filled with. However, when you leave the event, and go onto an alias with a timer (which in this case is 'spamdetect'...and it had to be a timer, to break out of the while loop, because spamdetect is a second loop, two 'while' loops cant operate at the same time)

mIRC has no idea what $nick youre talking about... it must drop it, in case other events occur.

$nick only holds 1 value within mIRC at a single time. So for instance, if I had said .timer 1 25 spamdetect $nick... And another event occured like a join or a part or a quit, that needed to re-fill $nick with information, then spamdetect would be kicking the newly filled information of $nick. That is why mIRC is set up this way. It stops 'lines' from being crossed. It would have to retain the value of $nick until that timer went off twenty-five full seconds later, It doesnt keep track of it as $nick, because the information was identified as $1, to the alias to free up the $nick identifier.

Try it out, write a short alias that does something simple like echo something....

Code:

on ^*:JOIN:#:{
   echo -a here is the event value of nick ~~> $nick 
  .timer.testnick 1 5 nickinfo $nick
}
alias nickinfo { 
  echo -a here is the info of nick ~~> $nick 
  echo -a here is the info of string 1 ~~~> $1 
}

 


nickinfo will retain whatever $1 is, and/or $2 or $3... etc.

identifiers work this way, try it with $chan and $nick both.

Code:
 
on ^*:JOIN:#:{
   echo -a here is the event value of nick and chan ~~> $nick joined $chan
  .timer.testnick 1 5 nickinfo $nick $chan
}
alias nickinfo { 
  echo -a here is the info of nick and channel ~~> $nick joined $chan
  echo -a here is the info of string 1 and string 2~~~> $1 joined $2
}



Posted By: learn3r Re: not working - 11/02/07 06:51 PM
Code:
.timer.testnick 1 5 nickinfo $nick



i didn't use
spamdetect $nick
spamdetect only and it's working
Posted By: Scripto Re: not working - 12/02/07 04:28 PM
I just tested this, using only an alias with no identifier behind it, and the same result occurs, the information is lost. It does not work. $nick must be $1 or the parameter is empty.

Try the two examples I posted. $nick returns $null after the timer, and $1 returns what was in $nick. $nick will not be re-evaluated in the format I explained smile

$1 is referred to as the parameter string of an alias.

type /help aliases
Posted By: Garou Re: not working - 12/02/07 07:02 PM
Thx.
© mIRC Discussion Forums