diff options
Diffstat (limited to 'rbot/plugins/fortune.rb')
-rw-r--r-- | rbot/plugins/fortune.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/rbot/plugins/fortune.rb b/rbot/plugins/fortune.rb new file mode 100644 index 00000000..2f76a318 --- /dev/null +++ b/rbot/plugins/fortune.rb @@ -0,0 +1,24 @@ +class FortunePlugin < Plugin + def help(plugin, topic="") + "fortune [<module>] => get a (short) fortune, optionally specifying fortune db" + end + def privmsg(m) + case m.params + when (/\B-/) + m.reply "incorrect usage: " + help(m.plugin) + return + when (/^([\w-]+)$/) + db = $1 + when nil + db = "fortunes" + else + m.reply "incorrect usage: " + help(m.plugin) + return + end + ret = Utils.safe_exec("/usr/games/fortune", "-n", "255", "-s", db) + m.reply ret.split("\n").join(" ") + return + end +end +plugin = FortunePlugin.new +plugin.register("fortune") |