diff --git a/modules/TextTransform.py b/modules/TextTransform.py index de79500..c77c7ca 100644 --- a/modules/TextTransform.py +++ b/modules/TextTransform.py @@ -16,6 +16,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . """ +import base64 + from extlib import irclib from Module import Module @@ -35,6 +37,8 @@ class TextTransform(Module): if self.rot13(what, reply): return self.reply(connection, replypath, reply[0]) + elif self.base64(what, reply): + return self.reply(connection, replypath, reply[0]) def rot13(self, what, reply): """ @@ -46,5 +50,18 @@ class TextTransform(Module): reply[0] = ' '.join(whats[1:]).encode('rot13', 'ignore') return True + def base64(self, what, reply): + """ + Encode/decode base64 string. + """ + + whats = what.split(' ') + if whats[0] == 'base64e' or whats[0] == 'base64': + reply[0] = base64.encodestring(' '.join(whats[1:])) + return True + if whats[0] == 'base64d': + reply[0] = base64.decodestring(' '.join(whats[1:])) + return True + # vi:tabstop=4:expandtab:autoindent # kate: indent-mode python;indent-width 4;replace-tabs on;