zetabot 1.0.2 → 1.0.3

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
- SHA1:
3
- metadata.gz: 6e927c6006c02faf5117ec11d11d0c5c6896d0cf
4
- data.tar.gz: 391a22bac0fdafcc528ae60394cf4fde8def9c9d
2
+ SHA256:
3
+ metadata.gz: 2dd3327d9406e8bace63344c59915b050f1d299c020158b37002b3ab1173ec2e
4
+ data.tar.gz: ee405d6b921baeff3a733b4ef4099ac9008fd813886bdd5fa5542d0b82151bf7
5
5
  SHA512:
6
- metadata.gz: 7b30608cb81f2a3d1bbf764bb87815e59de214f4ff146a0bd09721070ccf13f2bc64c072b6735f6c12039e49222c09fe7e1c96f81edc3edb2e53c4693444964e
7
- data.tar.gz: 03466234cd8842f36e3f86ab48828077013cd9d8c33a4304b77e42ffbb0bbcf26959829a0c11e644750e9310d16e5ee4958fd7ab7b9eae45fc528389a42d5f44
6
+ metadata.gz: e273343279ae3027037db881aa019d62d44c235b13789797fa9bcb12537bbefd8505b74d11e60ea6a55c004e44ec70ed94068477ca4fa282ff01b82e29b0f283
7
+ data.tar.gz: cad11ac72c558ad148d0c15704f5bae925adcd76a80d5db2372a1658e4beaadd12d127afd0caa9b247adeabdf473b48062846d3e16a7ea1ff9e7c1f4953355df
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zetabot (1.0.1)
4
+ zetabot (1.0.2)
5
5
  actionview
6
6
  chronic
7
7
  chronic_duration
@@ -81,7 +81,7 @@ GEM
81
81
  crack (0.4.3)
82
82
  safe_yaml (~> 1.0.0)
83
83
  crass (1.0.3)
84
- daemons (1.2.5)
84
+ daemons (1.2.6)
85
85
  debugging (1.1.1)
86
86
  binding.repl (~> 3.0)
87
87
  paint (>= 0.9, < 3.0)
@@ -89,7 +89,7 @@ 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.19.0)
92
+ discourse_api (0.20.0)
93
93
  faraday (~> 0.9)
94
94
  faraday_middleware (~> 0.10)
95
95
  rack (>= 1.6)
@@ -111,7 +111,7 @@ GEM
111
111
  faraday (>= 0.7.4, < 1.0)
112
112
  ffi (1.9.18)
113
113
  geocoder (1.4.5)
114
- gist (4.6.1)
114
+ gist (4.6.2)
115
115
  github_api (0.18.2)
116
116
  addressable (~> 2.4)
117
117
  descendants_tracker (~> 0.0.4)
@@ -122,14 +122,14 @@ GEM
122
122
  temple (>= 0.8.0)
123
123
  tilt
124
124
  hashery (2.1.2)
125
- hashie (3.5.6)
125
+ hashie (3.5.7)
126
126
  hirb (0.7.3)
127
127
  http-cookie (1.0.3)
128
128
  domain_name (~> 0.5)
129
129
  httparty (0.15.6)
130
130
  multi_xml (>= 0.5.2)
131
131
  humanize-bytes (2.2.0)
132
- i18n (0.9.1)
132
+ i18n (0.9.3)
133
133
  concurrent-ruby (~> 1.0)
134
134
  instance (0.2.0)
135
135
  interactive_editor (0.0.11)
@@ -179,9 +179,9 @@ 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.10.3)
182
+ minitest (5.11.1)
183
183
  mkfifo (0.1.1)
184
- multi_json (1.12.2)
184
+ multi_json (1.13.1)
185
185
  multi_xml (0.6.0)
186
186
  multipart-post (2.0.0)
187
187
  net-http-digest_auth (1.4.1)
@@ -198,7 +198,7 @@ GEM
198
198
  multi_json (~> 1.3)
199
199
  multi_xml (~> 0.5)
200
200
  rack (>= 1.2, < 3)
201
- oga (2.11)
201
+ oga (2.13)
202
202
  ast
203
203
  ruby-ll (~> 2.1)
204
204
  ori (0.1.0)
@@ -229,7 +229,7 @@ GEM
229
229
  rspec-core (~> 3.7.0)
230
230
  rspec-expectations (~> 3.7.0)
231
231
  rspec-mocks (~> 3.7.0)
232
- rspec-core (3.7.0)
232
+ rspec-core (3.7.1)
233
233
  rspec-support (~> 3.7.0)
