descartes 0.7 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,49 +1,49 @@
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 Seen
17
- include Cinch::Plugin
18
-
19
- class SeenStruct < Struct.new(:who, :where, :what, :time)
20
- def to_s
21
- "[#{time.asctime}] #{who} was seen in #{where} saying #{what}"
22
- end
23
- end
24
-
25
- listen_to :channel
26
- match /seen (.+)/
27
-
28
- def initialize(*args)
29
- super
30
- @users = {}
31
- end
32
-
33
- def listen(m)
34
- @users[m.user.nick] = SeenStruct.new(m.user, m.channel, m.message, Time.now)
35
- end
36
-
37
- def execute(m, nick)
38
- if nick == @bot.nick
39
- m.reply "That's me!"
40
- elsif nick == m.user.nick
41
- m.reply "That's you!"
42
- elsif @users.key?(nick)
43
- m.reply @users[nick].to_s
44
- else
45
- m.reply "I haven't seen #{nick}"
46
- end
47
- end
48
- 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 Seen
17
+ include Cinch::Plugin
18
+
19
+ class SeenStruct < Struct.new(:who, :where, :what, :time)
20
+ def to_s
21
+ "[#{time.asctime}] #{who} was seen in #{where} saying #{what}"
22
+ end
23
+ end
24
+
25
+ listen_to :channel
26
+ match /seen (.+)/
27
+
28
+ def initialize(*args)
29
+ super
30
+ @users = {}
31
+ end
32
+
33
+ def listen(m)
34
+ @users[m.user.nick] = SeenStruct.new(m.user, m.channel, m.message, Time.now)
35
+ end
36
+
37
+ def execute(m, nick)
38
+ if nick == @bot.nick
39
+ m.reply "That's me!"
40
+ elsif nick == m.user.nick
41
+ m.reply "That's you!"
42
+ elsif @users.key?(nick)
43
+ m.reply @users[nick].to_s
44
+ else
45
+ m.reply "I haven't seen #{nick}"
46
+ end
47
+ end
48
+ end
49
49
  end
@@ -1,24 +1,24 @@
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 Shinbo
17
- include Cinch::Plugin
18
- match /shinbo/i, use_prefix: false
19
-
20
- def execute(m)
21
- Target(m.channel).action 'headtilts'
22
- end
23
- 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 Shinbo
17
+ include Cinch::Plugin
18
+ match /shinbo/i, use_prefix: false
19
+
20
+ def execute(m)
21
+ Target(m.channel).action 'headtilts'
22
+ end
23
+ end
24
24
  end
