diff options
author | Tom Gilbert <tom@linuxbrit.co.uk> | 2005-07-27 15:59:13 +0000 |
---|---|---|
committer | Tom Gilbert <tom@linuxbrit.co.uk> | 2005-07-27 15:59:13 +0000 |
commit | 21949774b91eaec6ecde4eaa8ad121e2c0a36b87 (patch) | |
tree | 41a7601e168018ac203bad7ca8d7f9f82515bc28 /data/rbot/contrib/plugins/vandale.rb | |
parent | 51cf09ec02d089bfdd80e5f728cfc92a234dc437 (diff) |
rearrange repo for packaging
Diffstat (limited to 'data/rbot/contrib/plugins/vandale.rb')
-rw-r--r-- | data/rbot/contrib/plugins/vandale.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/data/rbot/contrib/plugins/vandale.rb b/data/rbot/contrib/plugins/vandale.rb new file mode 100644 index 00000000..7b806c85 --- /dev/null +++ b/data/rbot/contrib/plugins/vandale.rb @@ -0,0 +1,49 @@ +#----------------------------------------------------------------# +# Filename: vandale.rb +# Description: Rbot plugin. Looks up a word in the Dutch VanDale +# dictionary +# Author: eWoud - ewoud.nuyts<AT>student.kuleuven.ac.be +# requires GnuVD www.djcbsoftware.nl/projecten/gnuvd/ +#----------------------------------------------------------------# + +class VanDalePlugin < Plugin + def help(plugin, topic="") + "vandale [<word>] => Look up in the VanDale dictionary" + end + def privmsg(m) + case m.params + when (/^([\w-]+)$/) + ret = Array.new + Utils.safe_exec("/usr/local/bin/gnuvd", m.params).each{|line| if line.length > 5 then ret << line end} + m.reply ret.delete_at(0) + while ret[0] =~ /^[[:alpha:]_]*[0-9]/ + m.reply ret.delete_at(0) + end + while ret[0] =~ /^[0-9]/ + m.reply ret.delete_at(0) + end + i = 0 + while i < ret.length + ret[i] = ret[i].slice(/^[[:graph:]_]*/) + if ret[i].length == 0 or ret[i] =~ /^[0-9]/ + then + ret.delete_at(i) + else + i = i+1 + end + end + if ret.length != 0 then + m.reply "zie ook " + ret.join(", ") + end + return + when nil + m.reply "incorrect usage: " + help(m.plugin) + return + else + m.reply "incorrect usage: " + help(m.plugin) + return + end + end +end +plugin = VanDalePlugin.new +plugin.register("vandale") |