mIRC Home    About    Download    Register    News    Help

Print Thread
#163420 29/10/06 06:40 PM
Joined: Feb 2005
Posts: 344
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Feb 2005
Posts: 344
The words i gave up era not being filtered.
What is wrong?
Code:
 alias vloek {
  var %r = $lines(censuur.txt)
  var %i = 1
  while (%i <= %r ) {
    did -a woordfilter 4 $read(censuur.txt,%i)
    inc %i
  }
}

dialog woordfilter {
  title Woordfilter
  size -1 -1 260 150
  option dbu
  edit "", 1, 76 12 50 10, autohs
  button toevoegen, 2, 76 24 37 12
  button verwijderen, 3, 76 50 37 12
  list 4, 130 12 64 116, sort size extsel
}

on *:dialog:woordfilter:*:*:{
  if ($devent == init) {
    mdx.load
    mdx SetMircVersion $version
    mdx SetControlMDX 4 listview rowselect showsel single sortascending labeltip report > $views
    .did -i woordfilter 4 1 headerdims 112:1 
    .did -i woordfilter 4 1 headertext woordenlijst
    vloek
  }
  if ($devent == sclick) {
    if ($did == 2) { 
      addcensuur
      did -r woordfilter 1
      did -r woordfilter 4
      vloek
    }
    if ($did == 3) { 
      if ($Did(woordfilter, 4).sel) {
        .var %a = $Did(woordfilter, 4, 0).sel
        While (%a) {
          hdel -w censuur $Gettok($Did(woordfilter, 4, %a).seltext, 6, 32)
          did -d woordfilter 4 $Did(woordfilter, 4, %a).sel
          delcensuur 
          did -r woordfilter 4
          vloek 
          dec %a   
        }   
      }
    }
  }
}

alias mdx.load { mdx SetMircVersion $version | mdx MarkDialog $dname }
alias mdx dll $scriptdirdll\mdx.dll $1-
alias views return $scriptdirdll\views.mdx $1- 


;$1- is de tekst die gecensureerd moet worden
alias censuur {
  var %text = $1-
  var %i = $hget(censuur,0).data
  while ( %i ) {
    var %word = $hget(censuur,%i).data
    var %text = $iif($regsub($strip(%text),/\b $+ %word $+ \b/ig,$str(*,$len(%word)),%new),%new,%text)
    dec %i
  }
  return %text
}

;voegt een woord toe aan censuur
alias addcensuur {
  hadd -m censuur $did(woordfilter,1).text
  savecensuur
}

;verwijdert een woord uit de censuur lijst 
;(gebruik een * voor meerdere soortgelijke woorden te verwijderen)
alias delcensuur {
  .hdel -w censuur $did(woordfilter,4).sel
  savecensuur
}

;bewaard de censuurlijst
alias savecensuur { .hsave censuur censuur.txt }

;censuurlijst inladen
alias loadcensuur { 
  .hmake censuur 100
  if ( $exists(censuur.txt) ) { .hload censuur censuur.txt }
}

on *:start: { loadcensuur }
on ^*:action:*:*: { echo -i2mbfl # 6«06 $+ $timestamp $+ 6» $nick $censuur($1-) | haltdef }
on ^*:action:*:?: { echo $nick 6«06 $+ $timestamp $+ 6» $nick $censuur($1-) | haltdef }

on ^*:TEXT:*:#: { 
  if ($nick isop $chan) {
    echo -i2mbfl # 4«01 $+ $timestamp $+ 4»«  $nick 4» $censuur($1-) | haltdef
  }
  elseif ($nick ishop $chan) {
    echo -i2mbfl # 7«01 $+ $timestamp $+ 7»«  $nick 7» $censuur($1-) | haltdef
  }
  elseif ($nick isvoice $chan) {
    echo -i2mbfl # 3«01 $+ $timestamp $+ 3»«  $nick 3» $censuur($1-) | haltdef
  }
  else {
    echo -i2mbfl # 14«01 $+ $timestamp $+ 14»«  $nick 14» $censuur($1-) | haltdef
  }
} 


Greetzz

#163421 30/10/06 09:41 AM
Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
I am not certain if its due to this line but
var %text = $iif($regsub($strip(%text),/\b $+ %word $+ \b/ig,$str(*,$len(%word)),%new),%new,%text)
can be written as
var %text = $regsub(%text,/\b $+ %word $+ \b/igS,$str(*,$len(%word)),%text)

hadd -m censuur $did(woordfilter,1).text Looks off to me as well since the syntax is hadd -m censuur [item] $did(woordfilter,1).text
Seems like your missing [item]

Not saying its down to this but its what i noticed this early morning smile


$maybe
#163422 30/10/06 10:13 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
var %text = $regsub(%text,/\b $+ %word $+ \b/igS,$str(*,$len(%word)),%text)


That would do the regsub on %text resulting with %text updated, and then promptly replace the whole of %text with the number of matches as per the result/returned value of the $regsub

#163423 30/10/06 11:53 AM
Joined: Feb 2005
Posts: 344
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Feb 2005
Posts: 344
thanks for the responds.
the var %text is fine.
i found what was wrong.
here is what needed to be changed:
Code:
 if ($did == 3) { 
      if ($Did(woordfilter, 4).sel) {
        .var %a = $Did(woordfilter, 4, 0).sel
        While (%a) {
          hdel -w censuur $Gettok($Did(woordfilter, 4, %a).seltext, 6, 32)
          did -d woordfilter 4 $Did(woordfilter, 4, %a).sel
          delcensuur [color:red]
          did -r woordfilter 4
          vloek [/color]
          dec %a   
        }   
      }
    } 


Needed to be changed in:

Code:
  if ($did == 3) { 
      if ($Did(woordfilter, 4).sel) {
        .var %a = $Did(woordfilter, 4, 0).sel
        While (%a) {
          hdel -w censuur $Gettok($Did(woordfilter, 4, %a).seltext, 6, 32)
          did -d woordfilter 4 $Did(woordfilter, 4, %a).sel
          delcensuur 
          dec %a   
        }  [color:red]
         did -r woordfilter 4
         vloek  
      } [/color]
    }


Also the alias vloek needed some change:

Code:
 alias vloek {
  var %r = $lines(censuur.txt)
  var %i = 1
  while (%i <= %r ) {
    did -a woordfilter 4 $read(censuur.txt,%i)
    inc %i
  }
} 


Into this:

Code:
 vloek {
  var %i = $hget(censuur,0).data
  while ( %i ) {
    var %word = $hget(censuur,%i).data
    did -a woordfilter 4 %word
    dec %i
  }
}
 


And last but not least to let the filtering work:

Code:
 alias addcensuur {
  hadd -m censuur $did(woordfilter,1).text
  savecensuur
}
 


Into this

Code:
 alias addcensuur {
  hadd -m censuur $did(woordfilter,1).text [color:red]$did(woordfilter,1).text[/color]
  savecensuur
}
 

#163424 30/10/06 07:47 PM
Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
Doh:) like i said early morning pre-coffee time doesn't do me justice smile


$maybe

Link Copied to Clipboard