Skip to content

Commit

Permalink
Added updated at text.
Browse files Browse the repository at this point in the history
  • Loading branch information
onewheelskyward committed Sep 6, 2017
1 parent 88e7144 commit 2638c07
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
30 changes: 14 additions & 16 deletions lib/lita/handlers/onewheel_aqi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ def get_aqi(response)
reply += 'pm10: ' + color_str(aqi['data']['iaqi']['pm10']['v'].to_s) + ' '
end

reply += banner_str
updated_at = Time.parse aqi['data']['time']['s']

reply += "updated #{updated_at.strftime("%H:%M %-m/%-d/%y")} #{banner_str}"

response.reply reply
end
Expand Down Expand Up @@ -172,16 +174,13 @@ def get_aqi_deets(response)
end

def color_str(str, value = nil)
if value.nil?
value = str.to_i
end
value = str.to_i if value.nil?

aqi_range_colors.keys.each do |color_key|
if color_key.cover? value # Super secred cover sauce
if config.mode == :irc
color = colors[aqi_range_colors[color_key]]
str = "\x03#{color}#{str}\x03"
end
next unless color_key.cover? value # Super secred cover sauce
if config.mode == :irc
color = colors[aqi_range_colors[color_key]]
str = "\x03#{color}#{str}\x03"
end
end

Expand All @@ -191,13 +190,12 @@ def color_str(str, value = nil)
def color_str_with_value(range_str:, range_value:)
str = nil
aqi_range_colors.keys.each do |color_key|
if color_key.cover? range_value.to_i # Super secred cover sauce
color = colors[aqi_range_colors[color_key]]
if config.mode == :irc
str = "#{aqi_irc_emoji[color_key]} \x03#{color}#{range_str[color_key]}\x03 #{aqi_irc_emoji[color_key]} "
elsif config.mode == :slack
str = "#{aqi_slack_emoji[color_key]} #{range_str[color_key]} #{aqi_slack_emoji[color_key]} "
end
next unless color_key.cover? range_value.to_i # Super secred cover sauce
color = colors[aqi_range_colors[color_key]]
if config.mode == :irc
str = "#{aqi_irc_emoji[color_key]} \x03#{color}#{range_str[color_key]}\x03 #{aqi_irc_emoji[color_key]} "
elsif config.mode == :slack
str = "#{aqi_slack_emoji[color_key]} #{range_str[color_key]} #{aqi_slack_emoji[color_key]} "
end
end

Expand Down
2 changes: 1 addition & 1 deletion lita-onewheel-aqi.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = 'lita-onewheel-aqi'
spec.version = '2.0.5'
spec.version = '2.0.6'
spec.authors = ['Andrew Kreps']
spec.email = ['andrew.kreps@gmail.com']
spec.description = 'AQI data retrieval bot'
Expand Down
4 changes: 2 additions & 2 deletions spec/lita/handlers/onewheel_aqi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@

it 'queries the aqi' do
send_command 'aqi'
expect(replies.last).to include("AQI for Portland, OR, USA, \u000308Moderate\u0003 pm10: \u00030340\u0003 pm25: \u00030876\u0003 \u000314(http://aqicn.org/city/usa/oregon/government-camp-multorpor-visibility/)\u0003")
expect(replies.last).to include("AQI for Portland, OR, USA, ⚠️ 08Moderate ⚠️ pm25: 0876 pm10: 0340 updated 15:00 8/11/17 14(http://aqicn.org/city/usa/oregon/government-camp-multorpor-visibility/)")
end

it 'queries the aqideets' do
send_command 'aqideets'
expect(replies.last).to eq("AQI for Portland, OR, USA, \u000308Moderate\u0003 humidity: 11% pressure: 1014mb pm10: \u00030340\u0003 pm25: \u00030876\u0003 temp: 34.65C \u000314(http://aqicn.org/city/usa/oregon/government-camp-multorpor-visibility/)\u0003")
expect(replies.last).to eq("AQI for Portland, OR, USA, ⚠️ \u000308Moderate\u0003 ⚠️ humidity: 11% pressure: 1014mb pm10: \u00030340\u0003 pm25: \u00030876\u0003 temp: 34.65C \u000314(http://aqicn.org/city/usa/oregon/government-camp-multorpor-visibility/)\u0003")
end
end

0 comments on commit 2638c07

Please sign in to comment.