zetabot 2.0.8 → 2.0.9

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
  SHA256:
3
- metadata.gz: 8db9cc936475a5e7e21340224aa39b92ff76577124d1471f87fd7f8c7c1dc47e
4
- data.tar.gz: bd331a8c2bc1e2ea13c9d92bcae1a9941d8a573a3c35e7ea22a47f12105a1227
3
+ metadata.gz: 5ca813b62e8520169331f3e978e82d7ae782c96727362bc21125cd973e164b8a
4
+ data.tar.gz: f34bf6917e3015268b7dfd16684731a79ba27f987810b1fcd2ad59a9d4609071
5
5
  SHA512:
6
- metadata.gz: 0c357cc89ea106c23fd46062583bd4b1940b0ee507baa001f7847839bdda3c938cdd069f2cd075a37d618f5d9d3cb5f1bfbd57f0c814dc67814548b15085ed1d
7
- data.tar.gz: 75fa53a200ac74e00c32ea2042c89aac7e30d18d5cc4540eb328b8fd06e61bb001e0aa1f58c44028986eba4312b8a1b4a387f4319080d0ac036412b4238687b8
6
+ metadata.gz: 2965b9a7c3858b703d606cb444bf76ce707a105dda0c2a51335d255b209264cf94abe44e626658d55baab6da14e4274764edda230da117c2a7a60dedd6ab67fb
7
+ data.tar.gz: b632e398611d098b88ac692f88c0c7833900a1117e773685c8c869926b0c4832c14b1052904a235677b65aea85131851d1b9b85ab224d12fab62f6c1c1e8d86b
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.7.6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zetabot (2.0.7)
4
+ zetabot (2.0.9)
5
5
  actionview
6
6
  chronic
7
7
  chronic_duration
@@ -205,7 +205,6 @@ GEM
205
205
  mime-types (3.4.1)
206
206
  mime-types-data (~> 3.2015)
207
207
  mime-types-data (3.2022.0105)
208
- mini_portile2 (2.8.0)
209
208
  minitest (5.15.0)
210
209
  mkfifo (0.1.1)
211
210
  multi_json (1.15.0)
@@ -216,8 +215,7 @@ GEM
216
215
  connection_pool (~> 2.2)
217
216
  net_http_timeout_errors (0.3.5)
218
217
  netrc (0.11.0)
219
- nokogiri (1.13.6)
220
- mini_portile2 (~> 2.8.0)
218
+ nokogiri (1.13.6-x86_64-darwin)
221
219
  racc (~> 1.4)
222
220
  numerizer (0.1.1)
223
221
  oauth2 (1.4.9)
@@ -318,7 +316,7 @@ PLATFORMS
318
316
  ruby
319
317
 
320
318
  DEPENDENCIES
321
- bundler (~> 1.11)
319
+ bundler (~> 2.3)
322
320
  irbtools
323
321
  rake (~> 10.0)
324
322
  rspec (~> 3.0)
data/Zeta.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
- spec.add_development_dependency "bundler", "~> 1.11"
30
+ spec.add_development_dependency "bundler", "~> 2.3"
31
31
  spec.add_development_dependency "rake", "~> 10.0"
32
32
  spec.add_development_dependency "rspec", "~> 3.0"
33
33
  spec.add_development_dependency "irbtools"
@@ -23,7 +23,7 @@ module Plugins
23
23
  def fetch_random_fml
24
24
  url = 'http://www.fmylife.com/random'
25
25
  # fml_story = Nokogiri.HTML(RestClient.get(url)).at('div.article').text.strip
26
- fml_story = Nokogiri.HTML(open(url).read).at('div.article').text.strip
26
+ fml_story = Nokogiri.HTML(RestClient.get(url).body).at('div.article').text.strip
27
27
  fml_story[/^Today, (.+) FML/]
28
28
  rescue => e
29
29
  e.message
@@ -33,8 +33,10 @@ module Plugins
33
33
  private
34
34
 
35
35
  def search(query)
36
- url = URI.encode "http://www.gifbin.com/search/#{query}/"
37
- doc = Nokogiri::HTML( open(url) )
36
+ parser = URI::Parser.new
37
+ url = parser.escape "http://www.gifbin.com/search/#{query}/"
38
+
39
+ doc = Nokogiri::HTML( RestClient.get(url).body )
38
40
  e = doc.css('.thumbs li').length
