summaryrefslogtreecommitdiff
path: root/data/rbot
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-10-25 13:19:22 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-10-25 13:19:22 +0000
commitfacc2af8233f691d022742f8ba5b96625c4b55cb (patch)
treeae970d1824b4fc8e639decf6ef884441bdb389ac /data/rbot
parent4b4a915911518f70c001c22a8b93be417c3dc544 (diff)
demauro plugin: add is_italian? method (for use by other plugins)
Diffstat (limited to 'data/rbot')
-rw-r--r--data/rbot/plugins/demauro.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/data/rbot/plugins/demauro.rb b/data/rbot/plugins/demauro.rb
index 9f5fc218..85f1f417 100644
--- a/data/rbot/plugins/demauro.rb
+++ b/data/rbot/plugins/demauro.rb
@@ -14,30 +14,41 @@ class DeMauroPlugin < Plugin
end
def demauro(m, params)
+ justcheck = params[:justcheck]
+
parola = params[:parola].downcase
url = @wapurl + "index.php?lemma=#{URI.escape(parola)}"
xml = @bot.httputil.get_cached(url)
if xml.nil?
info = @bot.httputil.last_response
info = info ? "(#{info.code} - #{info.message})" : ""
+ return false if justcheck
m.reply "An error occurred while looking for #{parola}#{info}"
return
end
if xml=~ /Non ho trovato occorrenze per/
+ return false if justcheck
m.reply "Nothing found for #{parola}"
return
end
entries = xml.scan(DEMAURO_LEMMA)
text = parola
if !entries.assoc(parola) and !entries.assoc(parola.upcase)
+ return false if justcheck
text += " not found. Similar words"
end
+ return true if justcheck
text += ": "
text += entries[0...5].map { |ar|
"#{ar[0]} - #{ar[1].gsub(/<\/?em>/,'')}: #{@dmurl}#{ar[2]}"
}.join(" | ")
m.reply text
end
+
+ def is_italian?(word)
+ return demauro(nil, :parola => word, :justcheck => true)
+ end
+
end
plugin = DeMauroPlugin.new