zetabot 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b3a554bc48199494aa6031371fb243e7eec95e0a
4
- data.tar.gz: 5ba2388b7dbb81343831c5023afc5c28bf463be8
3
+ metadata.gz: dce1409371adb87fb83f3ae823892cfb68c8de02
4
+ data.tar.gz: 4802a3da4ff5988fff6671ca95109dae47a0daf7
5
5
  SHA512:
6
- metadata.gz: 01db01f70640a77d5193f1fe6837188472439c10221cd67d7228538bc63a072fc4e7b7941626b7537ad52ca797975afd31ff4f91b6bf87d52ed56345519e7cb8
7
- data.tar.gz: 3df65259b967710e7454a5ce87f926b72e8d46a3341974ed84b35e2091b3906b56ce20dac730517e03416a612f1c1251b30a4febafb64f432cf3a395b7fbba11
6
+ metadata.gz: '081b9aa9985ac373d577d9f348174d610a1f10b50e9e3e6c5aeefad250770b732dd0abf3c0ee5be30e96d25d9485d9ae38a2e3b95a9c930d008b2bb5fe441fad'
7
+ data.tar.gz: 77dc4cd3c3bd454f2fe7e1e5d0b6cd0b6d27ece912ef20e6a9daa632f4a1ee01588c8f29efab13cb1a2c58b79a0fd3a3e6164a08ba6ec80ef6d9c73397aef4bd
data/Gemfile.lock CHANGED
@@ -289,4 +289,4 @@ DEPENDENCIES
289
289
  zetabot!
290
290
 
291
291
  BUNDLED WITH
292
- 1.15.4
292
+ 1.16.0
@@ -34,7 +34,7 @@ module Plugins
34
34
  match 'rr', method: :russian
35
35
 
36
36
  def russian(m)
37
- # return m.reply "I am sorry comrade, but I do not have pistol on me." unless m.channel.ops.include?(@bot)
37
+ return m.reply "I am sorry comrade, but I do not have pistol on me." unless m.channel.ops.include?(@bot)
38
38
  return m.user.notice "Sorry comrade, but there is already game going on." if @games.include?(m.channel.name)
39
39
 
40
40
  # player setup
@@ -52,7 +52,7 @@ module Plugins
52
52
  true_src = @api_src.include?(src) ? src : 'wu'
53
53
  data = send("#{true_src}_src", query)
54
54
  end
55
- # return msg.reply "No results found for #{query}." if data.nil?
55
+ return msg.reply "No results found for #{query} with #{true_src} source." if data.nil?
56
56
  # return msg.reply 'Problem getting data. Try again later.' if data.nil?
57
57
  msg.reply(data.reply)
58
58
  end
@@ -141,11 +141,14 @@ module Plugins
141
141
  open(URI.encode("https://autocomplete.wunderground.com/aq?query=#{location}")).read,
142
142
  object_class: OpenStruct
143
143
  )
144
+ return nil if ac.RESULTS.empty?
145
+
144
146
  ac = ac.RESULTS[0]
145
147
  geolookup = JSON.parse(
146
148
  open(URI.encode("https://api.wunderground.com/api/#{Config.secrets[:wunderground]}/geolookup/#{ac.l}.json")).read,
147
149
  object_class: OpenStruct
148
150
  ).location.l rescue nil
151
+
149
152
  # Get Data
