descartes 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/descartes +37 -0
- data/lib/descartes/descartes.rb +25 -0
- data/lib/descartes/modules/currency.rb +35 -0
- data/lib/descartes/modules/google.rb +48 -0
- data/lib/descartes/modules/hi.rb +25 -0
- data/lib/descartes/modules/rpn.rb +43 -0
- data/lib/descartes/modules/seen.rb +36 -0
- data/lib/descartes/modules/shinbo.rb +24 -0
- data/lib/descartes/modules/trec.rb +31 -0
- data/lib/descartes/modules/url.rb +34 -0
- data/lib/descartes/version.rb +19 -0
- data/lib/descartes.rb +18 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a7665c9d7e36cf14dd567eaa9117a6a9dabe1ad9
|
4
|
+
data.tar.gz: c368d12f517d0f7f73bc36b87cd5a6b557769e41
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6cd7203fd36410896c14e9db9dbff0b3c8d24feb925ab440ad7087da94423ea5e4c2b6e6e9c8106dca9b4d25b2a9df5ad8af65f135d8fa68fb99de23e563593b
|
7
|
+
data.tar.gz: fafd1f3323c558e82f2785fc85e59c45cac0f970164c00ad471942a072d82693ed9bea26a1f53ac32c559b56e7c3a9bd79fbed6f23bafed7f2d62bb27a01df6b
|
data/bin/descartes
ADDED
@@ -0,0 +1,37 @@
|
|
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 'descartes'
|
16
|
+
|
17
|
+
server = ARGV[0] || 'irc.rizon.net'
|
18
|
+
channels = ARGV[1..-1] || ['#aggvistnurummor']
|
19
|
+
plugins = Descartes.load
|
20
|
+
|
21
|
+
Cinch::Bot.new {
|
22
|
+
configure do |c|
|
23
|
+
c.nick = 'Descartes'
|
24
|
+
c.realname = 'Descartes'
|
25
|
+
c.user = 'Descartes'
|
26
|
+
c.server = server
|
27
|
+
c.channels = channels
|
28
|
+
|
29
|
+
c.plugins.plugins = [Cinch::Plugins::Login] + plugins
|
30
|
+
c.plugins.options[Cinch::Plugins::Login] = { :password => 'dat_password' }
|
31
|
+
end
|
32
|
+
|
33
|
+
on :message, '!list' do |m|
|
34
|
+
m.reply m.bot.plugins.join ', '
|
35
|
+
end
|
36
|
+
|
37
|
+
}.start
|
@@ -0,0 +1,25 @@
|
|
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
|
17
|
+
Dir.glob(File.expand_path('../modules/*.rb', __FILE__)).each { |plugin|
|
18
|
+
require plugin
|
19
|
+
}
|
20
|
+
|
21
|
+
return Descartes.constants.map { |p|
|
22
|
+
"Descartes::#{p}".split('::').inject(Object) { |o, c| o.const_get c }
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
@@ -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 '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
|
@@ -0,0 +1,48 @@
|
|
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
|
+
require 'cgi'
|
18
|
+
|
19
|
+
class Descartes
|
20
|
+
class Google
|
21
|
+
include Cinch::Plugin
|
22
|
+
match /google (.+)/
|
23
|
+
|
24
|
+
def search(query)
|
25
|
+
page = Nokogiri::HTML(open("http://www.google.com/search?q=#{CGI.escape(query)}"))
|
26
|
+
|
27
|
+
[].tap { |res|
|
28
|
+
page.search('cite').each { |r|
|
29
|
+
res << { :url => r.inner_text }
|
30
|
+
}
|
31
|
+
|
32
|
+
page.xpath('//h3[@class="r"]').each_with_index { |r, i|
|
33
|
+
res[i][:title] = r.child.inner_text
|
34
|
+
}
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
def execute(m, query)
|
39
|
+
res = search query
|
40
|
+
|
41
|
+
if res.empty?
|
42
|
+
m.reply 'No results found.'
|
43
|
+
else
|
44
|
+
res[0..3].each { |r| m.reply "#{r[:title]} - #{r[:url]}" }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,25 @@
|
|
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 Hi
|
17
|
+
include Cinch::Plugin
|
18
|
+
|
19
|
+
match 'hello'
|
20
|
+
|
21
|
+
def execute(m)
|
22
|
+
m.reply "hello, #{m.user.nick}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +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, query)
|
21
|
+
query = m.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
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# https://github.com/cinchrb/cinch/blob/master/examples/plugins/seen.rb
|
2
|
+
class Descartes
|
3
|
+
class Seen
|
4
|
+
include Cinch::Plugin
|
5
|
+
|
6
|
+
class SeenStruct < Struct.new(:who, :where, :what, :time)
|
7
|
+
def to_s
|
8
|
+
"[#{time.asctime}] #{who} was seen in #{where} saying #{what}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
listen_to :channel
|
13
|
+
match /seen (.+)/
|
14
|
+
|
15
|
+
def initialize(*args)
|
16
|
+
super
|
17
|
+
@users = {}
|
18
|
+
end
|
19
|
+
|
20
|
+
def listen(m)
|
21
|
+
@users[m.user.nick] = SeenStruct.new(m.user, m.channel, m.message, Time.now)
|
22
|
+
end
|
23
|
+
|
24
|
+
def execute(m, nick)
|
25
|
+
if nick == @bot.nick
|
26
|
+
m.reply "That's me!"
|
27
|
+
elsif nick == m.user.nick
|
28
|
+
m.reply "That's you!"
|
29
|
+
elsif @users.key?(nick)
|
30
|
+
m.reply @users[nick].to_s
|
31
|
+
else
|
32
|
+
m.reply "I haven't seen #{nick}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +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/, :use_prefix => false
|
19
|
+
|
20
|
+
def execute(m)
|
21
|
+
Target(m.channel).action 'headtilts'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,31 @@
|
|
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 'nokogiri'
|
16
|
+
require 'open-uri'
|
17
|
+
|
18
|
+
|
19
|
+
class Descartes
|
20
|
+
class Treccani
|
21
|
+
include Cinch::Plugin
|
22
|
+
|
23
|
+
match /trec ([a-zA-Z]+)/
|
24
|
+
|
25
|
+
def execute(m, word)
|
26
|
+
url = "http://www.treccani.it/vocabolario/tag/#{word}"
|
27
|
+
page = Nokogiri::HTML(open(url))
|
28
|
+
m.reply page.xpath('//li[@class="result fs"]/p').text.strip + " di più qui: #{url}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,34 @@
|
|
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
|
+
page = Nokogiri::HTML(open("http#{ssl}://#{url}").read, nil, 'utf-8')
|
26
|
+
|
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
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,19 @@
|
|
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.version
|
17
|
+
'0.3.1'
|
18
|
+
end
|
19
|
+
end
|
data/lib/descartes.rb
ADDED
@@ -0,0 +1,18 @@
|
|
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 'descartes/descartes'
|
18
|
+
require 'descartes/version'
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: descartes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Giovanni Capuano
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cinch
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: cinch-login
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: A serious modular ruby IRC bot.
|
56
|
+
email: webmaster@giovannicapuano.net
|
57
|
+
executables:
|
58
|
+
- descartes
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/descartes/descartes.rb
|
63
|
+
- lib/descartes/modules/currency.rb
|
64
|
+
- lib/descartes/modules/google.rb
|
65
|
+
- lib/descartes/modules/hi.rb
|
66
|
+
- lib/descartes/modules/rpn.rb
|
67
|
+
- lib/descartes/modules/seen.rb
|
68
|
+
- lib/descartes/modules/shinbo.rb
|
69
|
+
- lib/descartes/modules/trec.rb
|
70
|
+
- lib/descartes/modules/url.rb
|
71
|
+
- lib/descartes/version.rb
|
72
|
+
- lib/descartes.rb
|
73
|
+
- bin/descartes
|
74
|
+
homepage: http://www.giovannicapuano.net
|
75
|
+
licenses:
|
76
|
+
- WTFPL
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.0.3
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: Codo ergo bot.
|
98
|
+
test_files: []
|