Hello,
i need an Response Script wich give different response in a specified order if the same word is used in a short time window (about 60seconds).
ie (within 60 seconds):
Chan: mana mana
Bot: *badiipidipi"
Chan: mana mana
Bot: *bapidi*
Chan: mana mana
Bot: *badibidid bididi bdidipipdiidi"
The bot should always give the Response in this Order, if the Words are used 3 times in a row within 60 seconds.
The time Windows isnt very importand but would be nice =)
Sorry but that is not what i mean, he should not just add a number behind the same response.
The Bot should give 3 very different responses, but in a specified order!.
bind pub - hallo! hallo:reply
proc hallo:reply {nick uhost hand chan arg} {
global halloreply
if {![info exists halloreply([set chan [string tolower $chan]])]} {
set halloreply($chan) [list [unixtime] 1]
}
foreach {t o} $halloreply($chan) {break}
if {[unixtime]-$t > 60 || $o > 3} { set o 1 }
putserv "privmsg $chan :HalloNr$o"
set halloreply($chan) [list [unixtime] [incr o]]
}
Can you edit that the script will count the word endless, and will never beginn from 0? If im right then it must be savend in an extern file to keep the number.
Cardinal wrote:Can you edit that the script will count the word endless, and will never beginn from 0? If im right then it must be savend in an extern file to keep the number.
The Script should count how often the word hello was used in the channel, and always give out the count if its used.
So the script must save the number in a file to keep it on a reboot.
# read words with count from file
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
}
}
}
# save words to file every 10 minute
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} {
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)]"
}