In the documentation for twitter_ebooks you’ll see the following code.
def on_startup scheduler.every '24h' do # Tweet something every 24 hours # See https://github.com/jmettraux/rufus-scheduler # tweet("hi") # pictweet("hi", "cuteselfie.jpg") end end
This will cause your ebooks_bot to tweet every 24 hours. However, what if you want your bot to Tweet at a specific schedule every day? We’ll take a look at how to set that up here…
In the code above,
scheduler refers to an a
Rufus::Scheduler instance (as the comments suggest)
Rufus Scheduler supports cron expressions. For example, if you wanted your bot to tweet at 06:00 and 18:00 every day you’d just update as follows…
def on_startup scheduler.cron '6,18 0 * * *' do tweet("hi") end end
Rufus Scheduler also allows you to specify a timezone, which will override the server timezone. In my case, I want to tweet at New York time. Specifying a timezone is very simple…
def on_startup scheduler.cron '6,18 0 * * * America/New_York' do tweet("hi") end end
Hi, I'm Max!
I'm a software developer who mainly works in PHP, but also dabbles in Ruby and Go. Technical topics that interest me are monitoring, security and performance.
During the day I solve challenging technical problems at Something Digital where I mainly work with the Magento platform. I also blog about tech, work on open source and hunt for bugs.
If you'd like to get in touch with me the best way is on Twitter.