]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blob - data/rbot/plugins/rot13.rb
plugin(points): new message parser, see #34
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / rot13.rb
1 #-- vim:sw=2:et
2 #++
3 #
4 # :title: ROT13 plugin
5 #
6 class RotPlugin < Plugin
7   def initialize
8     super
9     @bot.register_filter(:rot13) { |s|
10       ss = s.dup
11       ss[:text] = s[:text].tr("A-Za-z", "N-ZA-Mn-za-m")
12       ss
13     }
14   end
15
16   def help(plugin, topic="")
17     "rot13 <string> => encode <string> to rot13 or back"
18   end
19
20   def rot13(m, params)
21     m.reply @bot.filter(:rot13, params[:string].to_s).to_s
22   end
23 end
24 plugin = RotPlugin.new
25 plugin.map 'rot13 *string'