| View previous topic :: View next topic |
| Author |
Message |
Cardinal Voice
Joined: 24 Jan 2006 Posts: 19
|
Posted: Sun Jan 29, 2006 6:15 am Post subject: |
|
|
I replaced the * on bind pubm with "Junge" because the script should just count the word "junge", not every word
But thats not working...
Thank you anyway for the patience![/code] |
|
| Back to top |
|
 |
Cardinal Voice
Joined: 24 Jan 2006 Posts: 19
|
Posted: Sun Jan 29, 2006 6:42 am Post subject: |
|
|
Done!
| Code: |
if {[file exists scripts/wordcount.txt]} {
foreach {word count} [split [read [set infile [open scripts/wordcount.txt]]][close $infile] \n] {
if {$word != ""} {
set wordcount($word) $count
}
}
}
bind time ?0* save:wc
bind pubm - * state:wc
proc save:wc args {
global wordcount
set f [open scripts/wordcount.txt w]
foreach {w c} [array get wordcount] {
puts $f "$w $c"
}
close $f
}
proc state:wc {nick uhost hand chan arg} {
if {[string match -nocase *junge* $arg]} {
global wordcount
set word [string tolower [lindex [split $arg] 0]]
if {![info exists wordcount($word)]} { set wordcount($word) 0 }
puthelp "privmsg $chan :$word Nr. [incr wordcount($word)]"
}
}
|
|
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sun Jan 29, 2006 9:08 pm Post subject: |
|
|
Or you can do this:
| Code: | bind pub - junge state:wc
proc state:wc {nick uhost hand chan arg} {
global wordcount
if {![info exists wordcount(junge)]} { set wordcount(junge) 0 }
puthelp "privmsg $chan :junge Nr. [incr wordcount(junge)]"
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
|