X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Frot13.rb;h=36155962953ea07247bd01439bb779b83e380a84;hb=13391804db9e84749580811089f4be8e52dd1e0b;hp=1f367dbda9933ec3881ca10b0b9efd517ec8bf95;hpb=21949774b91eaec6ecde4eaa8ad121e2c0a36b87;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/rot13.rb b/data/rbot/plugins/rot13.rb index 1f367dbd..36155962 100644 --- a/data/rbot/plugins/rot13.rb +++ b/data/rbot/plugins/rot13.rb @@ -1,14 +1,25 @@ +#-- vim:sw=2:et +#++ +# +# :title: ROT13 plugin +# class RotPlugin < Plugin + def initialize + super + @bot.register_filter(:rot13) { |s| + ss = s.dup + ss[:text] = s[:text].tr("A-Za-z", "N-ZA-Mn-za-m") + ss + } + end + def help(plugin, topic="") "rot13 => encode to rot13 or back" end - def privmsg(m) - unless(m.params && m.params =~ /^.+$/) - m.reply "incorrect usage: " + help(m.plugin) - return - end - m.reply m.params.tr("A-Za-z", "N-ZA-Mn-za-m"); + + def rot13(m, params) + m.reply @bot.filter(:rot13, params[:string].to_s) end end plugin = RotPlugin.new -plugin.register("rot13") +plugin.map 'rot13 *string'