]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/rot13.rb
[plugin] geoip small fixes, needs more work
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / rot13.rb
index 447d0803198d1342d7d5fc258a65d86192f01c0c..4176772631a1ec674fb7e51c1e16527488713921 100644 (file)
@@ -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 <string> => encode <string> 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