Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

URI escape city names

'los angeles' needs to be 'los%20angeles'
  • Loading branch information...
commit fa969026b10088bc018baa73d6e068b64866d802 1 parent 5e60cfa
@steveklabnik authored
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}"
Please sign in to comment.
Something went wrong with that request. Please try again.