summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/rbot/plugins/rot13.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/data/rbot/plugins/rot13.rb b/data/rbot/plugins/rot13.rb
index 447d0803..36155962 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 <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)
end
end
plugin = RotPlugin.new