mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
#203506 18/08/08 01:40 AM
Joined: Nov 2006
Posts: 143
X
xyzzy Offline OP
Vogon poet
OP Offline
Vogon poet
X
Joined: Nov 2006
Posts: 143
Code:
on @*:text:*:#:{if $nick isreg # { var %k = 1,%kk = $lines(badwords.txt) | while %k <= %kk { if $+(*,$read(badwords.txt,%k),*) iswm $1- { ban -ku600 $chan $nick 2 Bad word detected out out > $read(badwords.txt,%k) | return $true } | inc %k } | return $false }

im using that code for badwords on channel the words on txt list how can i do same thing on hash tables confused
Code:
on *:text:*:#:{
  if !bwadd* iswm $1- {
    if $read(write badwords.txt,w,$2-) {
      .msg $chan  $2- already on the list
    }
    else {
      .write badwords.txt $2-
      .msg $chan $2- added on the list
    }
  }
} 

i try to do !bwadd fukeh so the script will add the fukeh word in the badwords.txt but its not work can fix it ?
also if make first code for hash table how can use !bwadd confused

xyzzy #203507 18/08/08 01:57 AM
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
well, for one thing, you are attempting to read from a file named "write badwords.txt", but then when you didn't find the offensive language in that filename, then you write it to "badwords.txt".

maroon #203508 18/08/08 03:21 AM
Joined: Nov 2006
Posts: 143
X
xyzzy Offline OP
Vogon poet
OP Offline
Vogon poet
X
Joined: Nov 2006
Posts: 143
lol yeh i got it now
was sleepy when post that msg
if $read(write badwords.txt,w,$2-) O-o lol
if $read(badwords.txt,w,$2-)
any idea for others things i asked confused
and how can i do !bwlist ?confused
!bwdel - if not on txt reply as not on list alrey crazy


xyzzy #203514 18/08/08 08:28 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
No offense to your coding, but that first ON TEXT script would be a lot easier to read using multiple lines.

For a hash table, you have to start with making the table, using /hmake

Then you need to add or load the information into the hash table.
To add it, you use /hadd
To load it (which I would recommend using your current badwords.txt file) you use /hload

There are a lot of other command and identifiers that are used with hash tables. I suggest you read the help file /help hash tables to get some understanding as to what commands and identifiers do what.

Joined: Nov 2006
Posts: 143
X
xyzzy Offline OP
Vogon poet
OP Offline
Vogon poet
X
Joined: Nov 2006
Posts: 143
Code:
on @*:text:*:#:{
  if ($1 == !bwadd) { if $read(badwords.txt,w,$2-) { 
    msg $chan  $2- already on the list } 
    else { write badwords.txt $2- | msg $chan $2- added on the list } 
  }
}

need bwdell n bwlist any idea confused

xyzzy #203592 21/08/08 02:41 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
This will use your current text file for badwords hash table. Please note that your current text file must contain one bad word per line, or this code will not work properly

I have included !bwadd, !bwdel and !bwlist as well as taking into account if someone tries to use the commands with out all of the required parameters, as well as if they try to send the command using colour, bold, underline, reverse text, etc.
Code:
on *:start:{
  if !$hget(Badwords) { .hmake Badwords 100 }
  if $exists(Badwords.txt) {
    .hload -n Badwords Badwords.txt
  }
}
on *:text:*:#:{
  var %bw.code = $strip($1-)
  %bw.code = $replace(%bw.code,$chr(44),$chr(32))
  tokenize 32 %bw.code
  if $1 == !bwadd {
    if !$2 {
      .notice $nick Usage: !bwadd <list of bad words to be added, space or comma separated)    
    }
    else {
      tokenize 32 $2-
      var %a = $0
      while %a {
        if !$hfind(Badwords,$($+($,%a),2),1).data {
          .hadd -m Badwords $calc($hget(Badwords,0).item + 1) $($+($,%a),2)
        }
        dec %a
      }
      .hsave -n Badwords Badwords.txt
    }
  }
  elseif $1 == !bwdel {
    if !$2 {
      .notice $nick Usage: !bwdel <list of bad words to be deleted, space or comma separated)    
    }
    else {
      tokenize 32 $2-
      var %a = $0
      while %a {
        .hdel Badwords $hfind(Badwords,$($+($,%a),2),1).data
      }
      dec %a
    }
    .hsave -n Badwords Badwords.txt
  }
  elseif $1 == !bwlist {
    .hsave -n Badwords Badwords.txt
    .msg $nick Warning the Badwords file currently has $hget(Badwords,0).item entries
    .play $nick Badwords.txt
  }
}

