6 class SpellPlugin < Plugin
7 Config.register Config::StringValue.new('spell.path',
9 :desc => _('Path to the program to use to check spelling'))
10 Config.register Config::StringValue.new('spell.command_line',
11 :default => '%s -a -S',
12 :desc => _('Command line used to call the spell.path. Use %s as a placeholder for the executable name'))
14 def help(plugin, topic="")
15 _("spell <word> => check spelling of <word>, suggest alternatives")
18 unless(m.params && m.params =~ /^\S+$/)
19 m.reply _("incorrect usage: ") + help(m.plugin)
24 IO.popen(@bot.config['spell.command_line'] % @bot.config['spell.path'], "w+") { |p|
30 m.reply(_("%{word} may be spelled correctly") % {:word => m.params})
32 m.reply "#{m.params}: #$1"
34 m.reply((_("%{word} is presumably derived from ") % {:word => m.params}) + $1.downcase)
36 m.reply(_("%{word}: no suggestions") % {:word => m.params})
42 m.reply(_("couldn't exec %{prog} :(") % {:prog => @bot.config['spell.path']})
45 m.reply(_("something odd happened while checking %{word} with %{prog}") % {
46 :word => m.params, :prog => @bot.config['spell.path']
50 plugin = SpellPlugin.new
51 plugin.register("spell")