Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base: fcd8371274
...
compare: 795f97c696
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 8 additions and 8 deletions.
  1. +8 −8 lib/xombot/plugins/weather.rb
16 lib/xombot/plugins/weather.rb
View
@@ -10,12 +10,12 @@ def execute(m, place, option)
@agent = Mechanize.new
page = @agent.get "#{WEATHER_QUERY_URL}#{place}"
current_weather = page.search '//span[@itemprop="temperature-fahrenheit"]'
- current_phrase = page.search '//span[@itemprop="weather-phrase"]'
+ current_phrase = page.search '//div[@class="wx-phrase "]'
if option == "hourly"
hourly_url = page.search '//a[@from="rightnow_1"]'
if hourly_url.first.nil?
- hourly_url = page.search '//a[@from="rightnow_TimeNav_weather_nav"][@title="Hourly"]'
+ hourly_url = page.search '//a[@from="today_TimeNav_weather_nav"][@title="Hourly"]'
end
if hourly_url.first.nil?
@@ -30,21 +30,21 @@ def execute(m, place, option)
parts.insert(0, page.search('//div[@class="wx-timepart wx-first"]'))
reply_string = parts.inject("") do |a, part|
- hour = part.children[1].children[0].content.to_i
- meridian = part.children[1].children[1].content.strip
+ hour = part.children[1].children[0].text.to_i
+ meridian = part.children[1].children[1].text.strip
if meridian.upcase == "PM"
hour += 12
end
- temp = part.children[3].children[2].content.strip.to_i
- phrase = part.children[3].children[4].content
+ temp = part.children[3].children[2].text.strip.to_i
+ phrase = part.children[3].children[4].text
temp_cel = (temp - 32) * 5 / 9
"#{a} #{hour}:00: #{temp}\u00b0F/#{temp_cel}\u00b0C/#{phrase}"
end
m.reply "#{place} by hour:#{reply_string}"
else
- temp = current_weather.first.content.to_i
+ temp = current_weather.first.text.to_i
temp_cel = (temp - 32) * 5 / 9
- m.reply "Weather in #{place}: #{temp}\u00b0F/#{temp_cel}\u00b0C and #{current_phrase.first.content}"
+ m.reply "Weather in #{place}: #{temp}\u00b0F/#{temp_cel}\u00b0C and #{current_phrase.first.text}"
end
end
end

No commit comments for this range

Something went wrong with that request. Please try again.