zetabot 0.0.22 → 1.0.0

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: cb98fe52dab0420577c01223ef4bebe5db52e962
4
- data.tar.gz: 8435c0f3027d592f72224d0ad26dfd7208866d07
3
+ metadata.gz: b3a554bc48199494aa6031371fb243e7eec95e0a
4
+ data.tar.gz: 5ba2388b7dbb81343831c5023afc5c28bf463be8
5
5
  SHA512:
6
- metadata.gz: 9e322912043ddd3abfd2663120b7f326fe6bf45fd7dce0596333472889d8a3eb6ae11690a8a4d27a13b77e00642b859ba4946f96ce340d80e939ae2419f6db38
7
- data.tar.gz: b399bc83defb05cdac4b3b204c2fa39d72abc5d771b146d3c67c1fa67eff17776c7dda08f0dbf724543d6d519d3451df514fddd38864a90da147bbb516a4c386
6
+ metadata.gz: 01db01f70640a77d5193f1fe6837188472439c10221cd67d7228538bc63a072fc4e7b7941626b7537ad52ca797975afd31ff4f91b6bf87d52ed56345519e7cb8
7
+ data.tar.gz: 3df65259b967710e7454a5ce87f926b72e8d46a3341974ed84b35e2091b3906b56ce20dac730517e03416a612f1c1251b30a4febafb64f432cf3a395b7fbba11
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zetabot (0.0.22)
4
+ zetabot (1.0.0)
5
5
  actionview
6
6
  chronic
7
7
  chronic_duration
@@ -33,6 +33,7 @@ PATH
33
33
  rest-client
34
34
  tag_formatter
35
35
  tzinfo
36
+ unitwise
36
37
  video_info
37
38
  wolfram
38
39
  wolfram-alpha
@@ -79,8 +80,8 @@ GEM
79
80
  concurrent-ruby (1.0.5)
80
81
  crack (0.4.3)
81
82
  safe_yaml (~> 1.0.0)
82
- crass (1.0.2)
83
- daemons (1.2.4)
83
+ crass (1.0.3)
84
+ daemons (1.2.5)
84
85
  debugging (1.1.1)
85
86
  binding.repl (~> 3.0)
86
87
  paint (>= 0.9, < 3.0)
@@ -88,7 +89,7 @@ GEM
88
89
  thread_safe (~> 0.3, >= 0.3.1)
89
90
  destructor (0.1.0)
90
91
  diff-lcs (1.3)
91
- discourse_api (0.18.0)
92
+ discourse_api (0.19.0)
92
93
  faraday (~> 0.9)
93
94
  faraday_middleware (~> 0.10)
94
95
  rack (>= 1.6)
@@ -109,13 +110,13 @@ GEM
109
110
  faraday_middleware (0.12.2)
110
111
  faraday (>= 0.7.4, < 1.0)
111
112
  ffi (1.9.18)
112
- geocoder (1.4.4)
113
+ geocoder (1.4.5)
113
114
  gist (4.6.1)
114
- github_api (0.18.1)
115
+ github_api (0.18.2)
115
116
  addressable (~> 2.4)
116
117
  descendants_tracker (~> 0.0.4)
117
118
  faraday (~> 0.8)
118
- hashie (>= 3.4)
119
+ hashie (~> 3.5, >= 3.5.2)
119
120
  oauth2 (~> 1.0)
120
121
  haml (5.0.4)
121
122
  temple (>= 0.8.0)
@@ -128,13 +129,13 @@ GEM
128
129
  httparty (0.15.6)
129
130
  multi_xml (>= 0.5.2)
130
131
  humanize-bytes (2.2.0)
131
- i18n (0.9.0)
132
+ i18n (0.9.1)
132
133
  concurrent-ruby (~> 1.0)
133
134
  instance (0.2.0)
134
- interactive_editor (0.0.10)
135
+ interactive_editor (0.0.11)
135
136
  spoon (>= 0.0.1)
136
137
  ipaddress (0.8.3)
137
- irbtools (2.1.0)
138
+ irbtools (2.2.0)
138
139
  binding.repl (~> 3.0)
139
140
  clipboard (~> 1.1)
140
141
  code (~> 0.9)
@@ -156,6 +157,7 @@ GEM
156
157
  wirb (~> 2.0)
