]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blob - rbot/plugins/fortune.rb
initial import of rbot
[user/henk/code/ruby/rbot.git] / rbot / plugins / fortune.rb
1 class FortunePlugin < Plugin
2   def help(plugin, topic="")
3     "fortune [<module>] => get a (short) fortune, optionally specifying fortune db"
4   end
5   def privmsg(m)
6     case m.params
7     when (/\B-/)
8       m.reply "incorrect usage: " + help(m.plugin)
9       return
10     when (/^([\w-]+)$/)
11       db = $1
12     when nil
13       db = "fortunes"
14     else
15       m.reply "incorrect usage: " + help(m.plugin)
16       return
17     end
18     ret = Utils.safe_exec("/usr/games/fortune", "-n", "255", "-s", db)
19     m.reply ret.split("\n").join(" ")
20     return
21   end
22 end
23 plugin = FortunePlugin.new
24 plugin.register("fortune")