descartes 0.3.10 → 0.3.11

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: 844e4ad50eb4f64b97902486f66281c5bc5f32e2
4
- data.tar.gz: ae57f2b8b6b6aa3a40e0b6e78c717f40f226f6da
3
+ metadata.gz: b97d6e88d2d8d305260597381a92dc1fce44ba5e
4
+ data.tar.gz: 7c3f14df7602df31530c8a0c003996fb6f2dd2ea
5
5
  SHA512:
6
- metadata.gz: cd844a2e4d713565e41ec975289c344e020fc153e93c40f46c8c72d818bc007623fcac2c271315dd165887e8455ed5e140b1e7c4236bbce9a6b28f4bd89e0b60
7
- data.tar.gz: 8a5633c23864dac0c99e1112aa1b332ed11a247a51099cedf254c6a0449f4c658800c08361f410601b3da2d75789875e6d6f2cfff20d6598d4b2827b6d811428
6
+ metadata.gz: 9acacb1bc7e1c033a20a6700e09a41dce15425adc2b52946026111006e136363e29eea399cb2d93dce9a221883cb21e43ef4fe602bd43856bf4f56961727dd50
7
+ data.tar.gz: 2fab6c8bfdb25f3ca841cce301d6ee21ec2761c08eaf47a8831822b1ee97f11f18ae77b47f36d71d1f5fda9524991b7ff07278606e8c1b76cc78f08feaae291f
data/bin/descartes CHANGED
@@ -16,14 +16,14 @@
16
16
 
17
17
  require 'descartes'
18
18
 
19
- @@nickname = ARGV[0] || 'Descartes'
19
+ nickname = ARGV[0] || 'Descartes'
20
20
  server = ARGV[1] || 'irc.rizon.net'
21
21
  channels = ARGV[2..-1] || ['#aggvistnurummor']
22
22
  plugins = Descartes.load
23
23
 
24
24
  Cinch::Bot.new {
25
25
  configure do |c|
26
- c.nick = @@nickname
26
+ c.nick = nickname
27
27
  c.realname = 'Descartes'
28
28
  c.user = 'Descartes'
29
29
  c.server = server
@@ -46,7 +46,7 @@ Cinch::Bot.new {
46
46
  end
47
47
 
48
48
  on :message, '!"' do |m|
49
- m.reply '“...”'
49
+ m.reply '“…”'
50
50
  end
51
51
 
52
52
  }.start
@@ -39,7 +39,8 @@ class Descartes
39
39
  res = search query
40
40
 
41
41
  if res.empty?
42
- m.reply 'No results found.'
42
+ # m.reply 'No results found.'
43
+ m.reply 'Nessun risultato.'
43
44
  else
44
45
  res[0..3].each { |r| m.reply "#{r[:title]} - #{r[:url]}" }
45
46
  end
@@ -15,8 +15,8 @@
15
15
  class Descartes
16
16
  class Reply
17
17
  include Cinch::Plugin
18
-
19
- match /#{@@nickname}.*\?/, :use_prefix => false
18
+
19
+ match /.*\?/, :prefix => lambda { |m| m.bot.nick }
20
20
 
21
21
  def execute(m)
22
22
  file = File.expand_path '../reply/replies.txt', __FILE__
@@ -18,12 +18,16 @@ require 'open-uri'
18
18
  class Descartes
19
19
  class Synonyms
20
20
  include Cinch::Plugin
21
- match /syn ([a-zA-Z]+)/
21
+ match /syn (.+)/
22
22
 
23
- def execute(m, word)
24
- url = "http://www.treccani.it/vocabolario/#{word}_(Sinonimi-e-Contrari)/"
25
- page = Nokogiri::HTML(open(url))
26
- m.reply page.xpath('//div[@class="spiega attacco"]/p').text.strip + " di più qui: #{url}"
23
+ def execute(m, word) # search synonyms of a term in the most famous italian vocabulary
24
+ begin
25
+ url = "http://www.treccani.it/vocabolario/#{word}_(Sinonimi-e-Contrari)/"
26
+ page = Nokogiri::HTML(open(url))
27
+ m.reply page.at_xpath('//div[@class="spiega attacco"]/p').text.strip + " di più qui: #{url}"
28
+ rescue
29
+ m.reply 'Vocabolo non trovato.'
30
+ end
27
31
  end
28
32
  end
29
33
  end
@@ -15,17 +15,19 @@
15
15
  require 'nokogiri'
16
16
  require 'open-uri'
17
17
 
18
-
19
18
  class Descartes
20
19
  class Treccani
21
20
  include Cinch::Plugin
21
+ match /trec (.+)/
22
22
 
23
- match /trec ([a-zA-Z]+)/
24
-
25
- def execute(m, word)
26
- url = "http://www.treccani.it/vocabolario/tag/#{word}"
23
+ def execute(m, word) # search the meaning of a term in the most famous italian vocabulary
24
+ url = "http://www.treccani.it/vocabolario/tag/#{word}"
27
25
  page = Nokogiri::HTML(open(url))
28
- m.reply page.xpath('//li[@class="result fs"]/p').text.strip + " di più qui: #{url}"
26
+ unless page.at_xpath('//div[@class="intro"]').text.include? 'prodotto alcun risultato'
27
+ m.reply page.at_xpath('//li[@class="result fs"]/p').text.strip + " di più qui: #{url}"
28
+ else
29
+ m.reply 'Vocabolo non trovato.'
30
+ end
29
31
  end
30
32
  end
31
33
  end
@@ -14,6 +14,6 @@
14
14
 
15
15
  class Descartes
16
16
  def self.version
17
- '0.3.10'
17
+ '0.3.11'
18
18
  end
19
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: descartes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.10
4
+ version: 0.3.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giovanni Capuano