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 

Ordered Response
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Cardinal
Voice


Joined: 24 Jan 2006
Posts: 19

PostPosted: Tue Jan 24, 2006 6:38 pm    Post subject: Ordered Response Reply with quote

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

Wink
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Tue Jan 24, 2006 7:21 pm    Post subject: Reply with quote

Elaborate more on your request.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Cardinal
Voice


Joined: 24 Jan 2006
Posts: 19

PostPosted: Tue Jan 24, 2006 7:32 pm    Post subject: Reply with quote

Hm i can only give a 2nd example because my english is not very professional Wink

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


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Tue Jan 24, 2006 8:54 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Cardinal
Voice


Joined: 24 Jan 2006
Posts: 19

PostPosted: Wed Jan 25, 2006 2:01 am    Post subject: Reply with quote

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 Sad
I hope you now know what i mean.
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Wed Jan 25, 2006 7:29 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Cardinal
Voice


Joined: 24 Jan 2006
Posts: 19

PostPosted: Thu Jan 26, 2006 2:43 am    Post subject: Reply with quote

Thank You!
Back to top
View user's profile Send private message
Cardinal
Voice


Joined: 24 Jan 2006
Posts: 19

PostPosted: Thu Jan 26, 2006 2:00 pm    Post subject: Reply with quote

Both scripts are not working:

Tcl error [hallo:reply]: can't read "halloreply": variable is array
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Thu Jan 26, 2006 5:08 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Cardinal
Voice


Joined: 24 Jan 2006
Posts: 19

PostPosted: Thu Jan 26, 2006 6:50 pm    Post subject: Reply with quote

thx again! Its working
Back to top
View user's profile Send private message
Cardinal
Voice


Joined: 24 Jan 2006
Posts: 19

PostPosted: Fri Jan 27, 2006 12:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
Cardinal
Voice


Joined: 24 Jan 2006
Posts: 19

PostPosted: Fri Jan 27, 2006 2:18 pm    Post subject: Reply with quote

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


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Fri Jan 27, 2006 6:23 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Cardinal
Voice


Joined: 24 Jan 2006
Posts: 19

PostPosted: Sat Jan 28, 2006 4:40 am    Post subject: Reply with quote

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


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sat Jan 28, 2006 6:56 pm    Post subject: Reply with quote

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
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 -> Script Requests All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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