234
234
  rspec-expectations (3.7.0)
235
235
  diff-lcs (>= 1.2.0, < 2.0)
@@ -271,7 +271,7 @@ GEM
271
271
  net_http_timeout_errors (~> 0.3.0)
272
272
  oga (~> 2.7)
273
273
  webrobots (0.1.2)
274
- wirb (2.1.1)
274
+ wirb (2.1.2)
275
275
  paint (>= 0.9, < 3.0)
276
276
  wolfram (0.2.1)
277
277
  nokogiri (>= 1.4.3)
@@ -289,4 +289,4 @@ DEPENDENCIES
289
289
  zetabot!
290
290
 
291
291
  BUNDLED WITH
292
- 1.16.0
292
+ 1.16.1
@@ -23,8 +23,6 @@ module Plugins
23
23
  match /setw (.+)/, method: :set_location
24
24
  match /wx (.+)/, method: :weather
25
25
  match /weather (.+)/, method: :weather
26
- match /almanac (.+)/, method: :almanac
27
- match /hurricane/, method: :hurricane
28
26
 
29
27
  #####
30
28
  def initialize(*args)
@@ -76,76 +74,30 @@ module Plugins
76
74
  msg.reply "Your location is now set to #{data.ac.name}, #{data.ac.c}!"
77
75
  end
78
76
 
79
- # ?hurricane
80
- def hurricane(msg)
81
- url = URI.encode "http://api.wunderground.com/api/#{Zsec.wunderground}/currenthurricane/view.json"
82
- location = JSON.parse(
83
- # RestClient.get(url)
84
- open(url).read
85
- )
86
- return msg.reply "No results found for #{query}." if location.nil?
87
- reply_msg = "∴ #{location['currenthurricane'][0]['stormInfo']['stormName_Nice']} " \
88
- "(#{location['currenthurricane'][0]['stormInfo']['stormNumber']}) "\
89
- "≈ Category #{location['currenthurricane'][0]['Current']['SaffirSimpsonCategory']} " \
90
- "≈ Wind #{location['currenthurricane'][0]['Current']['WindSpeed']['Mph']} mph " \
91
- "(#{location['currenthurricane'][0]['Current']['WindSpeed']['Kph']} kph) " \
92
- "≈ Wind Gust #{location['currenthurricane'][0]['Current']['WindGust']['Mph']} mph " \
93
- "(#{location['currenthurricane'][0]['Current']['WindGust']['Kph']} kph) " \
94
- "≈ #{location['currenthurricane'][0]['Current']['Time']['pretty']} ∴"
95
- msg.reply(reply_msg)
96
- end
97
-
98
- # ?almanac <location>
99
- def almanac(msg, locale)
100
- autocomplete = JSON.parse(open(URI.encode("http://autocomplete.wunderground.com/aq?query=#{locale}")).read)
101
- url = URI.encode("http://api.wunderground.com/api/#{Config.secrets[:wunderground]}/almanac/#{autocomplete['RESULTS'][0]['l']}.json")
102
- location = JSON.parse(
103
- # RestClient.get(url)
104
- open(url).read
105
- )
106
- return msg.reply "No results found for #{query}." if location.nil?
107
-
108
- time = Time.now()
109
-
110
- data = OpenStruct.new(
111
- date: time.strftime('%B, %d %Y (%A) '),
112
- airport: location['almanac']['airport_code'],
113
- high_norm_f: location['almanac']['temp_high']['normal']['F'],
114
- high_norm_c: location['almanac']['temp_high']['normal']['C'],
115
- high_record_y: location['almanac']['temp_high']['recordyear'],
116
- high_record_f: location['almanac']['temp_high']['record']['F'],
117
- high_record_c: location['almanac']['temp_high']['normal']['C'],
118
- low_norm_f: location['almanac']['temp_low']['normal']['F'],
119
- low_norm_c: location['almanac']['temp_low']['normal']['C'],
120
- low_record_y: location['almanac']['temp_low']['recordyear'],
121
- low_record_f: location['almanac']['temp_low']['record']['F'],
122
- low_record_c: location['almanac']['temp_low']['normal']['C'],
123
- )
124
-
125
- reply_msg = "∴ Almanac #{data.date} ≈ Airport #{data.airport} " \
126
- "≈ Normal #{data.high_norm_f} F (#{data.high_norm_c} C) | #{data.low_norm_f} F (#{data.low_norm_c} C) " \
127
- "≈ High #{data.high_record_f} F (#{data.high_record_c} C) [#{data.high_record_y}] " \
128
- "≈ Low #{data.low_record_f} F (#{data.low_record_c} C) [#{data.low_record_y}] ∴"
129
-
130
- msg.reply(reply_msg)
131
- end
132
-
133
-
134
- # -private
135
77
  private
