|
Joined: Nov 2006
Posts: 143
Vogon poet
|
OP
Vogon poet
Joined: Nov 2006
Posts: 143 |
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 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
|
|
|
|
Joined: Jan 2004
Posts: 2,127
Hoopy frood
|
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".
|
|
|
|
Joined: Nov 2006
Posts: 143
Vogon poet
|
OP
Vogon poet
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 and how can i do !bwlist ? !bwdel - if not on txt reply as not on list alrey
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
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
Vogon poet
|
OP
Vogon poet
Joined: Nov 2006
Posts: 143 |
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
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
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. 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
Vogon poet
|
OP
Vogon poet
Joined: Nov 2006
Posts: 143 |
Thank you so much RusselB 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
|
|
|
|
Joined: Nov 2006
Posts: 143
Vogon poet
|
OP
Vogon poet
Joined: Nov 2006
Posts: 143 |
ok after work on it a bit it seems works btw thnxx
|
|
|
|
Joined: Nov 2006
Posts: 143
Vogon poet
|
OP
Vogon poet
Joined: Nov 2006
Posts: 143 |
* /hdel: insufficient parameters (line 34, .hdel Badwords $hfind(Badwords,$($+($,%a),2),1).data whats wrong with that line
|
|
|
|
Joined: Jul 2006
Posts: 4,153
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,153 |
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 : 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
|
|
|
|
Joined: Feb 2006
Posts: 181
Vogon poet
|
Vogon poet
Joined: Feb 2006
Posts: 181 |
/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?
|
|
|
|
Joined: Jul 2006
Posts: 4,153
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,153 |
Yes, $hfind only return an item, never a data : $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
|
|
|
|
Joined: Feb 2006
Posts: 181
Vogon poet
|
Vogon poet
Joined: Feb 2006
Posts: 181 |
$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.
|
|
|
|
Joined: Nov 2006
Posts: 143
Vogon poet
|
OP
Vogon poet
Joined: Nov 2006
Posts: 143 |
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
|
|
|
|
Joined: Feb 2006
Posts: 181
Vogon poet
|
Vogon poet
Joined: Feb 2006
Posts: 181 |
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
}
|
|
|
|
Joined: Jul 2006
Posts: 4,153
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,153 |
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 : 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
|
|
|
|
Joined: Feb 2006
Posts: 181
Vogon poet
|
Vogon poet
Joined: Feb 2006
Posts: 181 |
I did edited the code. Why use $gettok ?? My code should work
|
|
|
|
Joined: Nov 2006
Posts: 143
Vogon poet
|
OP
Vogon poet
Joined: Nov 2006
Posts: 143 |
okies ur works now what abt ban the ppl using added words ? i asked it already 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
|
|
|
|
Joined: Jul 2006
Posts: 4,153
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,153 |
Imo, $gettok($1-,%a,32) is more cleaner than $($+($,%a),2), and it might be faster
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Feb 2006
Posts: 181
Vogon poet
|
Vogon poet
Joined: Feb 2006
Posts: 181 |
... this code bans if words add aa aaaa aa but hash adding as aaa/aa/aa/ so not works anything to do I do not understand ... Please clarify the exact problem... @ Wims 1) cleaner? Yes 2) faster ? Maybe
|
|
|
|
|