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.

Ordered Response

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
C
Cardinal
Voice
Posts: 19
Joined: Tue Jan 24, 2006 6:33 pm

Ordered Response

Post by Cardinal »

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 =)

;)
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Elaborate more on your request.
C
Cardinal
Voice
Posts: 19
Joined: Tue Jan 24, 2006 6:33 pm

Post by Cardinal »

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"
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

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]]
}
C
Cardinal
Voice
Posts: 19
Joined: Tue Jan 24, 2006 6:33 pm

Post by Cardinal »

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.
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

You should've figured that out by yourself after the example I gave you.

Code: Select all

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]]
}
C
Cardinal
Voice
Posts: 19
Joined: Tue Jan 24, 2006 6:33 pm

Post by Cardinal »

Thank You!
C
Cardinal
Voice
Posts: 19
Joined: Tue Jan 24, 2006 6:33 pm

Post by Cardinal »

Both scripts are not working:

Tcl error [hallo:reply]: can't read "halloreply": variable is array
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

My bad, replace

Code: Select all

foreach {t o} $halloreply {break}
with

Code: Select all

foreach {t o} $halloreply($chan) {break}
C
Cardinal
Voice
Posts: 19
Joined: Tue Jan 24, 2006 6:33 pm

Post by Cardinal »

thx again! Its working
C
Cardinal
Voice
Posts: 19
Joined: Tue Jan 24, 2006 6:33 pm

Post by Cardinal »

Im sure im going on your nerves... but

Code: Select all

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.
C
Cardinal
Voice
Posts: 19
Joined: Tue Jan 24, 2006 6:33 pm

Post by Cardinal »

Code: Select all

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 ""
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

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.
C
Cardinal
Voice
Posts: 19
Joined: Tue Jan 24, 2006 6:33 pm

Post by Cardinal »

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

...
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

# 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)]"
}
Post Reply