136
78
  #### Weather Sources
137
79
  # Weather Underground - https://wunderground.com
138
80
  def wu_src(location)
139
81
  # Fuzzy location lookup
82
+ # ac = JSON.parse(
83
+ # open(URI.encode("https://autocomplete.wunderground.com/aq?query=#{location}")).read,
84
+ # object_class: OpenStruct
85
+ # )
86
+ # return nil if ac.RESULTS.empty?
140
87
  ac = JSON.parse(
141
- open(URI.encode("https://autocomplete.wunderground.com/aq?query=#{location}")).read,
88
+ open(URI.encode("http://maps.googleapis.com/maps/api/geocode/json?address=#{location}")).read,
142
89
  object_class: OpenStruct
143
90
  )
144
- return nil if ac.RESULTS.empty?
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
145
96
 
146
- ac = ac.RESULTS[0]
97
+ # ac = ac.RESULTS[0]
147
98
  geolookup = JSON.parse(
148
- open(URI.encode("https://api.wunderground.com/api/#{Config.secrets[:wunderground]}/geolookup/#{ac.l}.json")).read,
99
+ # open(URI.encode("https://api.wunderground.com/api/#{Config.secrets[:wunderground]}/geolookup/#{ac.l}.json")).read,
100
+ open(URI.encode("https://api.wunderground.com/api/#{Config.secrets[:wunderground]}/geolookup/q/#{lat},#{lon}.json")).read,
149
101
  object_class: OpenStruct
150
102
  ).location.l rescue nil
151
103
 
@@ -155,13 +107,12 @@ module Plugins
155
107
  object_class: OpenStruct
156
108
  )
157
109
 
158
- debug "DATA: #{data}"
159
110
  data.ac = ac
160
111
  current = data.current_observation
161
112
  alerts = data.alerts.empty? ? 'none' : data.alerts.map {|l| l['type']}.join(',')
162
113
  pressure_si = Unitwise((current.pressure_in.to_f)+14.7, '[psi]').convert_to('kPa').to_f.round(2)
163
114
 
164
- data.reply = "WU ∴ #{ac.name}, #{ac.c} " \
115
+ data.reply = "WU ∴ #{ac.formatted_address} " \
165
116
  "≈ #{current.weather} #{current.temperature_string} " \
166
117
  "≈ Feels like #{current.feelslike_string} " \
167
118
  "≈ Humidity: #{current.relative_humidity} " \
