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.

Quote of the day

Help for those learning Tcl or writing their own scripts.
Post Reply
K
Kaj
Voice
Posts: 3
Joined: Sun Sep 22, 2013 5:09 am

Quote of the day

Post by Kaj »

Hey everyone,

I've a script that's able to fetch a quote from a MySQL database, with the command !quote.

But now I'd like to have something like !quoteoftheday, which returns a quote, which will return the same quote all this day long (selected randomly ofcourse).

So that it returns a different quote everyday.

How can I do this?

~Kaj
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

I guess there are numeous ways of doing this.
The first that comes to mind for me though, would be to store a "quote id generation timestamp", and generate a new quote or "quote-id" if the timestamp is too old...

A simple example would look like this

Code: Select all

proc someproc {} {
  set now [clock scan "today 00:00"]
  if {![info exists ::QuoteTimestamp] || $::QuoteTimestamp <= $now} {
    #Generate new quote here...
    set ::QuoteTimestamp $now
  }
  #Send the quote to the channel
}
NML_375
Post Reply