zetabot 0.0.7 → 0.0.8

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: 147e2c128ff44a016567129f0ce7a01348379ff8
4
- data.tar.gz: 715df00d50bd68934a67bcb5bfa83ff0b5f0cad0
3
+ metadata.gz: 0efc452957163d009f8a24a3518abdfdadf9fa66
4
+ data.tar.gz: e2800b1af4d5766614cd99233e58ce13efd7e4f8
5
5
  SHA512:
6
- metadata.gz: dd0b11cb0e6cae2bf916a297fd204236a2179c0bc0bb67822266132add149d696e5fa826bc2694f1c336b0d00e5c49652033bd5ec96a5532f0a091920644ee83
7
- data.tar.gz: 23b301230233e16a0049d0e4f961d9b276485b2cad70038f790087b73a0caf29e2fee1d976b01f936aa0576d2918ea7c544233cfba8d88ec54939a925223fecb
6
+ metadata.gz: b5449a4aa4e51d97fd552f398752f4a0fea592d4c1ee258355428f55230d2eb8b45fc6858f229bf3efb63201e0bbe6eb62cbdba1fc7bb1dd3f5c160163fa6a83
7
+ data.tar.gz: f7d139957d49f59f597ac498e483699bb54733063f61d0ab9219af651de21c96ec0301e9cb0acf3e72d0859fad2711629b44b20459bdebfc3b0024de5cb13016
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zetabot (0.0.7)
4
+ zetabot (0.0.8)
5
5
  actionview
6
6
  chronic
7
7
  chronic_duration
@@ -26,6 +26,7 @@
26
26
  require 'video_info'
27
27
  require 'mechanize'
28
28
  require 'action_view'
29
+ require 'timeout'
29
30
 
30
31
  module Plugins
31
32
  class Snooper
@@ -121,7 +122,17 @@ module Plugins
121
122
 
122
123
  def match_other(msg,url)
123
124
  begin
124
- html = Mechanize.start { |m| Nokogiri::HTML(m.get(url).content, nil, 'utf-8') }
125
+ html = Mechanize.start { |m|
126
+ # Timeout longwinded pages
127
+ m.max_history = 1
128
+ m.read_timeout = 4
129
+ m.max_file_buffer = 2_097_152
130
+
131
+ # Parse the HTML
132
+ Timeout::timeout(10) { Nokogiri::HTML(m.get(url).content, nil, 'utf-8') }
133
+ }
134
+
135
+ # Reply Blocks
125
136
  if node = html.at_xpath("html/head/title")
126
137
  msg.reply("‡ #{node.text.lstrip.gsub(/\r|\n|\n\r/, ' ')[0..300]}")
127
138
  end
@@ -131,9 +142,13 @@ module Plugins
131
142
  end
132
143
 
133
144
  info "[200] #{msg.user} - #{url}"
145
+ rescue Timeout::Error
146
+ error "[408] #{msg.user} - #{url}"
147
+ msg.reply 'URL was forced Timed out'
134
148
  rescue => e
135
149
  error e
136
150
  error "[404] #{msg.user} - #{url}"
151
+ msg.safe_reply 'I am unable to load that URL'
137
152
  end
138
153
  end
139
154
 
@@ -19,7 +19,7 @@ module Plugins
19
19
  # Rescue incase something goes wrong
20
20
  begin
21
21
  debug 'Query: ' + query
22
- url = URI.encode "http://api.wolframalpha.com/v2/query?input=#{query}&appid=#{ENV['ZETA_WOLFRAM']}&primary=true&format=plaintext"
22
+ url = URI.encode "http://api.wolframalpha.com/v2/query?input=#{query}&appid=#{Config.secrets[:wolfram]}&primary=true&format=plaintext"
23
23
  request = open(url).read
24
24
  data = Crack::XML.parse(request)
25
25
  pod0 = data['queryresult']['pod'][0]['subpod']['plaintext'].strip
@@ -31,7 +31,7 @@ module Plugins
31
31
  elsif pod0.length > 400
32
32
  m.user.send("#{pod0} #{pod1}", true)
33
33
  else
34
- m.reply "#{pod0} #{pod1}"
34
+ m.reply "#{pod0} = #{pod1}"
35
35
  end
36
36
  rescue
37
37
  m.reply 'Unable to get a results'
data/lib/Zeta/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Zeta
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
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.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liothen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-17 00:00:00.000000000 Z
11
+ date: 2016-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler