mIRC Home    About    Download    Register    News    Help

Print Thread
#266461 14/12/19 09:09 PM
Joined: Nov 2019
Posts: 32
A
An0o Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Nov 2019
Posts: 32
this code not active
when user changed nick to bad nick don't give him a band


alias check_badnick {
var %f = badnicks.txt
var %t = $lines(%f)
if (!%t) { return }

var %i = 1
while (%i <= %t) {
var %r = $read(%f,n,%i)
if (%r iswm $1) { return 1 }
inc %i
}

return 0
}


ON !*:JOIN:#: {
if ($check_badnick($nick)) {
msg # 3 $nick 12 Your nick is inappropriate. Please change it in 30 sec by typing 4/nick newnick
timer 1 30 ban # -ku600 $nick
}
}

ON !*:NICK: {
if ($check_badnick($newnick)) {
var %t = $comchan($newnick,0)
var %i = 1
while (%i <= %t) {
var %chan = $comchan($newnick,%i)
msg %chan 3 $newnick 12 Your nick is inappropriate. Please change it in 30 sec by typing 4/nick newnick
timer 1 30 ban %chan -ku600 $newnick
inc %i
}
}
}

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
First, it helps to create your post by using the hashtag symbol to add the 'code' tag to your post, so the code appears formatting like it does in the scripts editor, so it's easier to read. You can click on 'preview' to see if your post looks right. Sometimes you need to add some extra lines in front of the closing code-tag to make the last line easier to see. If using the code tag, your code can look like:

Code
alias check_badnick {
  var %f = badnicks.txt
  var %t = $lines(%f)
  if (!%t) { return }

  var %i = 1
  while (%i <= %t) {
    var %r = $read(%f,n,%i)
    if (%r iswm $1) { return 1 }
    inc %i
  }

  return 0
}


When you have trouble with code not working correctly, one thing that's a big help to find the problem is to insert debug messages into the script.

echo -s debug $scriptline $nofile($script) event= $event nick= $nick $ $+ 1- $qt($1-) message and/or variablles and or identifiers go here

This echoes a message to your status window which lets you see that it reached a specific line number of a specific script. That helps located the problem, and also helps find it when it's time to remove them. If you see the message showing line 4 but not line 10, and it should be showing both, this helps you identify the location of the problem, though the problem can sometimes be caused by an earlier line not doing its job correctly.

It's hard to tell where your problem is, as the code looks fine. Try manually testing your check_badnick alias to see if it works correctly.

//echo -a $check_badnick(badword_goes_here)

If this returns 0 for a bad word, or 1 for a good word, then you need to fix that problem first.

It's also a good idea to check if you're OP in the channel where the nick is changing. I think the @ event prefix should work to avoid triggering the ON NICK event if the person changing nick only shares a nick where you're not an op. But in addition, something like this makes sure you don't send empty threats to someone in a channel where you're not an OP:

Code
var %chan = $comchan($newnick,%i) | if (!$nick(%chan,$me,@)) { inc %i | continue }


Joined: Nov 2019
Posts: 32
A
An0o Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Nov 2019
Posts: 32
Ok thanks alot

Joined: Nov 2019
Posts: 32
A
An0o Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Nov 2019
Posts: 32
this not work
Code
 timer 1 30 ban %chan -ku600 $newnick 


this work

Code
      ban %chan $address($newnick,2) -ku600 $newnick 


thnxxxxx maroooooon

Joined: Aug 2015
Posts: 70
Babel fish
Offline
Babel fish
Joined: Aug 2015
Posts: 70
I think you want:
ban -ku600 <chan> <nick> <N> <reason>


mIRC Scripts IRC Network: irc://irc.mircscripts.info/chat
Joined: Nov 2019
Posts: 32
A
An0o Offline OP
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Nov 2019
Posts: 32
I want something else
When nick changes to badnick from the bads. Txt , it is band out channel
But if the badnick is in several nicks, it does not banded it
Example : jac is badnick in bads.Txt
tom >> jac(newnick in bads.txt) bandnick
Tom >> mac_jac not bandnick
I want to read the badnick when changing it, even if it is within the line and next to it other words and band it

Example: jac is badnick in bads.Txt
tom >> kamel_jacmohamed band nick

Code
   on *:NICK:{
  if $badnick($newnick) {
    var %e = 1, %u = $v1
    while $comchan($newnick,%e) {
      if ($me isop $v1) || ($me ishop $v1) && (%korukanal != $v2) && ($newnick isreg $v2) {
        mode $v2 +b %u
        kick $v2 $newnick 2 Nick'iniz KanaL Seviyesine Uygun Değildir. 2ßy 5 $me
 
      }
      inc %e
    }
  }
}
alias badnick {
  var %e = 1
  while $read(bads.txt,%e) {
    if $v1 iswm $1 {
      return $v1
    }
    inc %e
  } 

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
You are using
if $v1 iswm $1
where $v1 is the line in the text file and $1 is the nick being fed to the alias.
if you want to match where
word
appears anywhere within $1, then the text file should contain *word*
depending on the language being used, you may be matching too many things. Jack and Jackson are common english first and last names which would match jac

If you become experienced with regex, you can do similar string-within-string matches like
//echo -a $regex(jackson, (ab|cd|on) ) matched $regml(1)
which is equivalent to
if ((ab isin jackson) || (cd isin jackson) || (on isin jackson))
or even have more complicated matches where something matches only when the word appears next to specific text, or only when it doesn't appear next to other text.

Also reminder of what I mentioned about using the 'n' switch with $read except when you DO want to match identifiers, as it saves work trying to check for matches that you don't care about. If you place the string
$nick
into that text file, it will match everyone


Link Copied to Clipboard