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.

Adding timed procedure

Old posts that have not been replied to for several years.
Locked
User avatar
YooHoo
Owner
Posts: 939
Joined: Thu Feb 13, 2003 10:07 pm
Location: Redwood Coast

Adding timed procedure

Post by YooHoo »

I'm attempting to add another function to my sexword tcl.
I need a timer to automatically trigger the bot to run my procedure without being otherwise triggered, like every 300 minutes?
Here is what I have so far:

bind pub - !word pub_word
bind msg - word msg_word
bind dcc - word dcc_word

proc pub_word { nick mask hand channel args } {
global definitions
putquick "PRIVMSG $channel :[lindex $definitions [rand [llength $definitions]]]"
}

proc msg_word { nick uhost hand rest } {
global definitions
putquick "NOTICE $nick :[lindex $definitions [rand [llength $definitions]]]"
}

proc dcc_word { hand idx rest } {
global definitions
putidx $idx "[lindex $definitions [rand [llength $definitions]]]"
}


set definitions {
"word1 - definition of word1"
"word2 - definition of word2"
}
User avatar
caesar
Mint Rubber
Posts: 3777
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Automatically trigger it to do what?
Once the game is over, the king and the pawn go back in the same box.
User avatar
YooHoo
Owner
Posts: 939
Joined: Thu Feb 13, 2003 10:07 pm
Location: Redwood Coast

Post by YooHoo »

Trigger its bind. Example of how this tcl works:

<YooHoo> !sexword
<Eggy> teabagging - v. When a man lowers his testicles down onto someone's mouth. So-called because of the resemblance to lowering a teabag into water.

The bot grabs a predefined term and spits it out into the channel when triggered. What I would like to include is a function that would make the bot randomly spew forth a line every hour or so into my room.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Code: Select all

set timer_minutes 300

if {![info exists word_timer_id]} {
  set word_timer_id [timer $timer_minutes word_timer]
}

proc word_timer {} {
  global word_timer_id timer_minutes definitions
  set word_timer_id [timer $timer_minutes word_timer]
  putserv "privmsg #mychan :[lindex $definitions [rand [llength $definitions]]]"
}
Something like that.
User avatar
YooHoo
Owner
Posts: 939
Joined: Thu Feb 13, 2003 10:07 pm
Location: Redwood Coast

Post by YooHoo »

That works fantastically stdragon :lol: my thanks :wink:
Just one more lil' thing I could use help with...a flood control procedure, so chatters won't/can't make the bot flood a room with the $definitions. I tested it out, and the bot will respond to however many times it is triggered until it excess floods. Surely this could be prevented, right?
User avatar
darkmare
Voice
Posts: 12
Joined: Mon Apr 12, 2004 12:55 pm
Location: Beaverton, OR
Contact:

Post by darkmare »

OK this is almost exactly what I want to do, but I have one twist on it; I want to make the timer_minutes variable, something like 10 + random number from 0-30, so that it does the random action every 10-40 minutes, for example.

I can figure out how to add the random amount to the timer, my question is, will that set the timer once everytime it loads it, or will it give a random time interval everytime it calls it? I have a cat, and I want him to do random things like go use the litter box, preen, jump on someone's lap, etc. at random intervals. Also, I'd prefer generic examples; this way I learn something, not just a specific application of it.
Image
Brendan K Callahan Undernet: MaryFinn & PixelCat on #Mary'sPlace | http://3whack.org/brendan/ Theft by Deception DnB music (Released under the CreativeCommons License)
User avatar
darkmare
Voice
Posts: 12
Joined: Mon Apr 12, 2004 12:55 pm
Location: Beaverton, OR
Contact:

Post by darkmare »

Here's what I've started with:

#Random Cat Action
set timer_seconds {30 + [rand 60]}

if {![info exists word_timer_id]} {
set word_timer_id [timer $timer_seconds word_timer]
}

proc word_timer {} {
global word_timer_id timer_seconds random_actions
set word_timer_id [timer $timer_seconds word_timer]
putserv "PRIVMSG #marytest :\001ACTION [lindex $random_actions [rand [llength $random_actions]]]"
}

set random_actions {
"chases a dustball under the bar."
"falls off of the chair, and starts displacement grooming."
"runs around the room chasing invisible mice."
"closes his eyes and starts purring."
"starts grooming."
"stands half in and out of the place."
"perks his ears up, and then closes his eyes once again."
}

I generally try to learn from context, so yes, it's copied, and then modified to fit what I want. As it sits now, it's not working, well, it is, but it's not doing it in seconds, it sems to be doing it in minutes.
Image
Brendan K Callahan Undernet: MaryFinn & PixelCat on #Mary'sPlace | http://3whack.org/brendan/ Theft by Deception DnB music (Released under the CreativeCommons License)
Locked