class OmniBot::PeriodicCommand
Send to jabber user result of a daily command
Attributes
startup_pause[W]
timer_provider[W]
Public Class Methods
new(command)
click to toggle source
# File lib/omnibot/periodiccommand.rb, line 25 def initialize(command) @command = command @startup_pause = 0 raise 'Wrong command' if (@command || '') == '' end
Public Instance Methods
on_first_timer()
click to toggle source
# File lib/omnibot/periodiccommand.rb, line 8 def on_first_timer on_periodic_timer @timer_provider.add_periodic_timer(24 * 3600) { on_periodic_timer } end
on_periodic_timer()
click to toggle source
# File lib/omnibot/periodiccommand.rb, line 13 def on_periodic_timer OmniLog::info "Reporting command #{@command}" jabber_logged_command 'Periodic command', @command rescue => e OmniLog::error "PeriodicCommand error: #{e.message}\ntrace:\n#{Helpers::backtrace e}" end
start()
click to toggle source
# File lib/omnibot/periodiccommand.rb, line 36 def start now = Time.now tomorrow = DateTime.now + 1 next_report_time = Time.local(tomorrow.year, tomorrow.month, tomorrow.day, 1, 0, 0) next_report_time += @startup_pause @timer_provider.add_timer(next_report_time - now) { on_first_timer } end
to_s()
click to toggle source
# File lib/omnibot/periodiccommand.rb, line 32 def to_s "Periodic command '#{@command}'" end