descartes 0.3.7.3 → 0.3.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: bfcdaa72c4b9b1b0d871fb80b6237848babb8ec6
4
- data.tar.gz: cafd0650c236880ea5ca8ae37cb6ceb402a614ae
3
+ metadata.gz: cc616a48a2d57f44b088447a516715fc9404ebe5
4
+ data.tar.gz: 49747ef59f9cbe448ada135dd49767ff57335292
5
5
  SHA512:
6
- metadata.gz: f1ee6d70b6b9c1425a05994341e15d6e65a8215dd1798fbea64a9464fc1c44b6f7e6a957ce55d02e7860214e13bd96815b161ec4b839b4eec67dac70c952d50b
7
- data.tar.gz: 9a5668dd9913b67af14996a0e61dfa547758f9ea12e7816593eaae56084d832a4c7b5f77eda5ddfd10b2f638cc2e632dc869a3c8a8f38ce248547f659ad899a7
6
+ metadata.gz: 48bf793d8ecc118c0e6710797b68f320ad86837378472589f90f3c025d7248fb410cd9adda48b9e65a16408fe1b4c5dd06171ff444039ce3edb37bb34939038b
7
+ data.tar.gz: 8e9c4ebc012ff1b3a3226220a371fdb208658fab76ad1ded0a554da2c320f1b0bae542ea4e459c5745a79b2b79f23c0cc53202f0949896ff42887934d562b8fc
@@ -0,0 +1,35 @@
1
+ ##
2
+ ## DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
3
+ ## Version 2, December 2004
4
+ ##
5
+ ## Everyone is permitted to copy and distribute verbatim or modified
6
+ ## copies of this license document, and changing it is allowed as long
7
+ ## as the name is changed.
8
+ ##
9
+ ## DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
10
+ ## TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
11
+ ##
12
+ ## 0. You just DO WHAT THE FUCK YOU WANT TO.
13
+ ##
14
+
15
+ require 'open-uri'
16
+ require 'json'
17
+
18
+ class Descartes
19
+ class Quotone
20
+ include Cinch::Plugin
21
+
22
+ match /quotone/
23
+
24
+ def get(url)
25
+ open(url) { |f|
26
+ quote = JSON.parse f.read
27
+ return "\##{quote['id']} - #{quote['source']} (#{quote['tags']})\n#{quote['quote'].nl2(' / ').decode}"
28
+ }
29
+ end
30
+
31
+ def execute(m)
32
+ m.reply get 'http://www.quotone.unsigned.it/api/random.json'
33
+ end
34
+ end
35
+ end
@@ -20,10 +20,9 @@ class Descartes
20
20
 
21
21
  def execute(m)
22
22
  file = File.expand_path '../reply/replies.txt', __FILE__
23
- replies = [].tap { |ary|
24
- File.read(file).each_line { |line| ary << line unless line.empty? }
25
- }
26
- m.reply replies[rand(1..replies.length)]
23
+ m.reply [].tap { |ary|
24
+ File.read(file).each_line { |line| ary << line unless line.strip.empty? }
25
+ }.sample
27
26
  end
28
27
  end
29
28
  end
@@ -20,10 +20,9 @@ class Descartes
20
20
 
21
21
  def execute(m)
22
22
  file = File.expand_path '../reply/sindaco.txt', __FILE__
23
- replies = [].tap { |ary|
24
- File.read(file).each_line { |line| ary << line unless line.empty? }
25
- }
26
- m.reply replies[rand(1..replies.length)]
23
+ m.reply [].tap { |ary|
24
+ File.read(file).each_line { |line| ary << line unless line.strip.empty? }
25
+ }.sample
27
26
  end
28
27
  end
29
28
  end
@@ -22,13 +22,15 @@ class Descartes
22
22
  match /http(s)?:\/\/(\S+)/, :use_prefix => false
23
23
 
24
24
  def execute(m, ssl, url)
25
- page = Nokogiri::HTML(open("http#{ssl}://#{url}").read, nil, 'utf-8')
25
+ begin
26
+ page = Nokogiri::HTML(open("http#{ssl}://#{url}").read, nil, 'utf-8')
26
27
 
27
- if url.match('youtube.com|youtu.be') != nil
28
- m.reply page.css('//title').first.text.chomp(' - YouTube')
29
- else
30
- m.reply page.css('//title').first.text.strip
31
- end
28
+ if url.match('youtube.com|youtu.be') != nil
29
+ m.reply page.css('//title').first.text.chomp(' - YouTube')
30
+ else
31
+ m.reply page.css('//title').first.text.strip
32
+ end
33
+ rescue; end
32
34
  end
33
35
  end
34
36
  end
@@ -11,4 +11,13 @@ class String
11
11
  s.gsub! 'and', 'e'
12
12
  }
13
13
  end
14
+
15
+ def nl2(wat)
16
+ self.gsub(/\r\n?/, wat)
17
+ end
18
+
19
+ def decode
20
+ require 'htmlentities'
21
+ HTMLEntities.new.decode self
22
+ end
14
23
  end
@@ -14,6 +14,6 @@
14
14
 
15
15
  class Descartes
16
16
  def self.version
17
- '0.3.7.3'
17
+ '0.3.8'
18
18
  end
19
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: descartes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7.3
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giovanni Capuano
@@ -66,6 +66,34 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: htmlentities
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: json
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
69
97
  description: A serious modular ruby IRC bot.
70
98
  email: webmaster@giovannicapuano.net
71
99
  executables:
@@ -77,6 +105,7 @@ files:
77
105
  - lib/descartes/modules/crunchyroll.rb
78
106
  - lib/descartes/modules/currency.rb
79
107
  - lib/descartes/modules/google.rb
108
+ - lib/descartes/modules/quotone.rb
80
109
  - lib/descartes/modules/reply/replies.txt
81
110
  - lib/descartes/modules/reply/sindaco.txt
82
111
  - lib/descartes/modules/reply.rb