summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-03-13 22:15:21 +0100
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-03-13 22:15:21 +0100
commitdedf0c19d272f48c8d9d8949e838ba9dda73020a (patch)
tree43fdf0adae8f4ecc77aeccb5bd9307e6b73ecd46 /data
parent1bc0a152a6159ff235c9fb7e872f9e80604883da (diff)
rot13 plugin: provide a filter
Diffstat (limited to 'data')
-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