157
158
  iso8601 (0.9.1)
158
159
  jwt (1.5.6)
160
+ liner (0.2.4)
159
161
  loofah (2.1.1)
160
162
  crass (~> 1.0.2)
161
163
  nokogiri (>= 1.5.9)
@@ -168,9 +170,11 @@ GEM
168
170
  nokogiri (~> 1.6)
169
171
  ntlm-http (~> 0.1, >= 0.1.1)
170
172
  webrobots (>= 0.0.9, < 0.2)
173
+ memoizable (0.4.2)
174
+ thread_safe (~> 0.3, >= 0.3.1)
171
175
  method_locator (0.0.4)
172
176
  method_source (0.9.0)
173
- methodfinder (2.1.0)
177
+ methodfinder (2.1.1)
174
178
  mime-types (3.1)
175
179
  mime-types-data (~> 3.2015)
176
180
  mime-types-data (3.2016.0521)
@@ -199,7 +203,8 @@ GEM
199
203
  ruby-ll (~> 2.1)
200
204
  ori (0.1.0)
201
205
  os (1.0.0)
202
- paint (2.0.0)
206
+ paint (2.0.1)
207
+ parslet (1.8.1)
203
208
  pdf-reader (2.0.0)
204
209
  Ascii85 (~> 1.0.0)
205
210
  afm (~> 0.2.1)
@@ -207,7 +212,7 @@ GEM
207
212
  ruby-rc4
208
213
  ttfunk
209
214
  persist (1.0.0)
210
- public_suffix (3.0.0)
215
+ public_suffix (3.0.1)
211
216
  rack (2.0.3)
212
217
  rails-dom-testing (2.0.3)
213
218
  activesupport (>= 4.2.0)
@@ -241,6 +246,7 @@ GEM
241
246
  ruby_info (1.0.1)
242
247
  ruby_version (1.0.1)
243
248
  safe_yaml (1.0.4)
249
+ signed_multiset (0.2.1)
244
250
  spoon (0.0.6)
245
251
  ffi
246
252
  tag_formatter (0.0.3)
@@ -249,12 +255,17 @@ GEM
249
255
  tilt (2.0.8)
250
256
  time-lord (1.0.1)
251
257
  ttfunk (1.5.1)
252
- tzinfo (1.2.3)
258
+ tzinfo (1.2.4)
253
259
  thread_safe (~> 0.1)
254
260
  unf (0.1.4)
255
261
  unf_ext
256
262
  unf_ext (0.0.7.4)
257
263
  unicode-display_width (1.3.0)
264
+ unitwise (2.2.0)
265
+ liner (~> 0.2)
266
+ memoizable (~> 0.4)
267
+ parslet (~> 1.5)
268
+ signed_multiset (~> 0.2)
258
269
  video_info (2.7)
259
270
  iso8601 (~> 0.9.1)
260
271
  net_http_timeout_errors (~> 0.3.0)
data/Zeta.gemspec CHANGED
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
35
35
  spec.add_dependency 'daemons'
36
36
  spec.add_dependency 'destructor'
37
37
  spec.add_dependency 'tzinfo'
38
+ spec.add_dependency 'unitwise'
38
39
 
39
40
  spec.add_dependency 'cinch'
40
41
  spec.add_dependency 'cinch-cooldown'
data/lib/Zeta/access.rb CHANGED
@@ -30,9 +30,12 @@ module Cinch
30
30
 
31
31
  # Oper Overide
32
32
  if Config.oper_overide
33
- if user.oper
34
- user.refresh
35
- return true
33
+ # Do Not overide in #services
34
+ unless channel.to_s == "#services"
35
+ if user.oper
36
+ user.refresh
37
+ return true
38
+ end
36
39
  end
37
40
  end
38
41
 
@@ -34,8 +34,8 @@ 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 check_user(m.channel, @bot)
38
- # return m.user.notice "Sorry comrade, but there is already game going on." if @games.include?(m.channel.name)
37
+ # return m.reply "I am sorry comrade, but I do not have pistol on me." unless m.channel.ops.include?(@bot)
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
41
41
  player = m.user
@@ -47,7 +47,9 @@ module Plugins
47
47
  @games << m.channel.name