@@ -1,27 +1,27 @@
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 Sindaco
17
- include Cinch::Plugin
18
- match /Sindaco/i
19
-
20
- def execute(m)
21
- file = File.join $options[:dotfiles], 'sindaco.txt'
22
- m.reply [].tap { |ary|
23
- File.read(file).each_line { |line| ary << line unless line.strip.empty? }
24
- }.sample
25
- end
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 Sindaco
17
+ include Cinch::Plugin
18
+ match /Sindaco/i
19
+
20
+ def execute(m)
21
+ file = File.join $options[:dotfiles], 'sindaco.txt'
22
+ m.reply [].tap { |ary|
23
+ File.read(file).each_line { |line| ary << line unless line.strip.empty? }
24
+ }.sample
25
+ end
26
+ end
27
+ end
@@ -1,58 +1,58 @@
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
- require 'treccani'
16
-
17
- class Descartes
18
- class Treccani
19
- include Cinch::Plugin
20
- set :prefix, '!trec '
21
-
22
- match 'cit', method: :citazione
23
- match /enc (.+)/, method: :enciclopedia
24
- match /syn (.+)/, method: :sinonimi
25
- match /voc (.+)/, method: :vocabolario
26
-
27
- def citazione(m)
28
- treccani = Treccani::Citazione.new.get
29
- m.reply "#{treccani[:citazione]} - #{treccani[:autore]}"
30
- end
31
-
32
- def enciclopedia(m, word)
33
- begin
34
- m.reply Treccani::Enciclopedia.new.get(word)[:meanings].first[0..400]
35
- m.reply "- #{Treccani::Enciclopedia.new.get_url word}"
36
- rescue
37
- m.reply 'Vocabolo non trovato.'
38
- end
39
- end
40
-
41
- def sinonimi(m, word)
42
- begin
43
- m.reply Treccani::Sinonimi.new.get word
44
- rescue
45
- m.reply 'Vocabolo non trovato.'
46
- end
47
- end
48
-
49
- def vocabolario(m, word)
50
- begin
51
- m.reply Treccani::Vocabolario.new.get(word)[:meanings].first[0..400]
52
- m.reply "- #{Treccani::Vocabolario.new.get_url word}"
53
- rescue
54
- m.reply 'Vocabolo non trovato.'
55
- end
56
- end
57
- end
58
- 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
+ require 'treccani'
16
+
17
+ class Descartes
18
+ class Treccani
19
+ include Cinch::Plugin
20
+ set :prefix, '!trec '
21
+
22
+ match 'cit', method: :citazione
23
+ match /enc (.+)/, method: :enciclopedia
24
+ match /syn (.+)/, method: :sinonimi
25
+ match /voc (.+)/, method: :vocabolario
26
+
27
+ def citazione(m)
28
+ treccani = Treccani::Citazione.new.get
29
+ m.reply "#{treccani[:citazione]} - #{treccani[:autore]}"
30
+ end
31
+
32
+ def enciclopedia(m, word)
33
+ begin
34
+ m.reply Treccani::Enciclopedia.new.get(word)[:meanings].first[0..400]
35
+ m.reply "- #{Treccani::Enciclopedia.new.get_url word}"
36
+ rescue
37
+ m.reply 'Vocabolo non trovato.'
38
+ end
39
+ end
40
+
41
+ def sinonimi(m, word)
42
+ begin
43
+ m.reply Treccani::Sinonimi.new.get word
44
+ rescue
45
+ m.reply 'Vocabolo non trovato.'
46
+ end
47
+ end
48
+
49
+ def vocabolario(m, word)
50
+ begin
51
+ m.reply Treccani::Vocabolario.new.get(word)[:meanings].first[0..400]
52
+ m.reply "- #{Treccani::Vocabolario.new.get_url word}"
53
+ rescue
54
+ m.reply 'Vocabolo non trovato.'
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,36 +1,36 @@
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 'open-uri'
17
- require 'nokogiri'
18
-
19
- class Descartes
20
- class Url
21
- include Cinch::Plugin
22
- match /http(s)?:\/\/(\S+)/, use_prefix: false
23
-
24
- def execute(m, ssl, url)
25
- begin
26
- page = Nokogiri::HTML open("http#{ssl}://#{url}").read, nil, 'utf-8'
27
-
28
- if url.match 'youtube.com|youtu.be'
29
- m.reply "[Youtube] #{page.css('//title').first.text.chomp(' - YouTube')}".colorize :pink
30
- else
31
- m.reply "[URL] #{page.css('//title').first.text.strip}".colorize :red
32
- end
33
- rescue; end
34
- end
35
- end
36
- 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 'open-uri'
17
+ require 'nokogiri'
18
+
19
+ class Descartes
20
+ class Url
21
+ include Cinch::Plugin
22
+ match /http(s)?:\/\/(\S+)/, use_prefix: false
23
+
24
+ def execute(m, ssl, url)
25
+ begin
26
+ page = Nokogiri::HTML open("http#{ssl}://#{url}").read, nil, 'utf-8'
27
+
28
+ if url.match 'youtube.com|youtu.be'
29
+ m.reply "[Youtube] #{page.css('//title').first.text.chomp(' - YouTube')}".colorize :pink
30
+ else
31
+ m.reply "[URL] #{page.css('//title').first.text.strip}".colorize :red
32
+ end
33
+ rescue; end
34
+ end
35
+ end
36
+ end
@@ -1,42 +1,42 @@
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
- class String
17
- def to_ita
18
- day_eng = [ 'Sundays', 'Mondays', 'Tuesdays', 'Wednesdays', 'Thursdays', 'Fridays', 'Saturdays' ]
19
- day_ita = [ 'Domenica', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato' ]
20
- tim_eng = [ 'days', 'hours', 'minutes', 'seconds' ]
21
- tim_ita = [ 'giorni', 'ore', 'minuti', 'secondi' ]
22
-
23
- self.tap { |s|
24
- 0.upto(6) { |i| s.gsub! day_eng[i], day_ita[i] }
25
- 0.upto(3) { |i| s.gsub! tim_eng[i], tim_ita[i] }
26
- s.gsub! 'and', 'e'
27
- }
28
- end
29
-
30
- def nl2(wat)
31
- self.gsub(/\r\n?/, wat)
32
- end
33
-
34
- def decode
35
- require 'htmlentities'
36
- HTMLEntities.new.decode self
37
- end
38
-
39
- def numeric?
40
- self.to_i.to_s == self || self.to_f.to_s == self
41
- end
42
- 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
+ class String
17
+ def to_ita
18
+ day_eng = [ 'Sundays', 'Mondays', 'Tuesdays', 'Wednesdays', 'Thursdays', 'Fridays', 'Saturdays' ]
19
+ day_ita = [ 'Domenica', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato' ]
20
+ tim_eng = [ 'days', 'hours', 'minutes', 'seconds' ]
21
+ tim_ita = [ 'giorni', 'ore', 'minuti', 'secondi' ]
22
+
23
+ self.tap { |s|
24
+ 0.upto(6) { |i| s.gsub! day_eng[i], day_ita[i] }
25
+ 0.upto(3) { |i| s.gsub! tim_eng[i], tim_ita[i] }
26
+ s.gsub! 'and', 'e'
27
+ }
28
+ end
29
+
30
+ def nl2(wat)
31
+ self.gsub(/\r\n?/, wat)
32
+ end
33
+
34
+ def decode
35
+ require 'htmlentities'
36
+ HTMLEntities.new.decode self
37
+ end
38
+
39
+ def numeric?
40
+ self.to_i.to_s == self || self.to_f.to_s == self
41
+ end
42
+ end