| View previous topic :: View next topic |
| Author |
Message |
Garp Voice
Joined: 15 Sep 2003 Posts: 29
|
Posted: Fri Apr 21, 2006 3:52 am Post subject: how many instances of $word in $line |
|
|
This script should catch people who post lines like
| Code: |
<nick> Who is from location location location location location location location
|
But it's pretty complicated. Is there an easier way to catch annoying repeatings in one line?
| Code: |
bind pubm - "#channel *" dududu
proc dududu {nick uhost hand chan sentence} {
array set wordcount {}
if {([llength $sentence] < 5)||([llength $sentence] > 25)} {return 0}
foreach e [split $sentence] {
if {[llength [split $e ""]] < 4} {return 0};#ignore 'ha ha ha ha ha' etc
if {![info exists wordcount($e)]} {
set wordcount($e) 1
} elseif {[info exists wordcount($e)]} {
incr wordcount($e)
}
}
set output ""
foreach {x y} [array get wordcount] {
if {[string is integer -s $y]} {
lappend score [list $x $y]
}
}
set {e} [lsort -decreasing -integer -index 1 $score]
if { [lindex [lindex $e 0] 1] > 5 } {
putlog "[lindex [lindex $e 0] 0] used [lindex [lindex $e 0] 1] times";#kick or ban goes here
}
} |
|
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Fri Apr 21, 2006 4:07 am Post subject: |
|
|
for proper splitting see this _________________ connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code |
|
| Back to top |
|
 |
|