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 +4 -4
- data/bin/descartes +125 -125
- data/lib/descartes.rb +20 -20
- data/lib/descartes/descartes.rb +27 -27
- data/lib/descartes/modules/crunchyroll.rb +35 -35
- data/lib/descartes/modules/currency.rb +35 -35
- data/lib/descartes/modules/dicteng.rb +30 -30
- data/lib/descartes/modules/files/lastfm_api.yml +1 -1
- data/lib/descartes/modules/files/replies.txt +10 -4
- data/lib/descartes/modules/files/sindaco.txt +18 -18
- data/lib/descartes/modules/google.rb +48 -48
- data/lib/descartes/modules/lastfm.rb +91 -91
- data/lib/descartes/modules/musicthoughts.rb +33 -33
- data/lib/descartes/modules/pigro.rb +144 -144
- data/lib/descartes/modules/quotone.rb +35 -35
- data/lib/descartes/modules/reply.rb +27 -27
- data/lib/descartes/modules/rpn.rb +43 -43
- data/lib/descartes/modules/seen.rb +48 -48
- data/lib/descartes/modules/shinbo.rb +23 -23
- data/lib/descartes/modules/sindaco.rb +27 -27
- data/lib/descartes/modules/treccani.rb +58 -58
- data/lib/descartes/modules/url.rb +36 -36
- data/lib/descartes/utils.rb +42 -42
- data/lib/descartes/version.rb +19 -19
- metadata +2 -2
@@ -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
|
data/lib/descartes/utils.rb
CHANGED
@@ -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
|