This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

how many instances of $word in $line

Help for those learning Tcl or writing their own scripts.
Post Reply
G
Garp
Voice
Posts: 29
Joined: Mon Sep 15, 2003 7:58 pm

how many instances of $word in $line

Post by Garp »

This script should catch people who post lines like

Code: Select all

<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: Select all

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
    
	}

}
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

for proper splitting see this
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
Post Reply