zetabot 1.0.3 → 1.0.4
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 +30 -30
- data/lib/Zeta/plugins/pdfinfo.rb +14 -12
- data/lib/Zeta/plugins/weather.rb +134 -59
- data/lib/Zeta/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0e83b24e7bb11ff64bf361e2c02c1e0a02bdc566f749510ed466460605e3cc12
|
|
4
|
+
data.tar.gz: 4b6a88945cfda34e4802b032ee70d06bacb6a96cdd1b57951b0449b28d92442a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 70bf0af0cf2e4f1c54ea986bcdb29b9ea3f9e7ecabd4c2c25eb009d5e87f09a23c8a03e2aff03729d50c4653c46a72481c5153115851a0d6be8db0e82b319bc3
|
|
7
|
+
data.tar.gz: f6f666313c39d5591a0748557c2947e9d9307e028b0af4de3e4d1d3e2557c3c8371d7552afb2de2eaa4c25500906f4819473c94f1ef0853770ec4e338becce9b
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
zetabot (1.0.
|
|
4
|
+
zetabot (1.0.4)
|
|
5
5
|
actionview
|
|
6
6
|
chronic
|
|
7
7
|
chronic_duration
|
|
@@ -41,23 +41,23 @@ PATH
|
|
|
41
41
|
GEM
|
|
42
42
|
remote: https://rubygems.org/
|
|
43
43
|
specs:
|
|
44
|
-
Ascii85 (1.0.
|
|
45
|
-
actionview (5.
|
|
46
|
-
activesupport (= 5.
|
|
44
|
+
Ascii85 (1.0.3)
|
|
45
|
+
actionview (5.2.0)
|
|
46
|
+
activesupport (= 5.2.0)
|
|
47
47
|
builder (~> 3.1)
|
|
48
48
|
erubi (~> 1.4)
|
|
49
49
|
rails-dom-testing (~> 2.0)
|
|
50
50
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
|
51
|
-
activesupport (5.
|
|
51
|
+
activesupport (5.2.0)
|
|
52
52
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
53
|
-
i18n (
|
|
53
|
+
i18n (>= 0.7, < 2)
|
|
54
54
|
minitest (~> 5.1)
|
|
55
55
|
tzinfo (~> 1.1)
|
|
56
56
|
addressable (2.5.2)
|
|
57
57
|
public_suffix (>= 2.0.2, < 4.0)
|
|
58
58
|
afm (0.2.2)
|
|
59
59
|
ansi (1.5.0)
|
|
60
|
-
ast (2.
|
|
60
|
+
ast (2.4.0)
|
|
61
61
|
binding.repl (3.0.0)
|
|
62
62
|
builder (3.2.3)
|
|
63
63
|
cd (1.0.1)
|
|
@@ -80,7 +80,7 @@ GEM
|
|
|
80
80
|
concurrent-ruby (1.0.5)
|
|
81
81
|
crack (0.4.3)
|
|
82
82
|
safe_yaml (~> 1.0.0)
|
|
83
|
-
crass (1.0.
|
|
83
|
+
crass (1.0.4)
|
|
84
84
|
daemons (1.2.6)
|
|
85
85
|
debugging (1.1.1)
|
|
86
86
|
binding.repl (~> 3.0)
|
|
@@ -89,17 +89,17 @@ GEM
|
|
|
89
89
|
thread_safe (~> 0.3, >= 0.3.1)
|
|
90
90
|
destructor (0.1.0)
|
|
91
91
|
diff-lcs (1.3)
|
|
92
|
-
discourse_api (0.20.
|
|
92
|
+
discourse_api (0.20.1)
|
|
93
93
|
faraday (~> 0.9)
|
|
94
94
|
faraday_middleware (~> 0.10)
|
|
95
95
|
rack (>= 1.6)
|
|
96
96
|
dnsbl-client (1.0.4)
|
|
97
|
-
domain_name (0.5.
|
|
97
|
+
domain_name (0.5.20180417)
|
|
98
98
|
unf (>= 0.0.5, < 1.0.0)
|
|
99
99
|
dronebl.rb (0.1.0.0)
|
|
100
100
|
httparty (~> 0.13)
|
|
101
101
|
nokogiri (~> 1.6)
|
|
102
|
-
erubi (1.7.
|
|
102
|
+
erubi (1.7.1)
|
|
103
103
|
every_day_irb (2.0.0)
|
|
104
104
|
cd (~> 1.0)
|
|
105
105
|
fancy_irb (1.1.0)
|
|
@@ -109,8 +109,8 @@ GEM
|
|
|
109
109
|
multipart-post (>= 1.2, < 3)
|
|
110
110
|
faraday_middleware (0.12.2)
|
|
111
111
|
faraday (>= 0.7.4, < 1.0)
|
|
112
|
-
ffi (1.9.
|
|
113
|
-
geocoder (1.4.
|
|
112
|
+
ffi (1.9.23)
|
|
113
|
+
geocoder (1.4.7)
|
|
114
114
|
gist (4.6.2)
|
|
115
115
|
github_api (0.18.2)
|
|
116
116
|
addressable (~> 2.4)
|
|
@@ -126,10 +126,10 @@ GEM
|
|
|
126
126
|
hirb (0.7.3)
|
|
127
127
|
http-cookie (1.0.3)
|
|
128
128
|
domain_name (~> 0.5)
|
|
129
|
-
httparty (0.
|
|
129
|
+
httparty (0.16.2)
|
|
130
130
|
multi_xml (>= 0.5.2)
|
|
131
131
|
humanize-bytes (2.2.0)
|
|
132
|
-
i18n (0.
|
|
132
|
+
i18n (1.0.1)
|
|
133
133
|
concurrent-ruby (~> 1.0)
|
|
134
134
|
instance (0.2.0)
|
|
135
135
|
interactive_editor (0.0.11)
|
|
@@ -158,7 +158,7 @@ GEM
|
|
|
158
158
|
iso8601 (0.9.1)
|
|
159
159
|
jwt (1.5.6)
|
|
160
160
|
liner (0.2.4)
|
|
161
|
-
loofah (2.
|
|
161
|
+
loofah (2.2.2)
|
|
162
162
|
crass (~> 1.0.2)
|
|
163
163
|
nokogiri (>= 1.5.9)
|
|
164
164
|
mechanize (2.7.5)
|
|
@@ -179,7 +179,7 @@ GEM
|
|
|
179
179
|
mime-types-data (~> 3.2015)
|
|
180
180
|
mime-types-data (3.2016.0521)
|
|
181
181
|
mini_portile2 (2.3.0)
|
|
182
|
-
minitest (5.11.
|
|
182
|
+
minitest (5.11.3)
|
|
183
183
|
mkfifo (0.1.1)
|
|
184
184
|
multi_json (1.13.1)
|
|
185
185
|
multi_xml (0.6.0)
|
|
@@ -188,7 +188,7 @@ GEM
|
|
|
188
188
|
net-http-persistent (2.9.4)
|
|
189
189
|
net_http_timeout_errors (0.3.0)
|
|
190
190
|
netrc (0.11.0)
|
|
191
|
-
nokogiri (1.8.
|
|
191
|
+
nokogiri (1.8.2)
|
|
192
192
|
mini_portile2 (~> 2.3.0)
|
|
193
193
|
ntlm-http (0.1.1)
|
|
194
194
|
numerizer (0.1.1)
|
|
@@ -198,29 +198,29 @@ GEM
|
|
|
198
198
|
multi_json (~> 1.3)
|
|
199
199
|
multi_xml (~> 0.5)
|
|
200
200
|
rack (>= 1.2, < 3)
|
|
201
|
-
oga (2.
|
|
201
|
+
oga (2.15)
|
|
202
202
|
ast
|
|
203
203
|
ruby-ll (~> 2.1)
|
|
204
204
|
ori (0.1.0)
|
|
205
205
|
os (1.0.0)
|
|
206
206
|
paint (2.0.1)
|
|
207
|
-
parslet (1.8.
|
|
208
|
-
pdf-reader (2.
|
|
207
|
+
parslet (1.8.2)
|
|
208
|
+
pdf-reader (2.1.0)
|
|
209
209
|
Ascii85 (~> 1.0.0)
|
|
210
210
|
afm (~> 0.2.1)
|
|
211
211
|
hashery (~> 2.0)
|
|
212
212
|
ruby-rc4
|
|
213
213
|
ttfunk
|
|
214
214
|
persist (1.0.0)
|
|
215
|
-
public_suffix (3.0.
|
|
216
|
-
rack (2.0.
|
|
215
|
+
public_suffix (3.0.2)
|
|
216
|
+
rack (2.0.5)
|
|
217
217
|
rails-dom-testing (2.0.3)
|
|
218
218
|
activesupport (>= 4.2.0)
|
|
219
219
|
nokogiri (>= 1.6)
|
|
220
|
-
rails-html-sanitizer (1.0.
|
|
221
|
-
loofah (~> 2.
|
|
220
|
+
rails-html-sanitizer (1.0.4)
|
|
221
|
+
loofah (~> 2.2, >= 2.2.2)
|
|
222
222
|
rake (10.5.0)
|
|
223
|
-
recursive-open-struct (1.0
|
|
223
|
+
recursive-open-struct (1.1.0)
|
|
224
224
|
rest-client (2.0.2)
|
|
225
225
|
http-cookie (>= 1.0.2, < 2.0)
|
|
226
226
|
mime-types (>= 1.16, < 4.0)
|
|
@@ -237,7 +237,7 @@ GEM
|
|
|
237
237
|
rspec-mocks (3.7.0)
|
|
238
238
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
239
239
|
rspec-support (~> 3.7.0)
|
|
240
|
-
rspec-support (3.7.
|
|
240
|
+
rspec-support (3.7.1)
|
|
241
241
|
ruby-ll (2.1.2)
|
|
242
242
|
ansi
|
|
243
243
|
ast
|
|
@@ -255,12 +255,12 @@ GEM
|
|
|
255
255
|
tilt (2.0.8)
|
|
256
256
|
time-lord (1.0.1)
|
|
257
257
|
ttfunk (1.5.1)
|
|
258
|
-
tzinfo (1.2.
|
|
258
|
+
tzinfo (1.2.5)
|
|
259
259
|
thread_safe (~> 0.1)
|
|
260
260
|
unf (0.1.4)
|
|
261
261
|
unf_ext
|
|
262
|
-
unf_ext (0.0.7.
|
|
263
|
-
unicode-display_width (1.3.
|
|
262
|
+
unf_ext (0.0.7.5)
|
|
263
|
+
unicode-display_width (1.3.2)
|
|
264
264
|
unitwise (2.2.0)
|
|
265
265
|
liner (~> 0.2)
|
|
266
266
|
memoizable (~> 0.4)
|
data/lib/Zeta/plugins/pdfinfo.rb
CHANGED
|
@@ -42,18 +42,20 @@ module Plugins
|
|
|
42
42
|
return msg.reply("PDF → Unable to parse. file too big #{humanize_size}kb")
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
45
|
+
# Parse the HTML
|
|
46
|
+
Timeout::timeout(12) {
|
|
47
|
+
# Get file and parse metadata
|
|
48
|
+
open(url, "rb") do |io|
|
|
49
|
+
reader = PDF::Reader.new(io)
|
|
50
|
+
creator = reader.info[:Creator] || 'Anon'
|
|
51
|
+
producer = reader.info[:Producer] || 'Anon'
|
|
52
|
+
creation = reader.info[:CreationDate] || 'now'
|
|
53
|
+
modification = reader.info[:ModDate] || 'now'
|
|
54
|
+
title = reader.info[:Title] || nil
|
|
55
|
+
display = title ? title : "Title: None <> Creator: #{creator} <> Producer: #{producer} <> Creation: #{creation}"
|
|
56
|
+
msg.reply "PDF (#{humanize_size}kb) → #{display}"
|
|
57
|
+
end
|
|
58
|
+
}
|
|
57
59
|
|
|
58
60
|
|
|
59
61
|
rescue => e
|
data/lib/Zeta/plugins/weather.rb
CHANGED
|
@@ -21,79 +21,101 @@ module Plugins
|
|
|
21
21
|
match /w (.+)/, method: :weather
|
|
22
22
|
match 'w', method: :weather
|
|
23
23
|
match /setw (.+)/, method: :set_location
|
|
24
|
+
match /setws (.+)/, method: :set_source
|
|
24
25
|
match /wx (.+)/, method: :weather
|
|
25
26
|
match /weather (.+)/, method: :weather
|
|
26
27
|
|
|
27
28
|
#####
|
|
28
29
|
def initialize(*args)
|
|
29
|
-
@api_src = %w{wu noaa
|
|
30
|
-
@
|
|
30
|
+
@api_src = %w{wu noaa ds owm}
|
|
31
|
+
@src_translated = {wu: 'Wunderground', noaa: 'NOAA', ds: 'DarkSky', owm: 'Open Weather Map'}
|
|
32
|
+
@store = Persist.new(File.join(Dir.home, '.zeta', 'cache', 'weather.pstore'))
|
|
33
|
+
@source = Persist.new(File.join(Dir.home, '.zeta', 'cache', 'weather_source.pstore'))
|
|
31
34
|
super
|
|
32
35
|
end
|
|
33
36
|
|
|
34
37
|
# ?w <location>
|
|
35
38
|
def weather(msg, query=nil)
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
if !@source[msg.user.to_s].nil?
|
|
40
|
+
stored_source = @source[msg.user.to_s]
|
|
41
|
+
else
|
|
42
|
+
stored_source = 'wu'
|
|
43
|
+
end
|
|
44
|
+
|
|
38
45
|
if !@store[msg.user.to_s].nil? && query.nil?
|
|
39
|
-
|
|
40
|
-
stored_source = @api_src.include?(stored_source) ? stored_source : 'wu'
|
|
41
|
-
data = send("#{stored_source}_src", stored_location)
|
|
42
|
-
# location = geolookup(@store[msg.user.to_s])
|
|
43
|
-
# data = wunderground_src(stored_location, false)
|
|
46
|
+
data = send("#{stored_source}_src", msg, @store[msg.user.to_s], true)
|
|
44
47
|
elsif query.nil?
|
|
45
|
-
return msg.reply 'No location set. ?setw <location>
|
|
48
|
+
return msg.reply 'No location set. ?setw <location> and ?setws <source> for where you get the weather from'
|
|
46
49
|
else
|
|
47
50
|
# data = wu_src(query, true)
|
|
48
|
-
src = query[/:\w+/].gsub(/:/, '') if query[/:\w+/]
|
|
49
51
|
query = query.gsub(/:\w+/, '').strip if query
|
|
50
|
-
|
|
51
|
-
data = send("#{true_src}_src", query)
|
|
52
|
+
data = send("#{stored_source}_src", msg, query)
|
|
52
53
|
end
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
|
|
55
|
+
return msg.reply "No results found for #{query} with #{@src_translated[stored_source.to_sym]} source." if data.nil?
|
|
55
56
|
msg.reply(data.reply)
|
|
56
57
|
end
|
|
57
58
|
|
|
58
59
|
# ?setw <location>
|
|
59
60
|
def set_location(msg, query)
|
|
60
61
|
# Establish source
|
|
61
|
-
src = query[/:\w+/].gsub(/:/, '') if query[/:\w+/]
|
|
62
62
|
query = query.gsub(/:\w+/, '').strip if query
|
|
63
63
|
|
|
64
64
|
# Sanity Check
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
if !@source[msg.user.to_s].nil?
|
|
66
|
+
stored_source = @source[msg.user.to_s]
|
|
67
|
+
else
|
|
68
|
+
stored_source = 'wu'
|
|
69
|
+
end
|
|
70
|
+
data = send("#{stored_source}_src", msg,query)
|
|
67
71
|
|
|
68
72
|
# Error
|
|
69
73
|
return msg.reply "No results found for #{query}." if data.nil?
|
|
70
74
|
|
|
71
75
|
# Store and display general location
|
|
72
|
-
|
|
76
|
+
|
|
77
|
+
serial_location = "#{data.lat},#{data.lon}"
|
|
73
78
|
@store[msg.user.to_s] = serial_location unless data.nil?
|
|
74
|
-
msg.reply "Your location is now set to #{data.ac.
|
|
79
|
+
msg.reply "Your location is now set to #{data.ac.formatted_address}!"
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# ?setws <source>
|
|
83
|
+
def set_source(msg,src)
|
|
84
|
+
return msg.reply("You can set your weather source using ?setws <omw|ds|wu|noaa>") if src.nil?
|
|
85
|
+
true_src = @api_src.include?(src) ? src : 'wu'
|
|
86
|
+
@source[msg.user.to_s] = true_src
|
|
87
|
+
msg.reply "Your weather source is set to #{@src_translated[true_src.to_sym]}!"
|
|
75
88
|
end
|
|
76
89
|
|
|
77
90
|
private
|
|
78
91
|
#### Weather Sources
|
|
79
92
|
# Weather Underground - https://wunderground.com
|
|
80
|
-
def wu_src(location)
|
|
93
|
+
def wu_src(msg, location, stored=false)
|
|
81
94
|
# Fuzzy location lookup
|
|
82
95
|
# ac = JSON.parse(
|
|
83
96
|
# open(URI.encode("https://autocomplete.wunderground.com/aq?query=#{location}")).read,
|
|
84
97
|
# object_class: OpenStruct
|
|
85
98
|
# )
|
|
86
99
|
# return nil if ac.RESULTS.empty?
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
)
|
|
91
|
-
return nil if ac.results.nil? ## Unable to locate
|
|
92
|
-
|
|
93
|
-
ac = ac.results[0]
|
|
94
|
-
lat = ac.geometry.location.lat
|
|
95
|
-
lon = ac.geometry.location.lng
|
|
100
|
+
if stored
|
|
101
|
+
lat, lon = @store[msg.user.to_s].split(',')
|
|
102
|
+
else
|
|
96
103
|
|
|
104
|
+
ac = JSON.parse(
|
|
105
|
+
open(URI.encode("http://maps.googleapis.com/maps/api/geocode/json?address=#{location}")).read,
|
|
106
|
+
object_class: OpenStruct
|
|
107
|
+
)
|
|
108
|
+
return nil if ac.results.nil?
|
|
109
|
+
if ac.status = "OVER_QUERY_LIMIT"
|
|
110
|
+
return msg.reply("Google API - Over query Limit")
|
|
111
|
+
return nil
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
ac = ac.results[0]
|
|
115
|
+
lat = ac.geometry.location.lat
|
|
116
|
+
lon = ac.geometry.location.lng
|
|
117
|
+
localname = ac.formatted_address
|
|
118
|
+
end
|
|
97
119
|
# ac = ac.RESULTS[0]
|
|
98
120
|
geolookup = JSON.parse(
|
|
99
121
|
# open(URI.encode("https://api.wunderground.com/api/#{Config.secrets[:wunderground]}/geolookup/#{ac.l}.json")).read,
|
|
@@ -108,11 +130,14 @@ module Plugins
|
|
|
108
130
|
)
|
|
109
131
|
|
|
110
132
|
data.ac = ac
|
|
133
|
+
data.lat = lat
|
|
134
|
+
data.lon = lon
|
|
135
|
+
localname = data.current_observation.display_location.full if localname.nil?
|
|
111
136
|
current = data.current_observation
|
|
112
137
|
alerts = data.alerts.empty? ? 'none' : data.alerts.map {|l| l['type']}.join(',')
|
|
113
138
|
pressure_si = Unitwise((current.pressure_in.to_f)+14.7, '[psi]').convert_to('kPa').to_f.round(2)
|
|
114
139
|
|
|
115
|
-
data.reply = "WU ∴ #{
|
|
140
|
+
data.reply = "WU ∴ #{localname} " \
|
|
116
141
|
"≈ #{current.weather} #{current.temperature_string} " \
|
|
117
142
|
"≈ Feels like #{current.feelslike_string} " \
|
|
118
143
|
"≈ Humidity: #{current.relative_humidity} " \
|
|
@@ -124,17 +149,27 @@ module Plugins
|
|
|
124
149
|
end
|
|
125
150
|
|
|
126
151
|
# Open Weather map - https://openweathermap.org/api
|
|
127
|
-
def owm_src(location)
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
return nil if ac.results.nil? ## Unable to locate
|
|
152
|
+
def owm_src(msg, location, stored=false)
|
|
153
|
+
if stored
|
|
154
|
+
lat, lon = @store[msg.user.to_s].split(',')
|
|
155
|
+
else
|
|
134
156
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
157
|
+
ac = JSON.parse(
|
|
158
|
+
open(URI.encode("http://maps.googleapis.com/maps/api/geocode/json?address=#{location}")).read,
|
|
159
|
+
object_class: OpenStruct
|
|
160
|
+
)
|
|
161
|
+
return nil if ac.results.nil? ## Unable to locate
|
|
162
|
+
|
|
163
|
+
if ac.status = "OVER_QUERY_LIMIT"
|
|
164
|
+
return msg.reply("Google API - Over query Limit")
|
|
165
|
+
return nil
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
ac = ac.results[0]
|
|
169
|
+
lat = ac.geometry.location.lat
|
|
170
|
+
lon = ac.geometry.location.lng
|
|
171
|
+
localname = ac.formatted_address
|
|
172
|
+
end
|
|
138
173
|
|
|
139
174
|
# Get Data
|
|
140
175
|
data = JSON.parse(
|
|
@@ -148,7 +183,11 @@ module Plugins
|
|
|
148
183
|
pressure = Unitwise((data.main.pressure.to_f/10)+101, 'kPa')
|
|
149
184
|
wind = Unitwise(data.wind.speed, 'kilometer')
|
|
150
185
|
|
|
151
|
-
|
|
186
|
+
localname = data.name if localname.nil?
|
|
187
|
+
|
|
188
|
+
data.lat = lat
|
|
189
|
+
data.lon = lon
|
|
190
|
+
data.reply = "OWM ∴ #{localname} " \
|
|
152
191
|
"≈ #{data.weather[0].description}, #{temp.convert_to('[degF]').to_i.round(2)} F (#{temp.convert_to('Cel').to_i.round(2)} C) " \
|
|
153
192
|
"≈ Humidity: #{data.main.humidity}% " \
|
|
154
193
|
"≈ Pressure: #{pressure.convert_to('[psi]').to_f.round(2)} psi (#{pressure.convert_to('kPa').to_f} kPa) " \
|
|
@@ -159,16 +198,28 @@ module Plugins
|
|
|
159
198
|
end
|
|
160
199
|
|
|
161
200
|
# DarkSky - https://darksky.net/dev
|
|
162
|
-
def darksky_src(location)
|
|
201
|
+
def darksky_src(msg,location,stored=false)
|
|
202
|
+
|
|
163
203
|
ac = JSON.parse(
|
|
164
204
|
open(URI.encode("http://maps.googleapis.com/maps/api/geocode/json?address=#{location}")).read,
|
|
165
205
|
object_class: OpenStruct
|
|
166
206
|
)
|
|
167
207
|
return nil if ac.results.nil? ## Unable to locate
|
|
168
208
|
|
|
209
|
+
if ac.status = "OVER_QUERY_LIMIT"
|
|
210
|
+
return msg.reply("Google API - Over query Limit")
|
|
211
|
+
return nil
|
|
212
|
+
end
|
|
213
|
+
|
|
169
214
|
ac = ac.results[0]
|
|
170
|
-
|
|
171
|
-
|
|
215
|
+
if stored
|
|
216
|
+
lat, lon = @store[msg.user.to_s].split(',')
|
|
217
|
+
else
|
|
218
|
+
lat = ac.geometry.location.lat
|
|
219
|
+
lon = ac.geometry.location.lng
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
localname = ac.formatted_address
|
|
172
223
|
|
|
173
224
|
data = JSON.parse(
|
|
174
225
|
open(
|
|
@@ -176,7 +227,12 @@ module Plugins
|
|
|
176
227
|
).read,
|
|
177
228
|
object_class: OpenStruct
|
|
178
229
|
)
|
|
230
|
+
|
|
179
231
|
data.ac = ac
|
|
232
|
+
data.lat = lat
|
|
233
|
+
data.lon = lon
|
|
234
|
+
|
|
235
|
+
|
|
180
236
|
current = data.currently
|
|
181
237
|
alerts = data.alerts.count rescue 0
|
|
182
238
|
c = Unitwise(current.temperature, '[degF]').convert_to('Cel').to_i
|
|
@@ -187,7 +243,7 @@ module Plugins
|
|
|
187
243
|
tempstring = "#{current.temperature.to_i} F (#{c} C)"
|
|
188
244
|
feelslike = "#{current.apparentTemperature.to_i} F (#{c_feels} C)"
|
|
189
245
|
|
|
190
|
-
data.reply = "DS ∴ #{
|
|
246
|
+
data.reply = "DS ∴ #{localname} " \
|
|
191
247
|
"≈ #{current.summary} #{tempstring} " \
|
|
192
248
|
"≈ Feels like #{feelslike} " \
|
|
193
249
|
"≈ Humidity: #{current.relative_humidity} " \
|
|
@@ -200,38 +256,57 @@ module Plugins
|
|
|
200
256
|
end
|
|
201
257
|
|
|
202
258
|
# NOAA - https://graphical.weather.gov/xml/
|
|
203
|
-
def noaa_src(location)
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
)
|
|
208
|
-
return nil if ac.results.nil? ## Unable to locate
|
|
259
|
+
def noaa_src(msg, location, stored=false)
|
|
260
|
+
if stored
|
|
261
|
+
lat, lon = @store[msg.user.to_s].split(',')
|
|
262
|
+
else
|
|
209
263
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
264
|
+
ac = JSON.parse(
|
|
265
|
+
open(URI.encode("http://maps.googleapis.com/maps/api/geocode/json?address=#{location}")).read,
|
|
266
|
+
object_class: OpenStruct
|
|
267
|
+
)
|
|
268
|
+
return nil if ac.results.nil? ## Unable to locate
|
|
269
|
+
|
|
270
|
+
if ac.status = "OVER_QUERY_LIMIT"
|
|
271
|
+
return msg.reply("Google API - Over query Limit")
|
|
272
|
+
return nil
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
ac = ac.results[0]
|
|
276
|
+
lat = ac.geometry.location.lat
|
|
277
|
+
lon = ac.geometry.location.lng
|
|
278
|
+
localname = ac.formatted_address
|
|
279
|
+
end
|
|
213
280
|
|
|
214
|
-
|
|
281
|
+
station_list = JSON.parse(
|
|
215
282
|
open(URI.encode("https://api.weather.gov/points/#{lat},#{lon}/stations/")).read
|
|
216
283
|
) rescue nil
|
|
217
284
|
|
|
218
|
-
return nil if
|
|
285
|
+
return nil if station_list.nil? ## Unable to find station. probably not in the USA
|
|
286
|
+
|
|
287
|
+
station = JSON.parse(
|
|
288
|
+
open(URI.encode("#{station_list['observationStations'][0]}")).read,
|
|
289
|
+
object_class: OpenStruct
|
|
290
|
+
)
|
|
219
291
|
|
|
220
292
|
parsed = JSON.parse(
|
|
221
|
-
open(URI.encode("#{
|
|
293
|
+
open(URI.encode("#{station_list['observationStations'][0]}/observations/current")).read,
|
|
222
294
|
object_class: OpenStruct
|
|
223
295
|
)
|
|
224
296
|
|
|
297
|
+
localname = station.properties.name if localname.nil?
|
|
225
298
|
|
|
226
299
|
data = parsed.properties
|
|
227
300
|
data.ac = ac
|
|
301
|
+
data.lat = lat
|
|
302
|
+
data.lon = lon
|
|
228
303
|
f = data.temperature.value * 9/5
|
|
229
304
|
temp = "#{f.round(2)} F (#{data.temperature.value.to_i.round(2)} C) "
|
|
230
305
|
wind = "Gusts: #{data.windGust.value} avg: #{data.windSpeed.value.to_i.round(2)}"
|
|
231
306
|
feelslike = "#{data.windChill.value.to_i.round(2)} C"
|
|
232
307
|
pressure = Unitwise(data.barometricPressure.value.to_f+101325, 'Pa')
|
|
233
308
|
|
|
234
|
-
data.reply = "NOAA ∴ #{
|
|
309
|
+
data.reply = "NOAA ∴ #{localname} " \
|
|
235
310
|
"≈ #{data.textDescription} #{temp} " \
|
|
236
311
|
"≈ Feels like #{feelslike} " \
|
|
237
312
|
"≈ Humidity: #{data.relativeHumidity.value.round(2)} " \
|
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.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Liothen
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-01
|
|
11
|
+
date: 2018-05-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -657,7 +657,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
657
657
|
version: '0'
|
|
658
658
|
requirements: []
|
|
659
659
|
rubyforge_project:
|
|
660
|
-
rubygems_version: 2.7.
|
|
660
|
+
rubygems_version: 2.7.3
|
|
661
661
|
signing_key:
|
|
662
662
|
specification_version: 4
|
|
663
663
|
summary: Zeta is a IRC bot written in ruby using the Cinch Framework
|