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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/Zeta/plugins/russian_roulette.rb +1 -1
- data/lib/Zeta/plugins/weather.rb +34 -11
- data/lib/Zeta/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dce1409371adb87fb83f3ae823892cfb68c8de02
|
4
|
+
data.tar.gz: 4802a3da4ff5988fff6671ca95109dae47a0daf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '081b9aa9985ac373d577d9f348174d610a1f10b50e9e3e6c5aeefad250770b732dd0abf3c0ee5be30e96d25d9485d9ae38a2e3b95a9c930d008b2bb5fe441fad'
|
7
|
+
data.tar.gz: 77dc4cd3c3bd454f2fe7e1e5d0b6cd0b6d27ece912ef20e6a9daa632f4a1ee01588c8f29efab13cb1a2c58b79a0fd3a3e6164a08ba6ec80ef6d9c73397aef4bd
|
data/Gemfile.lock
CHANGED
@@ -34,7 +34,7 @@ module Plugins
|
|
34
34
|
match 'rr', method: :russian
|
35
35
|
|
36
36
|
def russian(m)
|
37
|
-
|
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
|
data/lib/Zeta/plugins/weather.rb
CHANGED
@@ -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
|
-
|
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
|
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("
|
178
|
+
open(URI.encode("http://maps.googleapis.com/maps/api/geocode/json?address=#{location}")).read,
|
176
179
|
object_class: OpenStruct
|
177
180
|
)
|
178
|
-
|
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=#{
|
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("
|
211
|
+
open(URI.encode("http://maps.googleapis.com/maps/api/geocode/json?address=#{location}")).read,
|
204
212
|
object_class: OpenStruct
|
205
213
|
)
|
206
|
-
|
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]}/#{
|
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("
|
252
|
+
open(URI.encode("http://maps.googleapis.com/maps/api/geocode/json?address=#{location}")).read,
|
240
253
|
object_class: OpenStruct
|
241
254
|
)
|
242
|
-
|
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/#{
|
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
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.
|
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-
|
11
|
+
date: 2017-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|