descartes 0.3.16 → 0.4

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: 3c15e7788e0c464a5cfbf345e508b94362a8d19f
4
- data.tar.gz: cb63ff6a9d1b67295a8208b174fbc7ea507b8bea
3
+ metadata.gz: b0b57aa9de1df1c113ebb033c34a5130f36ee934
4
+ data.tar.gz: 73d20235abaf909f4410e04ddbbab5725dc5b0f0
5
5
  SHA512:
6
- metadata.gz: e8bde749d631421e03b6b48c5755a6efdff801cbfbae9abf1353f4224dcfca4ea4168c3e3bdcb8e97194502e7e0db743a1322c92adcd2322623e7815b6f2e859
7
- data.tar.gz: 363acf13595609620e8f11b9ce06b74eafbc07574abedcc409a0d95c2c11ab2936256b1837416ee1ec8cdde6f41e28109080b32dcc9aec94f9dda6275d8c5fa7
6
+ metadata.gz: 581c343dd71d0140fff87c46f61687df21fd04acd02ee8b8a926cbabd1f83528880cbe426cb8f1852cd1c396808b1af38d4fbf9a424cd978d57ce8c016d04805
7
+ data.tar.gz: b35bde8554bcafd40e517f27e5fb64a91cf53d13d4455688c2f51d9b3e387015745a3136398952a3bb815889d0867b79e6c4249c6231a17dec153243a75668f8
data/bin/descartes CHANGED
@@ -33,8 +33,33 @@ Cinch::Bot.new {
33
33
  c.plugins.options[Cinch::Plugins::Login] = { :password => 'dat_password' }
34
34
  end
35
35
 
36
- on :message, '!list' do |m|
37
- m.reply m.bot.plugins.join ', '
36
+ on :message, '!help' do |m|
37
+ m.bot.plugins.each { |plugin|
38
+ plugin.handlers.each { |handler|
39
+ pattern = handler.pattern
40
+ name = plugin.to_s.split('::')[1].split(?:)[0]
41
+
42
+ prefix = case pattern.prefix
43
+ when Regexp then pattern.prefix.source
44
+ when String then pattern.prefix
45
+ else ''
46
+ end
47
+
48
+ suffix = case pattern.suffix
49
+ when Regexp then pattern.suffix.source
50
+ when String then pattern.suffix
51
+ else ''
52
+ end
53
+
54
+ regex = case pattern.pattern
55
+ when Regexp then pattern.pattern.source
56
+ when String then pattern.pattern
57
+ else ''
58
+ end
59
+
60
+ m.reply regex.empty? ? name : "#{name}: #{prefix}#{regex}#{suffix}"
61
+ }
62
+ }
38
63
  end
39
64
 
40
65
  on :message, '!è' do |m|
@@ -24,11 +24,11 @@ class Descartes
24
24
  series = Crunchyroll::find m.params[1].split('.cr ')[1]
25
25
 
26
26
  if series
27
- # m.reply "#{Format(:red, series[:title])} is a series airing on #{Format(:red, series[:where])} at #{Format(:red, series[:day])} #{Format(:red, series[:hour])}:#{Format(:red, series[:min])} which is in #{Format(:red, series[:left])}."
28
- m.reply "#{Format(:red, series[:title])} è una serie trasmessa da #{Format(:red, series[:where])} il #{Format(:red, series[:day].to_ita)} alle #{Format(:red, series[:hour])}:#{Format(:red, series[:min])}, cioè tra #{Format(:red, series[:left].to_ita)}."
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
29
  else
30
- # m.reply Format(:red, 'Anime not found')
31
- m.reply Format(:red, 'Anime non trovato')
30
+ # m.reply 'Anime not found'.colorize
31
+ m.reply 'Anime non trovato'.colorize
32
32
  end
33
33
  end
34
34
  end
@@ -22,8 +22,8 @@ class Descartes
22
22
  match /([a-zA-Z]+) ([a-zA-Z]+)/, :use_prefix => false
23
23
 
24
24
  def execute(m, action, word)
25
- url = "http://www.wordreference.com/#{action}/#{word}"
26
- page = Nokogiri::HTML(open(url))
25
+ url = "http://www.wordreference.com/#{action}/#{word}"
26
+ page = Nokogiri::HTML open(url)
27
27
  m.reply "#{page.xpath('//table[@class="WRD"]/tr[2]').text} di più qui: #{url}"
28
28
  end
29
29
  end
@@ -22,11 +22,11 @@ class Descartes
22
22
  match /google (.+)/
23
23
 
24
24
  def search(query)
25
- page = Nokogiri::HTML(open("http://www.google.com/search?q=#{CGI.escape(query)}"))
25
+ page = Nokogiri::HTML open("http://www.google.com/search?q=#{CGI.escape(query)}")
26
26
 
27
27
  [].tap { |res|
28
28
  page.search('cite').each { |r|
29
- res << { :url => r.inner_text }
29
+ res << { url: r.inner_text }
30
30
  }
31
31
 
32
32
  page.xpath('//h3[@class="r"]').each_with_index { |r, i|
@@ -16,10 +16,10 @@ class Descartes
16
16
  class Sindaco
17
17
  include Cinch::Plugin
18
18
 
19
- match /Sindaco/
19
+ match 'Sindaco'
20
20
 
21
21
  def execute(m)
22
- file = File.expand_path '../files/sindaco.txt', __FILE__
22
+ file = File.expand_path '../files/sindaco.txt', __FILE__
23
23
  m.reply [].tap { |ary|
24
24
  File.read(file).each_line { |line| ary << line unless line.strip.empty? }
25
25
  }.sample
@@ -23,12 +23,12 @@ class Descartes
23
23
 
24
24
  def execute(m, ssl, url)
25
25
  begin
26
- page = Nokogiri::HTML(open("http#{ssl}://#{url}").read, nil, 'utf-8')
26
+ page = Nokogiri::HTML open("http#{ssl}://#{url}").read, nil, 'utf-8'
27
27
 
28
- if url.match('youtube.com|youtu.be') != nil
29
- m.reply Format(:pink, "[Youtube] #{page.css('//title').first.text.chomp(' - YouTube')}")
28
+ if url.match 'youtube.com|youtu.be'
29
+ m.reply "[Youtube] #{page.css('//title').first.text.chomp(' - YouTube')}".colorize :pink
30
30
  else
31
- m.reply Format(:red, "[URL] #{page.css('//title').first.text.strip}")
31
+ m.reply "[URL] #{page.css('//title').first.text.strip}".colorize :red
32
32
  end
33
33
  rescue; end
34
34
  end
@@ -14,6 +14,6 @@
14
14
 
15
15
  class Descartes
16
16
  def self.version
17
- '0.3.16'
17
+ '0.4'
18
18
  end
19
19
  end
data/lib/descartes.rb CHANGED
@@ -14,6 +14,8 @@
14
14
 
15
15
  require 'cinch'
16
16
  require 'cinch/plugins/login'
17
+ require 'cinch/colorize'
18
+
17
19
  require 'descartes/utils'
18
20
  require 'descartes/descartes'
19
21
  require 'descartes/version'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: descartes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.16
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giovanni Capuano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-24 00:00:00.000000000 Z
11
+ date: 2013-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cinch
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: cinch-colorize
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'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: nokogiri
43
57
  requirement: !ruby/object:Gem::Requirement