X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Frot13.rb;h=4176772631a1ec674fb7e51c1e16527488713921;hb=0ddf77c9d54236bbc75c2b603871fc0c9e072873;hp=447d0803198d1342d7d5fc258a65d86192f01c0c;hpb=164c96aef65888b947d241306438ffd20d81d6a7;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/rot13.rb b/data/rbot/plugins/rot13.rb index 447d0803..41767726 100644 --- a/data/rbot/plugins/rot13.rb +++ b/data/rbot/plugins/rot13.rb @@ -1,9 +1,24 @@ +#-- 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 rot13(m, params) - m.reply params[:string].join(" ").tr("A-Za-z", "N-ZA-Mn-za-m"); + m.reply @bot.filter(:rot13, params[:string].to_s).to_s end end plugin = RotPlugin.new