17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/ruboty/rainfall_jp.rb', line 17
def rainfall_jp(message)
if YAHOO_JAPAN_APP_ID.nil?
raise "ENV['YAHOO_JAPAN_APP_ID'] is required for this command"
end
query = message.match_data['query'] || DEFAULT_LOCATION
name, geometry = fetch_location_name_and_coodinated_geometry(query)
if geometry.nil?
message.reply('ಠ_ಠ')
message.reply("Location '#{query}' is not found.")
return
end
result = fetch_rainfall(geometry)
message.reply("Rainfall forecast: #{name} (l/l: #{geometry})")
message.reply(result)
rescue Exception => e
message.reply('ಠ_ಠ')
message.reply(e)
message.reply(e.backtrace)
end
|