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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/Zeta/plugins/snooper.rb +16 -1
- data/lib/Zeta/plugins/wolfram.rb +2 -2
- data/lib/Zeta/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0efc452957163d009f8a24a3518abdfdadf9fa66
|
4
|
+
data.tar.gz: e2800b1af4d5766614cd99233e58ce13efd7e4f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5449a4aa4e51d97fd552f398752f4a0fea592d4c1ee258355428f55230d2eb8b45fc6858f229bf3efb63201e0bbe6eb62cbdba1fc7bb1dd3f5c160163fa6a83
|
7
|
+
data.tar.gz: f7d139957d49f59f597ac498e483699bb54733063f61d0ab9219af651de21c96ec0301e9cb0acf3e72d0859fad2711629b44b20459bdebfc3b0024de5cb13016
|
data/Gemfile.lock
CHANGED
data/lib/Zeta/plugins/snooper.rb
CHANGED
@@ -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|
|
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
|
|
data/lib/Zeta/plugins/wolfram.rb
CHANGED
@@ -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=#{
|
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
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.
|
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-
|
11
|
+
date: 2016-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|