Class: Ruboty::Chinachu::Actions::Recorded

Inherits:
Base
  • Object
show all
Defined in:
lib/ruboty/chinachu/actions/recorded.rb

Constant Summary

Constants inherited from Base

Base::PROGRAM_FORMAT

Instance Method Summary collapse

Methods inherited from Base

#chinachu, #chinachu_options

Instance Method Details

#callObject



6
7
8
# File 'lib/ruboty/chinachu/actions/recorded.rb', line 6

def call
  message.reply(list_recorded_yesterday.map { |r| summary(r, PROGRAM_FORMAT) }.join("\n"), code: true)
end

#list_recorded_yesterdayObject



10
11
12
13
14
15
16
17
# File 'lib/ruboty/chinachu/actions/recorded.rb', line 10

def list_recorded_yesterday
  current = Time.now
  before_twenty_four_hour = current - (60 * 60 * 24)
  recorded.select do |program|
    record_end_at = Time.at(program.end / 1000)
    before_twenty_four_hour < record_end_at && record_end_at < current
  end
end

#recordedObject



19
20
21
# File 'lib/ruboty/chinachu/actions/recorded.rb', line 19

def recorded
  chinachu.recorded
end