48
48
 
49
49
  turns, round_location = Array.new(2) { |i| Random.new.rand(1..6) }
50
- m.channel.action "starts a %d-turn game of Russian Roulette with %s." % [turns, player.nick]
50
+ m.channel.action "takes #{player.nick} into the back room for a #{turns} turn game"
51
+ m.action_reply "pulls out her pistol"
52
+ # m.channel.action "starts a %d-turn game of Russian Roulette with %s." % [turns, player.nick]
51
53
 
52
54
  phrases = PHRASES.dup.shuffle
53
55
 
@@ -56,20 +58,24 @@ module Plugins
56
58
  turns.times do |chamber|
57
59
  return end_game(m.channel, true) unless m.channel.users.include?(player)
58
60
  if round_location == chamber.succ
59
- m.reply "*click*"
61
+ player.notice "*click*"
60
62
  sleep 5
61
63
  m.channel.kick(player, "*BLAM*")
62
- m.reply "*BLAM*"
63
- m.channel.action "watches %s's brain splatter across the wall." % player.nick
64
+ m.channel.action "walks back into the room *Alone*"
64
65
  break
65
66
  else
66
67
  phrase = phrases.pop
67
- m.reply "*click* %s" % phrase
68
+ player.notice "*click* %s" % phrase
68
69
  end
69
70
  sleep 5
70
71
  end
71
72
 
72
- m.reply "Looks like you get to live another day." if turns < round_location
73
+ if turns < round_location
74
+ m.channel.action "walks back into the room with #{player}"
75
+ m.reply "Looks like you get to live another day."
76
+ m.channel.voice(player) # Voice the player because they survived
77
+ end
78
+
73
79
  sleep 1 if turns < round_location
74
80
  end_game(m.channel)
75
81
  end
@@ -140,9 +140,9 @@ module Plugins
140
140
  msg.reply("‡ #{node.text.lstrip.gsub(/\r|\n|\n\r/, ' ')[0..300]}")
141
141
  end
142
142
 
143
- if node = html.at_xpath('html/head/meta[@name="description"]')
144
- msg.reply("» #{node[:content].lines.first(3).join.gsub(/\r|\n|\n\r/, ' ')[0..300]}")
145
- end
143
+ # if node = html.at_xpath('html/head/meta[@name="description"]')
144
+ # msg.reply("» #{node[:content].lines.first(3).join.gsub(/\r|\n|\n\r/, ' ')[0..300]}")
145
+ # end
146
146
 
147
147
  info "[200] #{msg.user} - #{url}"
148
148
  rescue Timeout::Error
@@ -1,5 +1,8 @@
1
1
  require 'ostruct'
2
2
  require 'persist'
3
+ require 'open-uri'
4
+ require 'json'
5
+ require 'unitwise'
3
6
 
4
7
  module Plugins
5
8
  # Forecast is a Cinch plugin for getting the weather forecast.
@@ -15,7 +18,6 @@ module Plugins
15
18
  help: "Get the Weather?.\nUsage: `?weather`\nUsage: `?wx zip` `?w zip` `?setw zip` `?forecast zip`",
16
19
  )
17
20
 
18
- match /forecast (.+)/, method: :forecast
19
21
  match /w (.+)/, method: :weather
20
22
  match 'w', method: :weather
21
23
  match /setw (.+)/, method: :set_location
@@ -26,61 +28,61 @@ module Plugins
26
28
 
27
29
  #####
28
30
  def initialize(*args)
29
- @store = Persist.new( File.join(Dir.home, '.zeta', 'cache', 'weather.pstore') )
31
+ @api_src = %w{wu noaa darksky owm}
32
+ @store = Persist.new(File.join(Dir.home, '.zeta', 'cache', 'weather.pstore'))
30
33
  super
31
34
  end
32
35
 
33
- # ?forecast <location>
34
- def forecast(msg, query)
35
- location = geolookup(query)
36
- return msg.reply "No results found for #{query}." if location.nil?
37
-
38
- data = get_conditions(location)
39
- return msg.reply 'Problem getting data. Try again later.' if data.nil?
40
-
41
- msg.user.msg(weather_summary(data))
42
- end
43
-
44
36
  # ?w <location>
45
37
  def weather(msg, query=nil)
