egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how many instances of $word in $line

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Garp
Voice


Joined: 15 Sep 2003
Posts: 29

PostPosted: Fri Apr 21, 2006 3:52 am    Post subject: how many instances of $word in $line Reply with quote

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
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Fri Apr 21, 2006 4:07 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber