Skip to content
Browse files

URI escape city names

'los angeles' needs to be 'los%20angeles'
  • Loading branch information...
1 parent 5e60cfa commit fa969026b10088bc018baa73d6e068b64866d802 @steveklabnik committed
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/xombot/plugins/local_time.rb
View
4 lib/xombot/plugins/local_time.rb
@@ -1,3 +1,5 @@
+require 'uri'
+
class LocalTime < XOmBot::Plugin
TIME_QUERY_URL = "http://www.timeanddate.com/worldclock/results.html?query="
@@ -7,7 +9,7 @@ class LocalTime < XOmBot::Plugin
def execute(m, place)
@agent = Mechanize.new
- page = @agent.get "#{TIME_QUERY_URL}#{place}"
+ page = @agent.get "#{TIME_QUERY_URL}#{URI.escape(place)}"
current_time = page.search '//strong[@id="ct"]'
m.reply "Time in #{place}: #{current_time.first.content}"

0 comments on commit fa96902

Please sign in to comment.
Something went wrong with that request. Please try again.