39
41
  return "No Results Found" if e == 0
40
42
  result = doc.css('.thumbs li')[rand(e)].css('a img').attribute('src').text.gsub(/tn_/, '')
@@ -42,16 +44,20 @@ module Plugins
42
44
  end
43
45
 
44
46
  def gifbin
45
- url = URI.encode 'http://www.gifbin.com/random'
46
- doc = Nokogiri.HTML(open url)
47
+ parser = URI::Parser.new
48
+
49
+ url = parser.escape 'http://www.gifbin.com/random'
50
+ doc = Nokogiri.HTML(RestClient.get(url).body)
47
51
  doc.css('div#gifcontainer a img').attribute('src').text
48
52
  end
49
53
 
50
54
  def imgur
51
55
  # Cache results for 1 hour
52
56
  if @imgurray.empty? || @last_update >= (Time.now + 3600)
53
- url = URI.encode('http://reddit.com/r/gifs.json')
54
- doc = JSON.load(open(url))
57
+ parser = URI::Parser.new
58
+
59
+ url = parser.escape('http://reddit.com/r/gifs.json')
60
+ doc = JSON.load(RestClient.get(url).body)
55
61
 
56
62
  doc['data']['children'].each_with_index do |post, index|
57
63
  if doc['data']['children'][index]['data']['url'].to_s =~ /imgur/
@@ -25,11 +25,14 @@ module Plugins
25
25
 
26
26
  private
27
27
  def query_movie(m)
28
+ parser = URI::Parser.new
29
+
28
30
  year = m[/:\d+/].gsub(/:/, '') if m[/:\d+/]
29
- movie = URI.encode(m.gsub(/:\d+/, ''))
31
+ movie = parser.escape(m.gsub(/:\d+/, ''))
32
+
30
33
  data = JSON.parse(
31
34
  # RestClient.get("http://www.omdbapi.com/?t=#{movie}&y=#{year}")
32
- open("http://www.omdbapi.com/?t=#{movie}&y=#{year}&apikey=#{Config.secrets[:omdb]}").read
35
+ RestClient.get("http://www.omdbapi.com/?t=#{movie}&y=#{year}&apikey=#{Config.secrets[:omdb]}").body
33
36
  )