Joined: Nov 2006
Posts: 143
X
xyzzy Offline OP
Vogon poet
OP Offline
Vogon poet
X
Joined: Nov 2006
Posts: 143
Thank you so much RusselB
Code:
on @*:text:*:#:{if $nick isreg # { var %k = 1,%kk = $lines(badwords.txt) | while %k <= %kk { if $+(*,$read(badwords.txt,%k),*) iswm $1- { ban -ku600 $chan $nick 2 Bad word detected out out > $read(badwords.txt,%k) | return $true } | inc %k } | return $false }

how can i use ur code if this not change to hash confused

xyzzy #203700 24/08/08 08:04 PM
Joined: Nov 2006
Posts: 143
X
xyzzy Offline OP
Vogon poet
OP Offline
Vogon poet
X
Joined: Nov 2006
Posts: 143
ok after work on it a bit it seems works btw thnxx smile

xyzzy #203702 24/08/08 09:00 PM
Joined: Nov 2006
Posts: 143
X
xyzzy Offline OP
Vogon poet
OP Offline
Vogon poet
X
Joined: Nov 2006
Posts: 143
* /hdel: insufficient parameters (line 34,
.hdel Badwords $hfind(Badwords,$($+($,%a),2),1).data
whats wrong with that line confused

xyzzy #203703 24/08/08 09:26 PM
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
There's nothing wrong, the $hfind value is $null

Edit : it might be because you've specified a badword that don't exists just check the value, here the else part :

Code:
else {
tokenize 32 $2-
var %a = $0
while %a {
if ($hfind(Badwords,$($+($,%a),2),1).data) .hdel Badwords $v1
;else var %er = %er $v1
dec %a
 }
}
I've put an else in case you want to retrieved the words that aren't deleted

Last edited by Wims; 24/08/08 09:34 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
xyzzy #203704 24/08/08 09:33 PM
Joined: Feb 2006
Posts: 181
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2006
Posts: 181
Originally Posted By: mIRC Help
/hdel -sw <name> <item>

Deletes an item from a hash table.

The -w switch indicates that item is a wildcard, all matching items are freed.

Deletes an item from a hash table.
Is $hfind(Badwords,$($+($,%a),2),1).data the ITEM?

Crinul #203705 24/08/08 09:35 PM
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Yes, $hfind only return an item, never a data :

Originally Posted By: /help $hfind
$hfind(name/N, text, N, M)
Searches table for the Nth item name which matches text. Returns item name.



Last edited by Wims; 24/08/08 09:35 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #203706 24/08/08 09:40 PM
Joined: Feb 2006
Posts: 181
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2006
Posts: 181
Originally Posted By: mIRC Help

$hfind(name/N, text, N, M)
Searches table for the Nth item name which matches text. Returns item name.

Properties: data

If you specify the .data property, searches for a matching data value.


Edit:

@ xyzzy
try using $hfind(Badwords,$($+($,%a),2),1,w).data
w text is wildcard text

Last edited by Crinul; 24/08/08 09:47 PM.
Crinul #203707 24/08/08 09:45 PM
Joined: Nov 2006
Posts: 143
X
xyzzy Offline OP
Vogon poet
OP Offline
Vogon poet
X
Joined: Nov 2006
Posts: 143
Code:
  elseif $1 == !bwdel {
    if !$2 {
      .msg $chan Usage: !bwdel <list of bad words to be deleted, space or comma separated)    
    }
    else {
      tokenize 32 $2-
      var %a = $0
      while %a {
      if ($hfind(Badwords,$($+($,%a),2),1).data) .hdel Badwords $v1 | msg $chan $1 deleted from bad word list }
      ;else var %er = %er $v1
      dec %a
    }
  }
  .hsave -n Badwords Badwords.txt
}

do u think is this working ?
check it pls smthng wrong it del abt million times n mirc not works anymore lol

xyzzy #203708 24/08/08 10:11 PM
Joined: Feb 2006
Posts: 181
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2006
Posts: 181
Code:
elseif $1 == !bwdel {
  if !$2 {
    .msg $chan Usage: !bwdel <list of bad words to be deleted, space or comma separated)    
  }
  else {
    tokenize 32 $2-
    var %a = $0
    while %a {
      if ($hfind(Badwords,$($+($,%a),2),1).data) { 
         msg $chan $($+($,%a),2) deleted from bad word list
        .hdel Badwords $v1
      }
      dec %a
    }
  }
  .hsave -n Badwords Badwords.txt
}

xyzzy #203709 24/08/08 10:14 PM
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Crinul, the .data only applie for the match part, it return the item name...

xyzzy, You're missing a { in the if part and you're using $1 instead of $v1 :

Code:
else {
tokenize 32 $2-
var %a = $0
while %a {
if ($hfind(Badwords,$($+($,%a),2),1).data) { .hdel Badwords $v1 | msg $chan $($+($,%a),2) deleted from bad word list }
;else var %er = %er $v1
dec %a
    }
  }