150
153
  data = JSON.parse(
151
154
  open("https://api.wunderground.com/api/#{Config.secrets[:wunderground]}/alerts/conditions#{geolookup}.json").read,
@@ -156,7 +159,7 @@ module Plugins
156
159
  data.ac = ac
157
160
  current = data.current_observation
158
161
  alerts = data.alerts.empty? ? 'none' : data.alerts.map {|l| l['type']}.join(',')
159
- pressure_si = current.pressure_mb.to_i / 10
162
+ pressure_si = Unitwise(current.pressure_mb.to_i, '[psi]').convert_to('kPa').to_i.round(2)
160
163
 
161
164
  data.reply = "WU ∴ #{ac.name}, #{ac.c} " \
162
165
  "≈ #{current.weather} #{current.temperature_string} " \
@@ -172,13 +175,18 @@ module Plugins
172
175
  # Open Weather map - https://openweathermap.org/api
173
176
  def owm_src(location)
174
177
  ac = JSON.parse(
175
- open(URI.encode("https://autocomplete.wunderground.com/aq?query=#{location}")).read,
178
+ open(URI.encode("http://maps.googleapis.com/maps/api/geocode/json?address=#{location}")).read,
176
179
  object_class: OpenStruct
177
180
  )
178
- ac = ac.RESULTS[0]
181
+
182
+ return nil if ac.results.nil? ## Unable to locate
183
+
184
+ ac = ac.results[0]
185
+ lat = ac.geometry.location.lat
186
+ lon = ac.geometry.location.lng
179
187
  data = JSON.parse(
180
188
  open(
181
- URI.encode("https://api.openweathermap.org/data/2.5/weather?lat=#{ac.lat}&lon=#{ac.lon}&APPID=#{Config.secrets[:owm]}")
189
+ URI.encode("https://api.openweathermap.org/data/2.5/weather?lat=#{lat}&lon=#{lon}&APPID=#{Config.secrets[:owm]}")
182
190
  ).read,
183
191
  object_class: OpenStruct
184
192
  )
@@ -200,13 +208,18 @@ module Plugins
200
208
  # DarkSky - https://darksky.net/dev
201
209
  def darksky_src(location)
202
210
  ac = JSON.parse(
203
- open(URI.encode("https://autocomplete.wunderground.com/aq?query=#{location}")).read,
211
+ open(URI.encode("http://maps.googleapis.com/maps/api/geocode/json?address=#{location}")).read,
204
212
  object_class: OpenStruct
205
213
  )
206
- ac = ac.RESULTS[0]
214
+ return nil if ac.results.nil? ## Unable to locate
215
+
216
+ ac = ac.results[0]
217
+ lat = ac.geometry.location.lat
218
+ lon = ac.geometry.location.lng
219
+
207
220
  data = JSON.parse(
208
221
  open(
209
- URI.encode("https://api.darksky.net/forecast/#{Config.secrets[:darksky]}/#{ac.lat},#{ac.lon}")
222
+ URI.encode("https://api.darksky.net/forecast/#{Config.secrets[:darksky]}/#{lat},#{lon}")
210
223
  ).read,
211
224
  object_class: OpenStruct
212
225
  )
@@ -236,17 +249,27 @@ module Plugins
236
249
  # NOAA - https://graphical.weather.gov/xml/
237
250
  def noaa_src(location)
238
251
  ac = JSON.parse(
239
- open(URI.encode("https://autocomplete.wunderground.com/aq?query=#{location}")).read,
252
+ open(URI.encode("http://maps.googleapis.com/maps/api/geocode/json?address=#{location}")).read,
240
253
  object_class: OpenStruct
241
254
  )
242
- ac = ac.RESULTS[0]
255
+ return nil if ac.results.nil? ## Unable to locate
256
+
257
+ ac = ac.results[0]
258
+ lat = ac.geometry.location.lat
259
+ lon = ac.geometry.location.lng
260
+
243
261
  stations = JSON.parse(
244
- open(URI.encode("https://api.weather.gov/points/#{ac.lat},#{ac.lon}/stations/")).read)
262
+ open(URI.encode("https://api.weather.gov/points/#{lat},#{lon}/stations/")).read
263
+ ) rescue nil
264
+
265
+ return nil if stations.nil? ## Unable to find station. probably not in the USA
266
+
245
267
  parsed = JSON.parse(
246
268
  open(URI.encode("#{stations['observationStations'][0]}/observations/current")).read,
247
269
  object_class: OpenStruct
248
270
  )
249
271
 
272
+
250
273
  data = parsed.properties
251
274
  data.ac = ac
252
275
  f = data.temperature.value * 9/5
data/lib/Zeta/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Zeta
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zetabot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liothen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-04 00:00:00.000000000 Z
11
+ date: 2017-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler