descartes 0.7 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,144 +1,144 @@
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 'assonnato'
16
-
17
- class Descartes
18
- class Pigro
19
- include Cinch::Plugin
20
- match /show (.+)/
21
- match /staff (.+)/, method: :by_staff
22
-
23
- def by_staff(m, user)
24
- user = user.split(' ')
25
- role = user.last.to_sym.downcase
26
-
27
- if [ :translator, :editor, :checker, :timer, :typesetter, :encoder, :qchecker ].include? role
28
- user.pop
29
- options = { user: user.join(' '), role: role }
30
- else
31
- options = { user: user.join(' ') }
32
- end
33
-
34
- host = get_host 'pigro.txt'
35
- shows = Assonnato::Show.new host
36
-
37
- series = shows.all!(:ongoing, options) + shows.all!(:dropped, options) + shows.all!(:finished, options)
38
-
39
- if series.empty?
40
- if options.has_key? :role
41
- m.reply "#{options[:user].colorize} hasn't worked to any series as #{options[:role].colorize}."
42
- else
43
- m.reply "#{options[:user].colorize} hasn't worked to any series."
44
- end
45
- return
46
- end
47
-
48
- m.reply ''.tap { |str|
49
- if options.has_key? :role
50
- str << "#{series.first.send(options[:role]).colorize} has worked as #{options[:role].colorize} on "
51
- else
52
- str << "#{options[:user].colorize} has worked on "
53
- end
54
-
55
- series.each { |s|
56
- str << "#{s.name.colorize}, "
57
- }
58
- }[0..-3]
59
- end
60
-
61
- def execute(m, keyword)
62
- s = keyword.split ' '
63
- n_ep = s.last.numeric? ? s.pop : nil
64
- keyword = s.join ' '
65
-
66
- host = get_host 'pigro.txt'
67
- shows = Assonnato::Show.new host
68
- episodes = Assonnato::Episode.new host
69
-
70
- series = shows.search! keyword
71
-
72
- if series.empty?
73
- m.reply 'Series not found'
74
- return
75
- end
76
-
77
- series.take(5).each { |s|
78
- show = shows.get!(s.name).first
79
-
80
- if n_ep.nil?
81
- a = show.status.downcase.start_with?(?o) ? 'an' : ?a
82
- m.reply "[#{show.fansub.colorize}] #{show.name.colorize} is #{a} #{show.status} series of #{show.tot_episodes.colorize} episodes."
83
- m.reply ''.tap { |staff|
84
- {
85
- :Translator => show.translator,
86
- :Editor => show.editor,
87
- :Checker => show.checker,
88
- :Timer => show.timer,
89
- :Typesetter => show.typesetter,
90
- :Encoder => show.encoder,
91
- :QC => show.qchecker
92
- }.each_pair { |key, val|
93
- staff << "#{key.to_s.colorize}: #{val} / " unless val.empty?
94
- }
95
- }[0..-4]
96
- else
97
- episodes = episodes.get! show.name, n_ep.to_i
98
-
99
- if episodes.any?
100
- episodes.each { |ep|
101
- m.reply ("#{show.name.colorize} ##{ep.episode}".colorize + ' - ').tap { |staff|
102
- activities = {
103
- :Translation => ep.translation,
104
- :Editing => ep.editing,
105
- :Check => ep.checking,
106
- :Timing => ep.timing,
107
- :Typesetting => ep.typesetting,
108
- :Encoding => ep.encoding,
109
- :QC => ep.qchecking
110
- }
111
-
112
- if activities.select { |k, v| v != :done }.any?
113
- staff << ''.tap { |s|
114
- activities.each_pair { |key, val|
115
- s << "#{key.to_s.colorize}: #{val} / "
116
- }
117
- }[0..-3]
118
- else
119
- staff << 'Already released. '
120
- end
121
- staff << "#{'Download'.colorize}: #{ep.download}" unless ep.download.strip.empty?
122
- }
123
- }
124
- elsif n_ep.to_i > show.tot_episodes
125
- m.reply "#{m.user.nick.colorize} pls go and http://just-believe.in."
126
- else
127
- m.reply "The episode #{n_ep.colorize} has not been added yet to #{show.name.colorize}."
128
- end
129
- end
130
- }
131
- end
132
-
133
- def get_host(f)
134
- file = File.join $options[:dotfiles], f
135
-
136
- if File.exists? file
137
- url = File.read(file).strip
138
- return url unless url.empty?
139
- end
140
-
141
- 'http://pigro.omnivium.it'
142
- end
143
- end
144
- 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 'assonnato'
16
+
17
+ class Descartes
18
+ class Pigro
19
+ include Cinch::Plugin
20
+ match /show (.+)/
21
+ match /staff (.+)/, method: :by_staff
22
+
23
+ def by_staff(m, user)
24
+ user = user.split(' ')
25
+ role = user.last.to_sym.downcase
26
+
27
+ if [ :translator, :editor, :checker, :timer, :typesetter, :encoder, :qchecker ].include? role
28
+ user.pop
29
+ options = { user: user.join(' '), role: role }
30
+ else
31
+ options = { user: user.join(' ') }
32
+ end
33
+
34
+ host = get_host 'pigro.txt'
35
+ shows = Assonnato::Show.new host
36
+
37
+ series = shows.all!(:ongoing, options) + shows.all!(:dropped, options) + shows.all!(:finished, options)
38
+
39
+ if series.empty?
40
+ if options.has_key? :role
41
+ m.reply "#{options[:user].colorize} hasn't worked to any series as #{options[:role].colorize}."
42
+ else
43
+ m.reply "#{options[:user].colorize} hasn't worked to any series."
44
+ end
45
+ return
46
+ end
47
+
48
+ m.reply ''.tap { |str|
49
+ if options.has_key? :role
50
+ str << "#{series.first.send(options[:role]).colorize} has worked as #{options[:role].colorize} on "
51
+ else
52
+ str << "#{options[:user].colorize} has worked on "
53
+ end
54
+
55
+ series.each { |s|
56
+ str << "#{s.name.colorize}, "
57
+ }
58
+ }[0..-3]
59
+ end
60
+
61
+ def execute(m, keyword)
62
+ s = keyword.split ' '
63
+ n_ep = s.last.numeric? ? s.pop : nil
64
+ keyword = s.join ' '
65
+
66
+ host = get_host 'pigro.txt'
67
+ shows = Assonnato::Show.new host
68
+ episodes = Assonnato::Episode.new host
69
+
70
+ series = shows.search! keyword
71
+
72
+ if series.empty?
73
+ m.reply 'Series not found'
74
+ return
75
+ end
76
+
77
+ series.take(5).each { |s|
78
+ show = shows.get!(s.name).first
79
+
80
+ if n_ep.nil?
81
+ a = show.status.downcase.start_with?(?o) ? 'an' : ?a
82
+ m.reply "[#{show.fansub.colorize}] #{show.name.colorize} is #{a} #{show.status} series of #{show.tot_episodes.colorize} episodes."
83
+ m.reply ''.tap { |staff|
84
+ {
85
+ :Translator => show.translator,
86
+ :Editor => show.editor,
87
+ :Checker => show.checker,
88
+ :Timer => show.timer,
89
+ :Typesetter => show.typesetter,
90
+ :Encoder => show.encoder,
91
+ :QC => show.qchecker
92
+ }.each_pair { |key, val|
93
+ staff << "#{key.to_s.colorize}: #{val} / " unless val.empty?
94
+ }
95
+ }[0..-4]
96
+ else
97
+ episodes = episodes.get! show.name, n_ep.to_i
98
+
99
+ if episodes.any?
100
+ episodes.each { |ep|
101
+ m.reply ("#{show.name.colorize} ##{ep.episode}".colorize + ' - ').tap { |staff|
102
+ activities = {
103
+ :Translation => ep.translation,
104
+ :Editing => ep.editing,
105
+ :Check => ep.checking,
106
+ :Timing => ep.timing,
107
+ :Typesetting => ep.typesetting,
108
+ :Encoding => ep.encoding,
109
+ :QC => ep.qchecking
110
+ }
111
+
112
+ if activities.select { |k, v| v != :done }.any?
113
+ staff << ''.tap { |s|
114
+ activities.each_pair { |key, val|
115
+ s << "#{key.to_s.colorize}: #{val} / "
116
+ }
117
+ }[0..-3]
118
+ else
119
+ staff << 'Already released. '
120
+ end
121
+ staff << "#{'Download'.colorize}: #{ep.download}" unless ep.download.strip.empty?
122
+ }
123
+ }
124
+ elsif n_ep.to_i > show.tot_episodes
125
+ m.reply "#{m.user.nick.colorize} pls go and http://just-believe.in."
126
+ else
127
+ m.reply "The episode #{n_ep.colorize} has not been added yet to #{show.name.colorize}."
128
+ end
129
+ end
130
+ }
131
+ end
132
+
133
+ def get_host(f)
134
+ file = File.join $options[:dotfiles], f
135
+
136
+ if File.exists? file
137
+ url = File.read(file).strip
138
+ return url unless url.empty?
139
+ end
140
+
141
+ 'http://pigro.omnivium.it'
142
+ end
143
+ end
144
+ 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 'json'
17
-
18
- class Descartes
19
- class Quotone
20
- include Cinch::Plugin
21
-
22
- match /quotone( [0-9]+){0,1}/
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, num = nil)
32
- m.reply get(num ? "http://quotone.giovannicapuano.net/api/get/#{num.to_i}.json" : 'http://quotone.giovannicapuano.net/api/random.json')
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 'json'
17
+
18
+ class Descartes
19
+ class Quotone
20
+ include Cinch::Plugin
21
+
22
+ match /quotone( [0-9]+){0,1}/
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, num = nil)
32
+ m.reply get(num ? "http://quotone.giovannicapuano.net/api/get/#{num.to_i}.json" : 'http://quotone.giovannicapuano.net/api/random.json')
33
+ end
34
+ end
35
+ end
@@ -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
- class Reply
17
- include Cinch::Plugin
18
-
19
- match /.*\?/, :prefix => lambda { |m| m.bot.nick }
20
-
21
- def execute(m)
22
- file = File.join $options[:dotfiles], 'replies.txt'
23
- m.reply [].tap { |ary|
24
- File.read(file).each_line { |line| ary << line unless line.strip.empty? }
25
- }.sample
26
- end
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
+ class Reply
17
+ include Cinch::Plugin
18
+
19
+ match /.*\?/, :prefix => lambda { |m| m.bot.nick }
20
+
21
+ def execute(m)
22
+ file = File.join $options[:dotfiles], 'replies.txt'
23
+ m.reply [].tap { |ary|
24
+ File.read(file).each_line { |line| ary << line unless line.strip.empty? }
25
+ }.sample
26
+ end
27
+ end
28
28
  end
@@ -1,43 +1,43 @@
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
- class RPN
17
- include Cinch::Plugin
18
-
19
- match /rpn (.+)/, method: :rpn
20
- def rpn(m)
21
- query = m.params[1].split('!rpn ')[1]
22
-
23
- m.reply [].tap { |res|
24
- query.split.each { |i|
25
- case i
26
- when /\d/
27
- res << i.to_f
28
- when ?+, ?-, ?*, ?/, ?^
29
- i = '**' if i == ?^
30
- res << [].tap { |a|
31
- a << res.pop while res.last.class == Float
32
- }.inject(i)
33
- end
34
- }
35
- }.last
36
- end
37
-
38
- match 'help rpn', method: :help
39
- def help(m)
40
- m.reply '!rpn n1 n2 (...) n3 [+|-|*|/|^]'
41
- end
42
- end
43
- 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
+ class RPN
17
+ include Cinch::Plugin
18
+
19
+ match /rpn (.+)/, method: :rpn
20
+ def rpn(m)
21
+ query = m.params[1].split('!rpn ')[1]
22
+
23
+ m.reply [].tap { |res|
24
+ query.split.each { |i|
25
+ case i
26
+ when /\d/
27
+ res << i.to_f
28
+ when ?+, ?-, ?*, ?/, ?^
29
+ i = '**' if i == ?^
30
+ res << [].tap { |a|
31
+ a << res.pop while res.last.class == Float
32
+ }.inject(i)
33
+ end
34
+ }
35
+ }.last
36
+ end
37
+
38
+ match 'help rpn', method: :help
39
+ def help(m)
40
+ m.reply '!rpn n1 n2 (...) n3 [+|-|*|/|^]'
41
+ end
42
+ end
43
+ end