38
+ # Pull data source and scrub query
39
+ # Lookup user from pstore
46
40
  if !@store[msg.user.to_s].nil? && query.nil?
47
- location = geolookup(@store[msg.user.to_s])
41
+ stored_location, stored_source = @store[msg.user.to_s].split('::')
42
+ stored_source = @api_src.include?(stored_source) ? stored_source : 'wu'
43
+ data = send("#{stored_source}_src", stored_location)
44
+ # location = geolookup(@store[msg.user.to_s])
45
+ # data = wunderground_src(stored_location, false)
48
46
  elsif query.nil?
49
- return msg.reply 'No location set. ?setw <location>'
47
+ return msg.reply 'No location set. ?setw <location> :(wu|darkscy|noaa|apixu|owm)'
50
48
  else
51
- location = geolookup(query)
49
+ # data = wu_src(query, true)
50
+ src = query[/:\w+/].gsub(/:/, '') if query[/:\w+/]
51
+ query = query.gsub(/:\w+/, '').strip if query
52
+ true_src = @api_src.include?(src) ? src : 'wu'
53
+ data = send("#{true_src}_src", query)
52
54
  end
53
- return msg.reply "No results found for #{query}." if location.nil?
54
-
55
- data = get_conditions(location)
56
- return msg.reply 'Problem getting data. Try again later.' if data.nil?
57
-
58
- #[ Clarkston, WA, United States | Cloudy | Temp: 34 F (1 C) | Humidity: 73% | Winds: 8 mph ]
59
- reply_data = "∴ #{data.county}, #{data.country} " \
60
- "≈ #{data.weather} #{data.temperature} " \
61
- "≈ Feels like #{data.feels_like} " \
62
- "≈ Humidity: #{data.relative_humidity} " \
63
- "≈ Pressure: #{data.pressure_in} psi (#{data.pressure_mb} mb) " \
64
- "≈ Wind: #{data.wind} ≈ Alerts: #{data.alerts} ∴"
65
- msg.reply(reply_data)
55
+ # return msg.reply "No results found for #{query}." if data.nil?
56
+ # return msg.reply 'Problem getting data. Try again later.' if data.nil?
57
+ msg.reply(data.reply)
66
58
  end
67
59
 
68
60
  # ?setw <location>
69
- def set_location(msg,query)
70
- location = geolookup(query)
71
- return msg.reply "No results found for #{query}." if location.nil?
72
- @store[msg.user.to_s] = query unless location.nil?
73
- data = get_conditions(location)
74
- msg.reply "Your location is now set to #{data.county}, #{data.country}!"
61
+ def set_location(msg, query)
62
+ # Establish source
63
+ src = query[/:\w+/].gsub(/:/, '') if query[/:\w+/]
64
+ query = query.gsub(/:\w+/, '').strip if query
65
+
66
+ # Sanity Check
67
+ true_src = @api_src.include?(src) ? src : 'wu'
68
+ data = send("#{true_src}_src", query)
69
+
70
+ # Error
71
+ return msg.reply "No results found for #{query}." if data.nil?
72
+
73
+ # Store and display general location
74
+ serial_location = "#{query}::#{src}"
75
+ @store[msg.user.to_s] = serial_location unless data.nil?
76
+ msg.reply "Your location is now set to #{data.ac.name}, #{data.ac.c}!"
75
77
  end
76
78
 
77
79
  # ?hurricane
78
80
  def hurricane(msg)
79
81
  url = URI.encode "http://api.wunderground.com/api/#{Zsec.wunderground}/currenthurricane/view.json"
80
82
  location = JSON.parse(
81
- # RestClient.get(url)
82
- open(url).read
83
- )
83
+ # RestClient.get(url)
84
+ open(url).read
85
+ )
84
86
  return msg.reply "No results found for #{query}." if location.nil?
85
87
  reply_msg = "∴ #{location['currenthurricane'][0]['stormInfo']['stormName_Nice']} " \
86
88
  "(#{location['currenthurricane'][0]['stormInfo']['stormNumber']}) "\
@@ -94,13 +96,13 @@ module Plugins
94
96
  end
95
97
 
96
98
  # ?almanac <location>