34
37
  OpenStruct.new(
35
38
  title: data['Title'],
@@ -51,8 +51,9 @@ module Plugins
51
51
  react_on: :channel
52
52
 
53
53
  def execute(msg, url)
54
+ parser = URI::Parser.new
54
55
  url = "http://#{url}" unless url=~/^https?:\/\//
55
- url = URI.encode(url)
56
+ url = parser.escape(url)
56
57
 
57
58
  # Ignore items on blacklist
58
59
  # blacklist = DEFAULT_BLACKLIST.dup
@@ -23,10 +23,11 @@ module Plugins
23
23
 
24
24
 
25
25
  def wotd(m)
26
- url = URI.encode "http://www.urbandictionary.com/"
26
+ parser = URI::Parser.new
27
+ url = parser.escape("http://www.urbandictionary.com/")
28
+
27
29
  doc = Nokogiri.HTML(
28
- # RestClient.get(url)
29
- open(url)
30
+ RestClient.get(url).body
30
31
  )
31
32
  word = doc.at_css('.word').text.strip[0..40]
32
33
  meaning = doc.at_css('.meaning').text.strip[0..450] + "... \u263A"
@@ -35,13 +36,12 @@ module Plugins
35
36
 
36
37
  private
37
38
  def search(query)
38
- url = URI.encode "http://api.urbandictionary.com/v0/define?term=#{query}"
39
- # Nokogiri.HTML(open url).at_css('.meaning').text.strip[0..500]
39
+ parser = URI::Parser.new
40
+ url = parser.escape "http://api.urbandictionary.com/v0/define?term=#{query}"
40
41
 
41
42
  # Load API data
42
43
  data = JSON.parse(
43
- #RestClient.get(url)
44
- open(url).read
44
+ RestClient.get(url).body
45
45
  )
46
46
 
47
47
  # Return if nothing is found
@@ -87,9 +87,9 @@ module Plugins
87
87
  location = CGI.escape(location)
88
88
 
89
89
  ac = JSON.parse(
90
- open(
90
+ RestClient.get(
91
91
  "https://maps.googleapis.com/maps/api/geocode/json?address=#{location}&key=#{Config.secrets[:google]}"
92
- ).read, object_class: OpenStruct
92
+ ).body, object_class: OpenStruct
93
93
  )
94
94
 
95
95
  return nil if ac.results.nil? ## Unable to locate
@@ -100,8 +100,8 @@ module Plugins
100
100
 
101
101
  # Get Data
102
102
  data = JSON.parse(
103
- open("https://api.openweathermap.org/data/2.5/weather?lat=#{lat}&lon=#{lon}&APPID=#{Config.secrets[:owm]}"
104
- ).read, object_class: OpenStruct
103
+ RestClient.get("https://api.openweathermap.org/data/2.5/weather?lat=#{lat}&lon=#{lon}&APPID=#{Config.secrets[:owm]}"
104
+ ).body, object_class: OpenStruct
105
105
  )
106
106
 
107
107
  temp = Unitwise(data.main.temp, 'K') # Data is given in kelvin
@@ -124,7 +124,7 @@ module Plugins
124
124
  location = CGI.escape(location)
125
125
 
126
126
  ac = JSON.parse(
127
- open("https://maps.googleapis.com/maps/api/geocode/json?address=#{location}&key=#{Config.secrets[:google]}").read,
127
+ RestClient.get("https://maps.googleapis.com/maps/api/geocode/json?address=#{location}&key=#{Config.secrets[:google]}").body,
128
128
  object_class: OpenStruct
129
129
  )
130
130
  return nil if ac.results.nil? ## Unable to locate
@@ -134,7 +134,7 @@ module Plugins
134
134
  lon = ac.geometry.location.lng
135
135
 
136
136
  data = JSON.parse(
137
- open("https://api.darksky.net/forecast/#{Config.secrets[:darksky]}/#{lat},#{lon}").read,
137
+ RestClient.get("https://api.darksky.net/forecast/#{Config.secrets[:darksky]}/#{lat},#{lon}").body,
138
138
  object_class: OpenStruct
139
139
  )
140
140
  data.ac = ac
@@ -165,7 +165,7 @@ module Plugins
165
165
  location = CGI.escape(location)
166
166
 
167
167
  ac = JSON.parse(
168
- open("https://maps.googleapis.com/maps/api/geocode/json?address=#{location}&key=#{Config.secrets[:google]}").read,
168
+ RestClient.get("https://maps.googleapis.com/maps/api/geocode/json?address=#{location}&key=#{Config.secrets[:google]}").body,
169
169
  object_class: OpenStruct
170
170
  )
171
171
  return nil if ac.results.nil? ## Unable to locate
@@ -175,13 +175,13 @@ module Plugins
175
175
  lon = ac.geometry.location.lng
176
176
 
177
177
  stations = JSON.parse(
178
- open("https://api.weather.gov/points/#{lat},#{lon}/stations/").read
178
+ RestClient.get("https://api.weather.gov/points/#{lat},#{lon}/stations/").body
179
179
  ) rescue nil
180
180
 
181
181
  return nil if stations.nil? ## Unable to find station. probably not in the USA
182
182
 
183
183
  parsed = JSON.parse(
184
- open("#{CGI.escape(stations['observationStations'][0])}/observations/current").read,
184
+ RestClient.get("#{CGI.escape(stations['observationStations'][0])}/observations/current").body,
185
185
  object_class: OpenStruct
186
186
  )
187
187
 
@@ -20,7 +20,7 @@ module Plugins
20
20
  # Rescue in case something goes wrong
21
21
  begin
22
22
  url = "http://api.wolframalpha.com/v2/query?input=#{CGI.escape(query)}&appid=#{Config.secrets[:wolfram]}&primary=true&format=plaintext"
23
- request = open(url).read
23
+ request = RestClient.get(url).body
24
24
 
25
25
  data = Crack::XML.parse(request)
26
26
 
data/lib/Zeta/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Zeta
2
- VERSION = '2.0.8'
2
+ VERSION = '2.0.9'
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: 2.0.8
4
+ version: 2.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liothen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-11 00:00:00.000000000 Z
11
+ date: 2022-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.11'
19
+ version: '2.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.11'
26
+ version: '2.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -566,6 +566,7 @@ extra_rdoc_files: []
566
566
  files:
567
567
  - ".bundle/config"
568
568
  - ".gitignore"
569
+ - ".tool-versions"
569
570
  - Gemfile
570
571
  - Gemfile.lock
571
572
  - LICENSE.txt