transform: use codecs library for rot13

This commit is contained in:
Brian S. Stephan 2016-01-16 19:36:51 -06:00
parent c3c54b9f10
commit 59c593f60b
1 changed files with 3 additions and 1 deletions

View File

@ -1,6 +1,7 @@
"""Assorted text transformations (e.g. rot13)."""
import base64
import codecs
from ircbot.lib import Plugin
@ -40,7 +41,8 @@ class Transform(Plugin):
"""Apply a rot13 method to the text."""
text = match.group(1)
return self.bot.reply(event, text.encode('rot13', 'ignore'))
encoder = codecs.getencoder('rot13')
return self.bot.reply(event, encoder(text)[0])
def handle_base64(self, connection, event, match):
"""Apply a base64 encoding to the text."""