97
- def almanac(msg,locale)
98
- autocomplete = JSON.parse( open(URI.encode("http://autocomplete.wunderground.com/aq?query=#{locale}")).read )
99
+ def almanac(msg, locale)
100
+ autocomplete = JSON.parse(open(URI.encode("http://autocomplete.wunderground.com/aq?query=#{locale}")).read)
99
101
  url = URI.encode("http://api.wunderground.com/api/#{Config.secrets[:wunderground]}/almanac/#{autocomplete['RESULTS'][0]['l']}.json")
100
102
  location = JSON.parse(
101
- # RestClient.get(url)
102
- open(url).read
103
- )
103
+ # RestClient.get(url)
104
+ open(url).read
105
+ )
104
106
  return msg.reply "No results found for #{query}." if location.nil?
105
107
 
106
108
  time = Time.now()
@@ -130,70 +132,139 @@ module Plugins
130
132
 
131
133
 
132
134
  # -private
133
- def geolookup(locale)
134
- autocomplete = JSON.parse( open(URI.encode("http://autocomplete.wunderground.com/aq?query=#{locale}")).read )
135
- url = URI.encode("http://api.wunderground.com/api/#{Config.secrets[:wunderground]}/geolookup/#{autocomplete['RESULTS'][0]['l']}.json")
136
- location = JSON.parse(
137
- open(url).read
135
+ private
136
+ #### Weather Sources
137
+ # Weather Underground - https://wunderground.com
138
+ def wu_src(location)
139
+ # Fuzzy location lookup
140
+ ac = JSON.parse(
141
+ open(URI.encode("https://autocomplete.wunderground.com/aq?query=#{location}")).read,
142
+ object_class: OpenStruct
143
+ )
144
+ ac = ac.RESULTS[0]
145
+ geolookup = JSON.parse(
146
+ open(URI.encode("https://api.wunderground.com/api/#{Config.secrets[:wunderground]}/geolookup/#{ac.l}.json")).read,
147
+ object_class: OpenStruct
148
+ ).location.l rescue nil
149
+ # Get Data
150
+ data = JSON.parse(
151
+ open("https://api.wunderground.com/api/#{Config.secrets[:wunderground]}/alerts/conditions#{geolookup}.json").read,
152
+ object_class: OpenStruct
138
153
  )
139
- location['location']['l']
140
- rescue
141
- nil
154
+
155
+ debug "DATA: #{data}"
156
+ data.ac = ac
157
+ current = data.current_observation
158
+ alerts = data.alerts.empty? ? 'none' : data.alerts.map {|l| l['type']}.join(',')
159
+ pressure_si = current.pressure_mb.to_i / 10
160
+
161
+ data.reply = "WU ∴ #{ac.name}, #{ac.c} " \
162
+ "≈ #{current.weather} #{current.temperature_string} " \
163
+ "≈ Feels like #{current.feelslike_string} " \
164
+ "≈ Humidity: #{current.relative_humidity} " \
165
+ "≈ Pressure: #{current.pressure_in} psi (#{pressure_si} kPa) " \
166
+ "≈ Wind: #{current.wind_string} ≈ Alerts: #{alerts} ∴"
167
+ return data
168
+ # rescue
169
+ # return nil
142
170
  end
143
171
 
144
- def get_conditions(location)
172
+ # Open Weather map - https://openweathermap.org/api
173
+ def owm_src(location)
174
+ ac = JSON.parse(
175
+ open(URI.encode("https://autocomplete.wunderground.com/aq?query=#{location}")).read,
176
+ object_class: OpenStruct
177
+ )
178
+ ac = ac.RESULTS[0]
145
179
  data = JSON.parse(
146
- open("http://api.wunderground.com/api/#{Config.secrets[:wunderground]}/alerts/conditions#{location}.json").read
180
+ open(
181
+ URI.encode("https://api.openweathermap.org/data/2.5/weather?lat=#{ac.lat}&lon=#{ac.lon}&APPID=#{Config.secrets[:owm]}")
182
+ ).read,
183
+ object_class: OpenStruct
184
+ )
185
+
186
+ temp = Unitwise(data.main.temp, 'K') # Data is given in kelvin
187
+ pressure = Unitwise(data.main.pressure, '[psi]')
188
+ wind = Unitwise(data.wind.speed, 'kilometer')
189
+
190
+ data.reply = "OWM ∴ #{ac.name}, #{ac.c} " \
191
+ "≈ #{data.weather[0].description}, #{temp.convert_to('[degF]').to_i.round(2)} F (#{temp.convert_to('Cel').to_i.round(2)} C) " \
192
+ "≈ Humidity: #{data.main.humidity}% " \
193
+ "≈ Pressure: #{pressure.to_i.round(2)} psi (#{pressure.convert_to('kPa').to_i.round(2)} kPa) " \
194
+ "≈ Wind: #{wind.convert_to('mile').to_i.round(2)} mph (#{wind.to_i.round(2)} km/h) ∴"
195
+
196
+ return data
197
+
198
+ end
199
+
200
+ # DarkSky - https://darksky.net/dev
201
+ def darksky_src(location)
202
+ ac = JSON.parse(
203
+ open(URI.encode("https://autocomplete.wunderground.com/aq?query=#{location}")).read,
204
+ object_class: OpenStruct
147
205
  )
148
- current = data['current_observation']
149
- alerts = data['alerts'].empty? ? 'none' : data['alerts'].map { |l| l['type'] }.join(',')
150
- location_data = current['display_location']
151
-
152
- OpenStruct.new(
153
- county: location_data['full'],
154
- country: location_data['country'],
155
-
156
- lat: location_data['latitude'],
157
- lng: location_data['longitude'],
158
-
159
- observation_time: current['observation_time'],
160
- weather: current['weather'],
161
- temp_fahrenheit: current['temp_f'],
162
- temp_celcius: current['temp_c'],
163
- temperature: current['temperature_string'],
164
- relative_humidity: current['relative_humidity'],
165
- feels_like: current['feelslike_string'],
166
- uv_level: current['UV'],
167
-
168
- wind: current['wind_string'],
169
- wind_direction: current['wind_dir'],
170
- wind_degrees: current['wind_degrees'],
171
- wind_mph: current['wind_mph'],
172
- wind_gust_mph: current['wind_gust_mph'],
173
- wind_kph: current['wind_kph'],
174
- pressure_in: current['pressure_in'],
175
- pressure_mb: current['pressure_mb'],
176
-
177
- alerts: alerts,
178
-
179
- forecast_url: current['forecast_url']
206
+ ac = ac.RESULTS[0]
207
+ data = JSON.parse(
208
+ open(
209
+ URI.encode("https://api.darksky.net/forecast/#{Config.secrets[:darksky]}/#{ac.lat},#{ac.lon}")
210
+ ).read,
211
+ object_class: OpenStruct
180
212
  )
181
- rescue
182
- nil
213
+ data.ac = ac
214
+ current = data.currently
215
+ alerts = data.alerts.count rescue 0
216
+ c = Unitwise(current.temperature, '[degF]').convert_to('Cel').to_i
217
+ c_feels = Unitwise(current.apparentTemperature, '[degF]').convert_to('Cel').to_i
218
+ p = Unitwise(current.pressure, '[psi]').convert_to('kPa').to_i
219
+ gusts = Unitwise(current.windGust, 'mile').convert_to('kilometer').to_i
220
+
221
+ tempstring = "#{current.temperature.to_i} F (#{c} C)"
222
+ feelslike = "#{current.apparentTemperature.to_i} F (#{c_feels} C)"
223
+
224
+ data.reply = "DS ∴ #{ac.name}, #{ac.c} " \
225
+ "≈ #{current.summary} #{tempstring} " \
226
+ "≈ Feels like #{feelslike} " \
227
+ "≈ Humidity: #{current.relative_humidity} " \
228
+ "≈ Pressure: #{current.pressure} psi (#{p} kPa) " \
229
+ "≈ Wind: gusts upto #{current.windGust} mph (#{gusts} km/h) ≈ Alerts: #{alerts} ∴"
230
+
231
+ return data
232
+ # rescue
233
+ # return nil
183
234
  end
184
235
 
185
- def weather_summary(data)
186
- %Q{
187
- Forecast for: #{data.county}, #{data.country}
188
- Latitude: #{data.lat}, Longitude: #{data.lng}
189
- Weather is #{data.weather}, #{data.feels_like}
190
- UV: #{data.uv_level}, Humidity: #{data.relative_humidity}
191
- Wind: #{data.wind}
192
- Direction: #{data.wind_direction}, Degrees: #{data.wind_degrees},
193
- #{data.observation_time}
194
- More Info: #{data.forecast_url}}
195
- rescue
196
- 'Problem fetching the weather summary. Try again later.'
236
+ # NOAA - https://graphical.weather.gov/xml/
237
+ def noaa_src(location)
238
+ ac = JSON.parse(
239
+ open(URI.encode("https://autocomplete.wunderground.com/aq?query=#{location}")).read,
240
+ object_class: OpenStruct
241
+ )
242
+ ac = ac.RESULTS[0]
243
+ stations = JSON.parse(
244
+ open(URI.encode("https://api.weather.gov/points/#{ac.lat},#{ac.lon}/stations/")).read)
245
+ parsed = JSON.parse(
246
+ open(URI.encode("#{stations['observationStations'][0]}/observations/current")).read,
247
+ object_class: OpenStruct
248
+ )
249
+
250
+ data = parsed.properties
251
+ data.ac = ac
252
+ f = data.temperature.value * 9/5
253
+ temp = "#{f.round(2)} F (#{data.temperature.value.to_i.round(2)} C) "
254
+ wind = "Gusts: #{data.windGust.value} avg: #{data.windSpeed.value.to_i.round(2)}"
255
+ feelslike = "#{data.windChill.value.to_i.round(2)} C"
256
+ pressure_in = ((data.barometricPressure.value.to_i * 0.00014503773773) * 100).round(2)
257
+ pressure = (data.barometricPressure.value.to_i / 100).round(2)
258
+
259
+ data.reply = "NOAA ∴ #{ac.name} " \
260
+ "≈ #{data.textDescription} #{temp} " \
261
+ "≈ Feels like #{feelslike} " \
262
+ "≈ Humidity: #{data.relativeHumidity.value.round(2)} " \
263
+ "≈ Pressure: #{pressure_in} psi (#{pressure} kPa) " \
264
+ "≈ Wind: #{wind} ≈ Alerts: ∴"
265
+ return data
266
+ # rescue
267
+ # data.reply = "Error fetching data"
197
268
  end
198
269
 
199
270
  end
data/lib/Zeta/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Zeta
2
- VERSION = '0.0.22'
2
+ VERSION = '1.0.0'
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: 0.0.22
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liothen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-18 00:00:00.000000000 Z
11
+ date: 2017-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: unitwise
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: cinch
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -603,7 +617,6 @@ files:
603
617
  - lib/Zeta/plugins/gem.rb
604
618
  - lib/Zeta/plugins/gif.rb
605
619
  - lib/Zeta/plugins/help.rb
606
- - lib/Zeta/plugins/libsecure.rb
607
620
  - lib/Zeta/plugins/macros.rb
608
621
  - lib/Zeta/plugins/movie.rb
609
622
  - lib/Zeta/plugins/pdfinfo.rb
@@ -1,34 +0,0 @@
1
- require 'uri'
2
- require 'net/http'
3
- require 'ostruct'
4
- require 'discourse_api'
5
- require 'action_view'
6
-
7
- module Plugins
8
- class Libsecure
9
- include Cinch::Plugin
10
- include Cinch::Helpers
11
- include ActionView::Helpers::DateHelper
12
-
13
- enable_acl(:nobody)
14
-
15
- self.plugin_name = 'DarkScience #libsecure'
16
- self.help = '?latest'
17
-
18
- match 'latest', method: :fetch_latest
19
-
20
- def fetch_latest(m)
21
- return unless m.channel == '#libsecure' || m.channel == '#bots'
22
-
23
- client = DiscourseApi::Client.new('https://libsecure.so', Config.secrets[:libsecure], Config.secrets[:libsecure_user] )
24
- parser = client.latest_topics.sort_by { |hash| hash['last_posted_at'] }
25
- data = parser.last
26
-
27
- m.reply "Latest → #{data['title']} -- https://libsecure.so/t/#{data['id']}"
28
- end
29
-
30
- end
31
- end
32
-
33
- # AutoLoad
34
- Bot.config.plugins.plugins.push Plugins::Libsecure