Should work

Edit : in Crinul's code, the value of $hget(Badwords,$v1).data is certainly $null since we just delete the item..., $($+($,%a),2) should be used, but a $gettok seems to be better imo.

Last edited by Wims; 24/08/08 10:18 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #203710 24/08/08 10:21 PM
Joined: Feb 2006
Posts: 181
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2006
Posts: 181
I did edited the code.
Why use $gettok ??
My code should work

Crinul #203713 24/08/08 11:04 PM
Joined: Nov 2006
Posts: 143
X
xyzzy Offline OP
Vogon poet
OP Offline
Vogon poet
X
Joined: Nov 2006
Posts: 143
okies ur works now
what abt ban the ppl using added words ?
i asked it already crazy
Code:
on @*:text:*:#:{if $nick isreg # { var %k = 1,%kk = $lines(badwords.txt) | while %k <= %kk { if $+(*,$read(badwords.txt,%k),*) iswm $1- { ban -ku600 $chan $nick 2 Bad word detected out out > $read(badwords.txt,%k) | return $true } | inc %k } | return $false }

this code bans if words add
aa
aaaa
aa
but hash adding as
aaa/aa/aa/
so not works anything to do confused

Crinul #203714 24/08/08 11:07 PM
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Imo, $gettok($1-,%a,32) is more cleaner than $($+($,%a),2), and it might be faster smile


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
xyzzy #203715 24/08/08 11:23 PM
Joined: Feb 2006
Posts: 181
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2006
Posts: 181
Originally Posted By: xyzzy

...

this code bans if words add
aa
aaaa
aa
but hash adding as
aaa/aa/aa/
so not works anything to do confused


I do not understand ...
Please clarify the exact problem...

@ Wims

1) cleaner?
Yes
2) faster ?
Maybe smile


Crinul #203716 24/08/08 11:26 PM
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Ah Ah, i've made some test, and $eval is really much faster wink


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Crinul #203720 24/08/08 11:47 PM
Joined: Nov 2006
Posts: 143
X
xyzzy Offline OP
Vogon poet
OP Offline
Vogon poet
X
Joined: Nov 2006
Posts: 143
!bwadd word
adding the words in badwords.txt
the code i gave bans if words added as
word1
word2
word3
but the command !bwadd words abreast
like word1|word2|word3
Code:
on @*:text:*:#:{if $nick isreg # { var %k = 1,%kk = $lines(badwords.txt) | while %k <= %kk { if $+(*,$read(badwords.txt,%k),*) iswm $1- { ban -ku600 $chan $nick 2 Bad word detected out out > $read(badwords.txt,%k) | return $true } | inc %k } | return $false }

so this not works if words added like this word1|word2|word3

Last edited by xyzzy; 24/08/08 11:47 PM.
Joined: Apr 2018
Posts: 24
T
Ameglian cow
Offline
Ameglian cow
T
Joined: Apr 2018
Posts: 24
Hello guys, any suggestion how to make this hash badword to give ban to hostmask of user when is match the badword,
and how to make the badword to be add like /bwadd /bwdel *azz* *azz azz* to match the word azzhole azz hole azz-hole azz`hole, like user say ffff i want to !bwadd *ff* or ff* or *ff

on *:start:{
if !$hget(Badwords) { .hmake Badwords 100 }
if $exists(Badwords.txt) {
.hload -n Badwords Badwords.txt
}
}
on *:text:*:#:{
var %bw.code = $strip($1-)
%bw.code = $replace(%bw.code,$chr(44),$chr(32))
tokenize 32 %bw.code
if $1 == !bwadd {
if !$2 {
.notice $nick Usage: !bwadd <list of bad words to be added, space or comma separated)
}
else {
tokenize 32 $2-
var %a = $0
while %a {
if !$hfind(Badwords,$($+($,%a),2),1).data {
.hadd -m Badwords $calc($hget(Badwords,0).item + 1) $($+($,%a),2)
}
dec %a
}
.hsave -n Badwords Badwords.txt
}
}
elseif $1 == !bwdel {
if !$2 {
.notice $nick Usage: !bwdel <list of bad words to be deleted, space or comma separated)
}
else {
tokenize 32 $2-
var %a = $0
while %a {
.hdel Badwords $hfind(Badwords,$($+($,%a),2),1).data
}
dec %a
}
.hsave -n Badwords Badwords.txt
}
elseif $1 == !bwlist {
.hsave -n Badwords Badwords.txt
.msg $nick Warning the Badwords file currently has $hget(Badwords,0).item entries
.play $nick Badwords.txt
}
}

Page 1 of 2 1 2

Link Copied to Clipboard