descartes 0.7 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 94b706f7f63fa2638de81f8afd10c139c5d80bd5
4
- data.tar.gz: 741010619fd2fa3155c2fda45bfc5cc4ade699de
3
+ metadata.gz: 4b75a8569961035b8683561054cfc84772f3fab0
4
+ data.tar.gz: 82049ea9083517b13fcb7186e8c21c1fc65fc8b6
5
5
  SHA512:
6
- metadata.gz: 975b98926325769276de665f13eaf4aad6b9551ddb5177cd9735a61c73b7b25297a36fa5aa5df83fe03116553f2354345c3b78dbd39ab6f8041da04c80e85ae0
7
- data.tar.gz: 8defccc7b299cd308e7fe618eb547a46dfdfeabd876c9288a3fa0aa5896fefe407547c831be337bed5d628e6e6211f74b082318bf28fcb5ccaaddd8832148d72
6
+ metadata.gz: 1f520e24344ac404e4dd6adaee7b0296a7f9ff9d111d102fe0632e9aba99786f89398b1ea955096fbf43fabe0b130ea06151da84b22921a27dd52448d645db9d
7
+ data.tar.gz: a655575e593da5551872cc56caff4356f0a70e975eede1cea14053d4900334eced193ae43f25a9d5b2b0946f3a9a2aa3df5a4266abb86abeb2caa57bf5602cd0
data/bin/descartes CHANGED
@@ -1,125 +1,125 @@
1
- #!/usr/bin/env ruby
2
- ##
3
- # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
4
- # Version 2, December 2004
5
- #
6
- # Everyone is permitted to copy and distribute verbatim or modified
7
- # copies of this license document, and changing it is allowed as long
8
- # as the name is changed.
9
- #
10
- # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
- # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
- #
13
- # 0. You just DO WHAT THE FUCK YOU WANT TO.
14
- ##
15
-
16
- require 'descartes'
17
- require 'optparse'
18
- require 'fileutils'
19
-
20
- options = {
21
- :nickname => 'Descartes',
22
- :server => 'irc.rizon.net',
23
- :channels => ['#aggvistnurummor'],
24
- :dotfiles => File.join(ENV['HOME'], '.descartes'),
25
- :password => 'dat_password',
26
- :exclude => []
27
- }
28
-
29
- OptionParser.new { |o|
30
- o.on '-n', '--nickname NICKNAME', 'bot\'s nickname' do |nickname|
31
- options[:nickname] = nickname
32
- end
33
-
34
- o.on '-s', '--server SERVER', 'target IRC server' do |server|
35
- options[:server] = server
36
- end
37
-
38
- o.on '-c', '--channel #chan1,#chan2', 'target channels' do |channels|
39
- options[:channels] = channels.split(?,).map { |s| s.strip }
40
- end
41
-
42
- o.on '-d', '--dotfiles PATH', 'folder where store config files' do |dotfiles|
43
- options[:dotfiles] = dotfiles
44
- end
45
-
46
- o.on '-p', '--password PASSWORD', 'target channel\'s password' do |password|
47
- options[:password] = password
48
- end
49
-
50
- o.on '-e', '--exclude module1,module2', 'exclude modules' do |exclude|
51
- options[:exclude] = exclude.split(?,).map { |s| s.strip.downcase }
52
- end
53
- }.parse!
54
-
55
- files = File.join File.dirname(__FILE__), '../lib/descartes/modules/files'
56
- FileUtils.cp_r(files, options[:dotfiles]) unless File.directory? options[:dotfiles]
57
-
58
- Dir["#{options[:dotfiles]}/**/*"].each { |file|
59
- lib = Dir["#{files}/**/*"].select { |f| File.basename(f) == File.basename(file) }
60
- next if lib.empty?
61
- next unless lib.first.end_with? '.txt'
62
-
63
- if File.read(lib.first) != File.read(file)
64
- FileUtils.cp lib.first, options[:dotfiles]
65
- puts "'#{file}' has been updated."
66
- end
67
- }
68
-
69
- Cinch::Bot.new {
70
- configure do |c|
71
- c.nick = options[:nickname]
72
- c.realname = 'Descartes'
73
- c.user = 'Descartes'
74
- c.server = options[:server]
75
- c.channels = options[:channels]
76
-
77
- c.plugins.plugins = [Cinch::Plugins::Login] + Descartes.load(options)
78
- c.plugins.options[Cinch::Plugins::Login] = { :password => options[:password] }
79
- end
80
-
81
- on :message, '!help' do |m|
82
- m.bot.plugins.each { |plugin|
83
- plugin.handlers.each { |handler|
84
- pattern = handler.pattern
85
- name = plugin.to_s.split('::')[1].split(?:)[0]
86
-
87
- prefix = case pattern.prefix
88
- when Regexp then pattern.prefix.source
89
- when String then pattern.prefix
90
- else ''
91
- end
92
-
93
- suffix = case pattern.suffix
94
- when Regexp then pattern.suffix.source
95
- when String then pattern.suffix
96
- else ''
97
- end
98
-
99
- regex = case pattern.pattern
100
- when Regexp then pattern.pattern.source
101
- when String then pattern.pattern
102
- else ''
103
- end
104
-
105
- m.reply regex.empty? ? name : "#{name}: #{prefix}#{regex}#{suffix}"
106
- }
107
- }
108
- end
109
-
110
- on :message, '!è' do |m|
111
- m.reply ?È
112
- end
113
-
114
- on :message, '!t' do |m|
115
- m.reply ?~
116
- end
117
-
118
- on :message, '!"' do |m|
119
- m.reply '“…”'
120
- end
121
-
122
- on :message, '!version' do |m|
123
- m.reply Descartes.version
124
- end
125
- }.start
1
+ #!/usr/bin/env ruby
2
+ ##
3
+ # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
4
+ # Version 2, December 2004
5
+ #
6
+ # Everyone is permitted to copy and distribute verbatim or modified
7
+ # copies of this license document, and changing it is allowed as long
8
+ # as the name is changed.
9
+ #
10
+ # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
+ # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
+ #
13
+ # 0. You just DO WHAT THE FUCK YOU WANT TO.
14
+ ##
15
+
16
+ require 'descartes'
17
+ require 'optparse'
18
+ require 'fileutils'
19
+
20
+ options = {
21
+ :nickname => 'Descartes',
22
+ :server => 'irc.rizon.net',
23
+ :channels => ['#aggvistnurummor'],
24
+ :dotfiles => File.join(ENV['HOME'], '.descartes'),
25
+ :password => 'dat_password',
26
+ :exclude => []
27
+ }
28
+
29
+ OptionParser.new { |o|
30
+ o.on '-n', '--nickname NICKNAME', 'bot\'s nickname' do |nickname|
31
+ options[:nickname] = nickname
32
+ end
33
+
34
+ o.on '-s', '--server SERVER', 'target IRC server' do |server|
35
+ options[:server] = server
36
+ end
37
+
38
+ o.on '-c', '--channel #chan1,#chan2', 'target channels' do |channels|
39
+ options[:channels] = channels.split(?,).map { |s| s.strip }
40
+ end
41
+
42
+ o.on '-d', '--dotfiles PATH', 'folder where store config files' do |dotfiles|
43
+ options[:dotfiles] = dotfiles
44
+ end
45
+
46
+ o.on '-p', '--password PASSWORD', 'target channel\'s password' do |password|
47
+ options[:password] = password
48
+ end
49
+
50
+ o.on '-e', '--exclude module1,module2', 'exclude modules' do |exclude|
51
+ options[:exclude] = exclude.split(?,).map { |s| s.strip.downcase }
52
+ end
53
+ }.parse!
54
+
55
+ files = File.join File.dirname(__FILE__), '../lib/descartes/modules/files'
56
+ FileUtils.cp_r(files, options[:dotfiles]) unless File.directory? options[:dotfiles]
57
+
58
+ Dir["#{options[:dotfiles]}/**/*"].each { |file|
59
+ lib = Dir["#{files}/**/*"].select { |f| File.basename(f) == File.basename(file) }
60
+ next if lib.empty?
61
+ next unless lib.first.end_with? '.txt'
62
+
63
+ if File.read(lib.first) != File.read(file)
64
+ FileUtils.cp lib.first, options[:dotfiles]
65
+ puts "'#{file}' has been updated."
66
+ end
67
+ }
68
+
69
+ Cinch::Bot.new {
70
+ configure do |c|
71
+ c.nick = options[:nickname]
72
+ c.realname = 'Descartes'
73
+ c.user = 'Descartes'
74
+ c.server = options[:server]
75
+ c.channels = options[:channels]
76
+
77
+ c.plugins.plugins = [Cinch::Plugins::Login] + Descartes.load(options)
78
+ c.plugins.options[Cinch::Plugins::Login] = { :password => options[:password] }
79
+ end
80
+
81
+ on :message, '!help' do |m|
82
+ m.bot.plugins.each { |plugin|
83
+ plugin.handlers.each { |handler|
84
+ pattern = handler.pattern
85
+ name = plugin.to_s.split('::')[1].split(?:)[0]
86
+
87
+ prefix = case pattern.prefix
88
+ when Regexp then pattern.prefix.source
89
+ when String then pattern.prefix
90
+ else ''
91
+ end
92
+
93
+ suffix = case pattern.suffix
94
+ when Regexp then pattern.suffix.source
95
+ when String then pattern.suffix
96
+ else ''
97
+ end
98
+
99
+ regex = case pattern.pattern
100
+ when Regexp then pattern.pattern.source
101
+ when String then pattern.pattern
102
+ else ''
103
+ end
104
+
105
+ m.reply regex.empty? ? name : "#{name}: #{prefix}#{regex}#{suffix}"
106
+ }
107
+ }
108
+ end
109
+
110
+ on :message, '!è' do |m|
111
+ m.reply ?È
112
+ end
113
+
114
+ on :message, '!t' do |m|
115
+ m.reply ?~
116
+ end
117
+
118
+ on :message, '!"' do |m|
119
+ m.reply '“…”'
120
+ end
121
+
122
+ on :message, '!version' do |m|
123
+ m.reply Descartes.version
124
+ end
125
+ }.start
data/lib/descartes.rb CHANGED
@@ -1,21 +1,21 @@
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 'cinch'
16
- require 'cinch/plugins/login'
17
- require 'cinch/colorize'
18
-
19
- require 'descartes/utils'
20
- require 'descartes/descartes'
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 'cinch'
16
+ require 'cinch/plugins/login'
17
+ require 'cinch/colorize'
18
+
19
+ require 'descartes/utils'
20
+ require 'descartes/descartes'
21
21
  require 'descartes/version'
