mIRC Home    About    Download    Register    News    Help

Print Thread
#174117 02/04/07 02:07 PM
Joined: Aug 2006
Posts: 469
G
Garou Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Aug 2006
Posts: 469
Why its not kicking?

raw 301:*:{
if (%away != off) && ($nick !isop #chat) {
var %a = 1, %b = $hget(bad.away,0).item
while %a <= %b {
var %bad.away = $hget(bad.away,%a).item
if $istok($6-,%bad.away,32) { ban -ku600 #chat $2 2 14Offensive Away Msg }
inc %a
}
return $regsubex($1-,/\b( $+ %away $+ )\b/gi,$str(*,$len(\t)))
}
halt
}
on *:start:{
if !$hget(bad.away) { .hmake bad.away 10 }
if $exists(bad.away.hsh) { .hload bad.away bad.away.hsh }
}
on *:exit:{
.hsave -o bad.away bad.away.hsh
}
on *:disconnect:{
.hsave -o bad.away bad.away.hsh
}
alias bad.away {
if !$1 { .notice $nick No word specified }
elseif $hfind(bad.away,$1,0) {
.hdel bad.away $1
}
else .hadd -m bad.away $1 $1
}

Garou #174130 02/04/07 06:23 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Try changing
Code:
var %bad.away = $hget(bad.away,%a).item
to
Code:
var %bad.away = $hget(bad.away,%a).data


Other than that possibility, I don't see anything wrong with your code.


P.S.: Please use the Code Tags (button looks like #) around your code in the future. It makes it easier to read.

RusselB #174132 02/04/07 06:50 PM
Joined: Aug 2006
Posts: 469
G
Garou Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Aug 2006
Posts: 469
Weird still wont work. Is it possible to get the away bad words from var instead of hash file? Emp: var %bad.away = $chr(32) $+ ,bad1,bad2,bad3,bad4,

Garou #174138 02/04/07 10:30 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
It's possible, but the number of badwords is going to be a lot more limited than using a hashtable, since variables have a limit of about 950 characters including the variable name, the spaces on either side of the = sign and the = sign.

Before we get into making changes like that, which in my opinion for something like this, would be going backwards, can you post an example of an entry from the hash table.

I see that you load/store the hash table from/to a file called bad.away.hsh
That file, if brought up in a word processor (eg: notepad), will have the item name on one line, then the data for the item on the next.
If you would post a small example (2 or 3 entries should be sufficient), then I'll review that information to see if it might be organized better, or if maybe the organization is your problem.


Going through your code more carefully, I think I found a better way of doing this. Here's the re-write I came up with
P.S.: This has been tested to a limited extent.
Code:
raw 301:*:{
  if (%away != off) && ($2 !isop #chat) {
    var %a = 1, %b = $numtok($3-,32)
    while %a <= %b {
      if $hget(bad.away,$gettok($3-,%b,32)) {
        ban -ku600 #chat $2 2 14Offensive Away Msg
        %a = %b
      }
      inc %a
    }
    return $regsubex($1-,/\b( $+ %away $+ )\b/gi,$str(*,$len(\t)))
  }
  haltdef
}
on *:start:{
  if !$hget(bad.away) { .hmake bad.away 10 }
  if $exists(bad.away.hsh) { .hload bad.away bad.away.hsh }
}
on *:exit:{
  .hsave -o bad.away bad.away.hsh
}
on *:disconnect:{
  .hsave -o bad.away bad.away.hsh
}
alias bad.away {
  if !$1 { .notice $nick No word specified }
  else {    .hadd -m bad.away $1 $iif($hget(bad.away,$1),$false,$true)  }
} 

Last edited by RusselB; 02/04/07 11:28 PM.
RusselB #174142 03/04/07 12:28 AM
Joined: Aug 2006
Posts: 469
G
Garou Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Aug 2006
Posts: 469
ok its store like this in notepad: blowjob suck asshole lesbi suckmydick bitch


Garou #174143 03/04/07 12:38 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Based on the code you provided, there is one item per entry in the hash table, with each item having a data entry that matches the item.
So //echo -a $hget(bad.away,blowjob)
returns blowjob

Using the code I provided in my last post, it will go through all of the words in the away message, as returned by raw 301, and see if that word is in the hash table.

RusselB #174145 03/04/07 12:59 AM
Joined: Aug 2006
Posts: 469
G
Garou Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Aug 2006
Posts: 469
THx RusselB its working now, it was not stored properly.

raw 301:*:{
if (%away != off) && ($2 !isop #reg) {
var %a = 1, %b = $numtok($3-,32)
while %a <= %b {
if $hget(bad.away,$gettok($3-,%b,32)) {
ban -ku600 #reg $2 2 14Offensive Away Msg
%a = %b
}
inc %a
}
return $regsubex($1-,/\b( $+ %away $+ )\b/gi,$str(*,$len(\t)))
}
haltdef
}
on *:start:{
if !$hget(bad.away) { .hmake bad.away 10 }
if $exists(bad.away.hsh) { .hload bad.away bad.away.hsh }
}
on *:exit:{
.hsave -o bad.away bad.away.hsh
}
on *:disconnect:{
.hsave -o bad.away bad.away.hsh
}

menu menubar {
-
Add Bad Away Msg
.Add Bad Away Msg : bad.away $?= "Add bad away" | echo $asctime([HH:nn]) * 4Bad Away Msg Added.
.-
.Remove Bad Away Msg : bad.away $?= "Remove bad away" | echo $asctime([HH:nn]) * 4Bad Away Msg Removed.
.-
.View Bad Away Msg List: run bad.away.hsh
.-
.Clear Bad Away Msg List: .hfree bad.away | $iif(exits(bad.away.hsh),remove bad.away.hsh)
}
alias bad.away {
if !$1 { .notice $nick No word specified }
else { .hadd -m bad.away $1 $iif($hget(bad.away,$1),$false,$true) }
}

Last edited by Garou; 03/04/07 01:00 AM.
Garou #174148 03/04/07 01:19 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Garou: When posting code please use the Code Tags (button looks like #). They make things much easier to read.

Also slight correction to a menu item.
Currently you have
Code:
Clear Bad Away Msg List: .hfree bad.away | $iif(exits(bad.away.hsh),remove bad.away.hsh)

Change it to
Code:
Clear Bad Away Msg List: .hfree bad.away | $iif($exists(bad.away.hsh),remove bad.away.hsh)

RusselB #174149 03/04/07 01:25 AM
Joined: Aug 2006
Posts: 469
G
Garou Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Aug 2006
Posts: 469
Ok thx.

Last edited by Garou; 03/04/07 01:31 AM.

Link Copied to Clipboard