@@ -0,0 +1,61 @@
1
+
2
+ require 'ostruct'
3
+ require 'persist'
4
+ require 'open-uri'
5
+ require 'json'
6
+ require 'unitwise'
7
+
8
+ module Plugins
9
+ # Forecast is a Cinch plugin for getting the weather forecast.
10
+ # @original_author Jonah Ruiz <jonah@pixelhipsters.com>
11
+ # @author Liothen <liothen@flagrun.net>
12
+ class WeatherHurricane
13
+ include Cinch::Plugin
14
+ include Cinch::Helpers
15
+ enable_acl
16
+
17
+ set(
18
+ plugin_name: "Hurricane Info",
19
+ help: "Get the Weather?.\nUsage: `?hurricane`\n",
20
+ )
21
+
22
+ match /almanac (.+)/, method: :almanac
23
+
24
+ def almanac(msg, locale)
25
+ autocomplete = JSON.parse(open(URI.encode("http://autocomplete.wunderground.com/aq?query=#{locale}")).read)
26
+ url = URI.encode("http://api.wunderground.com/api/#{Config.secrets[:wunderground]}/almanac/#{autocomplete['RESULTS'][0]['l']}.json")
27
+ location = JSON.parse(
28
+ # RestClient.get(url)
29
+ open(url).read
30
+ )
31
+ return msg.reply "No results found for #{query}." if location.nil?
32
+
33
+ time = Time.now()
34
+
35
+ data = OpenStruct.new(
36
+ date: time.strftime('%B, %d %Y (%A) '),
37
+ airport: location['almanac']['airport_code'],
38
+ high_norm_f: location['almanac']['temp_high']['normal']['F'],
39
+ high_norm_c: location['almanac']['temp_high']['normal']['C'],
40
+ high_record_y: location['almanac']['temp_high']['recordyear'],
41
+ high_record_f: location['almanac']['temp_high']['record']['F'],
42
+ high_record_c: location['almanac']['temp_high']['normal']['C'],
43
+ low_norm_f: location['almanac']['temp_low']['normal']['F'],
44
+ low_norm_c: location['almanac']['temp_low']['normal']['C'],
45
+ low_record_y: location['almanac']['temp_low']['recordyear'],
46
+ low_record_f: location['almanac']['temp_low']['record']['F'],
47
+ low_record_c: location['almanac']['temp_low']['normal']['C'],
48
+ )
49
+
50
+ reply_msg = "∴ Almanac #{data.date} ≈ Airport #{data.airport} " \
51
+ "≈ Normal #{data.high_norm_f} F (#{data.high_norm_c} C) | #{data.low_norm_f} F (#{data.low_norm_c} C) " \
52
+ "≈ High #{data.high_record_f} F (#{data.high_record_c} C) [#{data.high_record_y}] " \
53
+ "≈ Low #{data.low_record_f} F (#{data.low_record_c} C) [#{data.low_record_y}] ∴"
54
+
55
+ msg.reply(reply_msg)
56
+ end
57
+
58
+ end
59
+ end
60
+ Bot.config.plugins.plugins.push Plugins::WeatherAlmanac
61
+
@@ -0,0 +1,44 @@
1
+ require 'ostruct'
2
+ require 'persist'
3
+ require 'open-uri'
4
+ require 'json'
5
+ require 'unitwise'
6
+
7
+ module Plugins
8
+ # Forecast is a Cinch plugin for getting the weather forecast.
9
+ # @original_author Jonah Ruiz <jonah@pixelhipsters.com>
10
+ # @author Liothen <liothen@flagrun.net>
11
+ class WeatherHurricane
12
+ include Cinch::Plugin
13
+ include Cinch::Helpers
14
+ enable_acl
15
+
16
+ set(
17
+ plugin_name: "Hurricane Info",
18
+ help: "Get the Weather?.\nUsage: `?hurricane`\n",
19
+ )
20
+
21
+ match /hurricane/, method: :hurricane
22
+
23
+ def hurricane(msg)
24
+ url = URI.encode "http://api.wunderground.com/api/#{Zsec.wunderground}/currenthurricane/view.json"
25
+ location = JSON.parse(
26
+ # RestClient.get(url)
27
+ open(url).read
28
+ )
29
+ return msg.reply "No results found for #{query}." if location.nil?
30
+ reply_msg = "∴ #{location['currenthurricane'][0]['stormInfo']['stormName_Nice']} " \
31
+ "(#{location['currenthurricane'][0]['stormInfo']['stormNumber']}) "\
32
+ "≈ Category #{location['currenthurricane'][0]['Current']['SaffirSimpsonCategory']} " \
33
+ "≈ Wind #{location['currenthurricane'][0]['Current']['WindSpeed']['Mph']} mph " \
34
+ "(#{location['currenthurricane'][0]['Current']['WindSpeed']['Kph']} kph) " \
35
+ "≈ Wind Gust #{location['currenthurricane'][0]['Current']['WindGust']['Mph']} mph " \
36
+ "(#{location['currenthurricane'][0]['Current']['WindGust']['Kph']} kph) " \
37
+ "≈ #{location['currenthurricane'][0]['Current']['Time']['pretty']} ∴"
38
+ msg.reply(reply_msg)
39
+ end
40
+
41
+ end
42
+ end
43
+
44
+ Bot.config.plugins.plugins.push Plugins::WeatherHurricane
data/lib/Zeta/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Zeta
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.3'
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.2
4
+ version: 1.0.3
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-05 00:00:00.000000000 Z
11
+ date: 2018-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -627,6 +627,8 @@ files:
627
627
  - lib/Zeta/plugins/snooper.rb
628
628
  - lib/Zeta/plugins/urban.rb
629
629
  - lib/Zeta/plugins/weather.rb
630
+ - lib/Zeta/plugins/weather_almanac.rb
631
+ - lib/Zeta/plugins/weather_hurricane.rb
630
632
  - lib/Zeta/plugins/whois.rb
631
633
  - lib/Zeta/plugins/wiki.rb
632
634
  - lib/Zeta/plugins/wolfram.rb
@@ -655,7 +657,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
655
657
  version: '0'
656
658
  requirements: []
657
659
  rubyforge_project:
658
- rubygems_version: 2.6.11
660
+ rubygems_version: 2.7.4
659
661
  signing_key:
660
662
  specification_version: 4
661
663
  summary: Zeta is a IRC bot written in ruby using the Cinch Framework