lita-onewheel-forecast-io 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/lita/handlers/utils.rb +5 -3
- data/lita-onewheel-forecast-io.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4973d862a7f63d33ebc7433799e0ca0cfcfa5952
|
4
|
+
data.tar.gz: a5cded2488420f509fc0b3e62ae0a00bc3e98f77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aacb79de8f6a0b323866de5b7e4d943fc28cfde1e16b0bc3306ac24d59f235950e1fbb0b9692178e1aced2ccc311d324979a13c923b85644a131702137fdcc2f
|
7
|
+
data.tar.gz: f7e5fbfc6ac34b0ee56087b53e1524fd2462369dafe264dfc8a30b444b174f573d3108f716dd48ef6853db68a48bdf2883c7f6928c9542fd395f445608a92590
|
data/lib/lita/handlers/utils.rb
CHANGED
@@ -58,7 +58,7 @@ module ForecastIo
|
|
58
58
|
|
59
59
|
# Perform a geocoder lookup based on a) the query or b) the user's serialized state.
|
60
60
|
# If neither of those exist, default to Portland.
|
61
|
-
def geo_lookup(user, query)
|
61
|
+
def geo_lookup(user, query, persist = true)
|
62
62
|
Lita.logger.debug "Performing geolookup for '#{user.name}' for '#{query}'"
|
63
63
|
|
64
64
|
default_location = {
|
@@ -86,7 +86,9 @@ module ForecastIo
|
|
86
86
|
Lita.logger.debug "Redis hget failed, performing lookup for #{query}"
|
87
87
|
geocoded = optimistic_geo_wrapper query
|
88
88
|
Lita.logger.debug "Geolocation found. '#{geocoded.inspect}' failed, performing lookup"
|
89
|
-
|
89
|
+
if persist
|
90
|
+
redis.hset(REDIS_KEY, user.name, geocoded.to_json)
|
91
|
+
end
|
90
92
|
end
|
91
93
|
|
92
94
|
# Let's set up the defaults in the event that the geocoder fails.
|
@@ -165,7 +167,7 @@ module ForecastIo
|
|
165
167
|
end
|
166
168
|
|
167
169
|
def handle_geo_lookup(response)
|
168
|
-
location = geo_lookup(response.user, response.match_data[1])
|
170
|
+
location = geo_lookup(response.user, response.match_data[1], persist = false)
|
169
171
|
response.reply "#{location.latitude}, #{location.longitude}"
|
170
172
|
end
|
171
173
|
|