| View previous topic :: View next topic |
| Author |
Message |
Kaj Voice
Joined: 22 Sep 2013 Posts: 3
|
Posted: Sun Sep 22, 2013 5:14 am Post subject: Quote of the day |
|
|
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 |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun Sep 22, 2013 10:14 am Post subject: |
|
|
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: | 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, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
|