From 0f3e302547363ea237454dda891ddb5de1be4476 Mon Sep 17 00:00:00 2001 From: Tom Gilbert Date: Sat, 9 Oct 2004 01:51:05 +0000 Subject: initial import of rbot --- rbot/plugins/spell.rb | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 rbot/plugins/spell.rb (limited to 'rbot/plugins/spell.rb') diff --git a/rbot/plugins/spell.rb b/rbot/plugins/spell.rb new file mode 100644 index 00000000..eb80a48d --- /dev/null +++ b/rbot/plugins/spell.rb @@ -0,0 +1,36 @@ +class SpellPlugin < Plugin + def help(plugin, topic="") + "spell => check spelling of , suggest alternatives" + end + def privmsg(m) + unless(m.params && m.params =~ /^\w+$/) + m.reply "incorrect usage: " + help(m.plugin) + return + end + p = IO.popen("ispell -a -S", "w+") + if(p) + p.puts m.params + p.close_write + p.each_line {|l| + if(l =~ /^\*/) + m.reply "#{m.params} may be spelled correctly" + return + elsif(l =~ /^\s*&.*: (.*)$/) + m.reply "#{m.params}: #$1" + return + elsif(l =~ /^\s*\+ (.*)$/) + m.reply "#{m.params} is presumably derived from " + $1.downcase + return + elsif(l =~ /^\s*#/) + m.reply "#{m.params}: no suggestions" + return + end + } + else + m.reply "couldn't exec ispell :(" + return + end + end +end +plugin = SpellPlugin.new +plugin.register("spell") -- cgit v1.2.3