Class: Descartes::Crunchybot

Inherits:
Object
  • Object
show all
Includes:
Cinch::Plugin
Defined in:
lib/descartes/modules/crunchyroll.rb

Instance Method Summary collapse

Instance Method Details

#get(m) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'lib/descartes/modules/crunchyroll.rb', line 51

def get(m)
  series = Crunchyroll.get m.params[1].split('.cr ')[1]

  if series
    m.reply "#{series[:title].colorize} è una serie trasmessa da #{series[:where].colorize} il #{series[:day].to_ita.colorize} alle #{series[:hour].colorize}:#{series[:min].colorize}, cioè tra #{series[:left].to_ita.colorize}."
  else
    m.reply 'Anime non trovato'.colorize
  end
end

#today(m) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/descartes/modules/crunchyroll.rb', line 23

def today(m)
  crunchyroll = Crunchyroll.today

  aired    = crunchyroll.select { |h| h[:airs] == :aired    }.map { |r| r[:title].colorize }.flatten.join(', ')[0..-2]
  tomorrow = crunchyroll.select { |h| h[:airs] == :tomorrow }
  today    = crunchyroll.select { |h| h[:airs] == :today    }

  m.reply "Gli anime di oggi su #{'Crunchyroll'.colorize}:"

  today.each do |series|
    m.reply "#{series[:title].colorize} (tra #{series[:left].to_ita.colorize})"
  end

  m.reply '' if today.any?

  if tomorrow.any?
    m.reply "Domani trasmetterà (per via del fuso):"
    tomorrow.each do |series|
      m.reply "#{series[:title].colorize} (tra #{series[:left].to_ita.colorize})"
    end
  end

  m.reply '' if tomorrow.any?

  m.reply "Sono stati già trasmessi: #{aired}." unless aired.empty?
end