| View previous topic :: View next topic |
| Author |
Message |
Cardinal Voice
Joined: 24 Jan 2006 Posts: 19
|
Posted: Tue Jan 24, 2006 6:38 pm Post subject: Ordered Response |
|
|
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 =)
 |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
|
| Back to top |
|
 |
Cardinal Voice
Joined: 24 Jan 2006 Posts: 19
|
Posted: Tue Jan 24, 2006 7:32 pm Post subject: |
|
|
Hm i can only give a 2nd example because my english is not very professional
Well, the bot should give 3 responses in a specified order to the same word.
ie:
Chan: Hallo!
Bot: HalloNr1
Chan: Hallo!
Bot: HalloNr2
Chan: Hallo!
Bot: HalloNr3
the it should begin again at "HalloNr1" |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Tue Jan 24, 2006 8:54 pm Post subject: |
|
|
| Code: | 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 {break}
if {[unixtime]-$t > 60 || $o > 3} { set o 1 }
putserv "privmsg $chan :HalloNr$o"
set halloreply($chan) [list [unixtime] [incr o]]
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
Cardinal Voice
Joined: 24 Jan 2006 Posts: 19
|
Posted: Wed Jan 25, 2006 2:01 am Post subject: |
|
|
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!.
Chan: Hallo
Bot: Hallo (reply1)
Chan: Hallo
Bot: Hi (reply2)
Chan Hallo
Bot: Hidiho (reply3)
Sorry if im not easy to understand
I hope you now know what i mean. |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Wed Jan 25, 2006 7:29 pm Post subject: |
|
|
You should've figured that out by yourself after the example I gave you.
| Code: | 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] 0]
}
set replies {"Hallo" "Hi" "Hidiho"}
foreach {t o} $halloreply {break}
if {[unixtime]-$t > 60 || $o > 3} { set o 0 }
putserv "privmsg $chan :[lindex $replies $o]"
set halloreply($chan) [list [unixtime] [incr o]]
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
Cardinal Voice
Joined: 24 Jan 2006 Posts: 19
|
Posted: Thu Jan 26, 2006 2:43 am Post subject: |
|
|
| Thank You! |
|
| Back to top |
|
 |
Cardinal Voice
Joined: 24 Jan 2006 Posts: 19
|
Posted: Thu Jan 26, 2006 2:00 pm Post subject: |
|
|
Both scripts are not working:
Tcl error [hallo:reply]: can't read "halloreply": variable is array |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Thu Jan 26, 2006 5:08 pm Post subject: |
|
|
My bad, replace
| Code: | | foreach {t o} $halloreply {break} |
with
| Code: | | foreach {t o} $halloreply($chan) {break} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
Cardinal Voice
Joined: 24 Jan 2006 Posts: 19
|
Posted: Thu Jan 26, 2006 6:50 pm Post subject: |
|
|
| thx again! Its working |
|
| Back to top |
|
 |
Cardinal Voice
Joined: 24 Jan 2006 Posts: 19
|
Posted: Fri Jan 27, 2006 12:56 pm Post subject: |
|
|
Im sure im going on your nerves... but
| Code: |
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. |
|
| Back to top |
|
 |
Cardinal Voice
Joined: 24 Jan 2006 Posts: 19
|
Posted: Fri Jan 27, 2006 2:18 pm Post subject: |
|
|
| Code: |
if {![file exists counter.txt]} {
close [open counter.txt a+]
}
bind pub - junge junge:reply
proc junge:reply {nick uhost hand chan arg} {
global jungereply
if {![info exists jungereply([set chan [string tolower $chan]])]} {
set jungereply($chan) [list [unixtime] 1]
}
set file [open counter.txt r]
set counter [lindex [gets $file] 0]
close $file
incr counter
set $file [open counter.txt w]
puts $file $counter
close $file
putserv "privmsg $chan :Junge $counter"
}
|
That is what i build, but its not working..
Tcl error [hallo:reply]: expected integer but got "" |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri Jan 27, 2006 6:23 pm Post subject: |
|
|
| 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. |
I didn't get what you mean. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
Cardinal Voice
Joined: 24 Jan 2006 Posts: 19
|
Posted: Sat Jan 28, 2006 4:40 am Post subject: |
|
|
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.
i.e:
Chan: Junge
Bot: Junge Nr. 5982
Chan: Junge
Bot: Junge Nr. 5983
... |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat Jan 28, 2006 6:56 pm Post subject: |
|
|
| Code: | # 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)]"
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
|