12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/lita/handlers/moiscot-coffee.rb', line 12
def coffee(response)
time = Time.new
day = time.strftime("%a")
spec = Gem::Specification.find_by_name("moiscot-coffee")
gem_root = spec.gem_dir
path = gem_root + '/lib/lita/handlers/data.json'
file = File.read(path)
data_hash = JSON.parse(file)
data_hash.each do |row|
if row['day'] == day
response.reply "Hoy le toca a #{row['name']} :coffee:"
end
end
rescue => e
Lita.logger.error("Coffee#coffee raised #{e.class}: #{e.message}")
response.reply "Coffee has turned off the internetz, #{e.class} is raising '#{e.message}'"
end
|