mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2013
Posts: 140
R
raycomp Offline OP
Vogon poet
OP Offline
Vogon poet
R
Joined: May 2013
Posts: 140
I came across this script Author unknown but cant get it to work. Using mIRC 7.36 in remotes as a channel bot. Please advice

Quote:
;Swearwords============================

on @*:TEXT:*:#: {
; The list of swears. Words should be separated by commas
var %swears = fark,shoot,mittens
; Number of times to warn before banning
var %warns = 2
var %x = $numtok(%swears,44)
tokenize 32 $strip($1-)
while (%x) && ($nick isreg $chan) {
if ($istok($1-,$gettok(%swears,%x,44),32)) {
inc $+(%,swear.,$wildsite)
var %n = $($+(%,swear.,$wildsite),2)
if (%n <= %warns) {
notice $nick $nick $+ , this is your $ord(%n) warning for using forbidden language in this channel. $iif(%n = %warns,Breaking the channel rules one more time will result in ban.)
}
elseif (%n > %warns) {
ban -ku300 $chan $nick 2 Using forbidden language
unset $+(%,swear.,$wildsite)
}
}
dec %x
}
}
; Reset all of the swear data on mIRC start
on *:START: { unset %swear.* }


Not sure about the while (%x) && ($nick isreg $chan) {
changed it to while (%x) {
But still not working when using one of the words in channel

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
in the future, it helps to use the code icon under the # symbol. when you use quote, the code is wrapped and formatted badly without the indents, as if there's a hard line-ending in the middle of the notice.

How are you testing this? It's working fine in 7.55, but i can't imagine it using anything that wouldn't also work in 7.3-whatever. If you're trying to see how it reacts to things yourself types, be aware that TEXT does not see anything yourself types into channel. Also, the @ prefix means that it doesn't do anything if yourself is not an @op. The 'isreg' means it was only applying the rules to someone who is a 'regular' nick without op/voice. Also, if you have another TEXT event above it in that same scriptfile matching :*: then it intercepts everything instead.

You can add a few echoes to the status window containing $scriptline so you can see whether the event is being seen, and if so how far down it sees until it stops echoing them.

Joined: May 2013
Posts: 140
R
raycomp Offline OP
Vogon poet
OP Offline
Vogon poet
R
Joined: May 2013
Posts: 140
Thank you how do i use the echo please?

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
you can add an echo within a script to let you know if that line is even being reached. You can also include in the echo the values of different %variables or $1 or $nick or $chan to identify what those are. By leaving a trail of breadcrumbs, you can see where something went wrong. I usually like to include the scriptname and the line number in the echo, so if i forget to remove it, the echo message in status window tells me where to find it, rather than hunting through all my scripts for it. Something simple like:

Code:
echo -s debug: $nopath($script) $scriptline nick = $nick (1) $1

Joined: May 2013
Posts: 140
R
raycomp Offline OP
Vogon poet
OP Offline
Vogon poet
R
Joined: May 2013
Posts: 140
Thank you all got it fixed. Is there a way to rather add badwords in a text file to read from there? if so please if you don't mind alter the script I have tried but are too inexperienced

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Before updating this script, you need to find out if it's working well for you, rather than wasting your time and our time making a dead-end script. For example, your use of $istok() means that it only matches complete words, and is defeated by anything touching the badword, including punctuation like commas, or periods.

Also, the way you're doing this is looping through the variables N times when you have N swearwords, so this can bog down when you add more words. It would be even slower if you did this in a way which requires accessing a disk file to scan it for bad words.

Rather than using $read to check a swearwords.txt for a match, you can add bad words to a hashtable, then use $hfind to make a single 'pass' against $strip($1-) looking for a match. You can create a hashtable where the badwords are the item names, or are the itemnames themselves. You would also need to choose whether to add wildcard or regex patterns to the hashtable, because $hfind() matches them differently. i.e. * and . mean different things in wildcards than in regex.

If you haven't already done so, check out https://www.mirc.com/help.html where more detailed syntax and examples have been added to some - but not all - identifiers and commands.

Joined: May 2013
Posts: 140
R
raycomp Offline OP
Vogon poet
OP Offline
Vogon poet
R
Joined: May 2013
Posts: 140
Thanks all

Joined: Mar 2019
Posts: 8
R
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
R
Joined: Mar 2019
Posts: 8
I combined an old badword script i had, with yours to make one with .txt file

You need to create the "badwords.txt" on the mirc folder, you can change the location on the code. The words have to be on a list, 1 per line, you can use "*" in case the word have variations, exemple *motherfu*, it'll trigger anytime someone say something with "motherfu" on it, not just the complete word.

Code:
on *:text:*:#:{
  if ($me isop #) && ($nick isreg $chan) {
    var %warns = 2
    var %y = 1
    while ($read(badwords.txt,%y) != $null) {
      if ($read(badwords.txt,%y) iswm $strip($1-)) {
        inc $+(%,swear.,$wildsite)
        var %n = $($+(%,swear.,$wildsite),2)
        if (%n <= %warns) {
          notice $nick $nick $+ , this is your $ord(%n) warning for using forbidden language in this channel. $iif(%n = %warns,Breaking the channel rules one more time will result in ban.)
        }
        elseif (%n > %warns) {
          ban -ku300 $chan $nick 2 Using forbidden language
          unset $+(%,swear.,$wildsite)
        }
      }
      inc %y
    } 
  }
  halt
}

on *:START: { unset %swear.* }


Enjoy smile


Link Copied to Clipboard