@@ -1,28 +1,28 @@
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
- class Descartes
16
- def self.load(options)
17
- $options = options
18
-
19
- Dir.glob(File.expand_path('../modules/*.rb', __FILE__)).each { |plugin|
20
- name = plugin.split(?/).last.split(?.).first.downcase
21
- require plugin unless $options[:exclude].include? name
22
- }
23
-
24
- return Descartes.constants.map { |p|
25
- "Descartes::#{p}".split('::').inject(Object) { |o, c| o.const_get c }
26
- }
27
- end
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
+ class Descartes
16
+ def self.load(options)
17
+ $options = options
18
+
19
+ Dir.glob(File.expand_path('../modules/*.rb', __FILE__)).each { |plugin|
20
+ name = plugin.split(?/).last.split(?.).first.downcase
21
+ require plugin unless $options[:exclude].include? name
22
+ }
23
+
24
+ return Descartes.constants.map { |p|
25
+ "Descartes::#{p}".split('::').inject(Object) { |o, c| o.const_get c }
26
+ }
27
+ end
28
28
  end
@@ -1,35 +1,35 @@
1
- # encoding: UTF-8
2
- ##
3
- # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
4
- # Version 2, December 2004
5
- #
6
- # Everyone is permitted to copy and distribute verbatim or modified
7
- # copies of this license document, and changing it is allowed as long
8
- # as the name is changed.
9
- #
10
- # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
- # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
- #
13
- # 0. You just DO WHAT THE FUCK YOU WANT TO.
14
- ##
15
-
16
- require 'crunchyroll'
17
-
18
- class Descartes
19
- class Crunchybot
20
- include Cinch::Plugin
21
- match /\.cr (.+)/, use_prefix: false
22
-
23
- def execute(m)
24
- series = Crunchyroll::find m.params[1].split('.cr ')[1]
25
-
26
- if series
27
- # m.reply "#{series[:title].colorize} is a series airing on #{series[:where].colorize} at #{series[:day].colorize} #{series[:hour].colorize}:#{series[:min].colorize} which is in #{series[:left].colorize}."
28
- m.reply "#{series[:title].colorize} è una serie trasmessa da #{series[:where].colorize} il #{series[:day].to_ita.colorize} alle #{series[:hour].colorize}:#{series[:min].colorize}, cioè tra #{series[:left].to_ita.colorize}."
29
- else
30
- # m.reply 'Anime not found'.colorize
31
- m.reply 'Anime non trovato'.colorize
32
- end
33
- end
34
- end
35
- end
1
+ # encoding: UTF-8
2
+ ##
3
+ # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
4
+ # Version 2, December 2004
5
+ #
6
+ # Everyone is permitted to copy and distribute verbatim or modified
7
+ # copies of this license document, and changing it is allowed as long
8
+ # as the name is changed.
9
+ #
10
+ # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
+ # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
+ #
13
+ # 0. You just DO WHAT THE FUCK YOU WANT TO.
14
+ ##
15
+
16
+ require 'crunchyroll'
17
+
18
+ class Descartes
19
+ class Crunchybot
20
+ include Cinch::Plugin
21
+ match /\.cr (.+)/, use_prefix: false
22
+
23
+ def execute(m)
24
+ series = Crunchyroll::find m.params[1].split('.cr ')[1]
25
+
26
+ if series
27
+ # m.reply "#{series[:title].colorize} is a series airing on #{series[:where].colorize} at #{series[:day].colorize} #{series[:hour].colorize}:#{series[:min].colorize} which is in #{series[:left].colorize}."
28
+ m.reply "#{series[:title].colorize} è una serie trasmessa da #{series[:where].colorize} il #{series[:day].to_ita.colorize} alle #{series[:hour].colorize}:#{series[:min].colorize}, cioè tra #{series[:left].to_ita.colorize}."
29
+ else
30
+ # m.reply 'Anime not found'.colorize
31
+ m.reply 'Anime non trovato'.colorize
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,35 +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 'nokogiri'
17
-
18
- class Descartes
19
- class Currency
20
- include Cinch::Plugin
21
- match /[0-9]+ [A-Za-z]+ to [A-Za-z]+/, use_prefix: false
22
-
23
- def execute(m)
24
- amount = m.params[1].match /[0-9]+/
25
- from = m.params[1].match(/[A-Za-z]+ to/).to_s[0..-4]
26
- to = m.params[1].match(/to [A-Za-z]+/).to_s[3..-1]
27
-
28
- from = 'jpy' if from == 'yen'
29
- to = 'jpy' if to == 'yen'
30
-
31
- url = "http://www.xe.com/currencyconverter/convert/?Amount=#{amount}&From=#{from}&To=#{to}"
32
- m.reply Nokogiri::HTML(open(url)).xpath('//tr[@class="uccRes"]').children[4].text
33
- end
34
- end
35
- end
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 'nokogiri'
17
+
18
+ class Descartes
19
+ class Currency
20
+ include Cinch::Plugin
21
+ match /[0-9]+ [A-Za-z]+ to [A-Za-z]+/, use_prefix: false
22
+
23
+ def execute(m)
24
+ amount = m.params[1].match /[0-9]+/
25
+ from = m.params[1].match(/[A-Za-z]+ to/).to_s[0..-4]
26
+ to = m.params[1].match(/to [A-Za-z]+/).to_s[3..-1]
27
+
28
+ from = 'jpy' if from == 'yen'
29
+ to = 'jpy' if to == 'yen'
30
+
31
+ url = "http://www.xe.com/currencyconverter/convert/?Amount=#{amount}&From=#{from}&To=#{to}"
32
+ m.reply Nokogiri::HTML(open(url)).xpath('//tr[@class="uccRes"]').children[4].text
33
+ end
34
+ end
35
+ end