add base64 to text transformations
This commit is contained in:
parent
da9e4b3142
commit
977675c593
|
@ -16,6 +16,8 @@ You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import base64
|
||||||
|
|
||||||
from extlib import irclib
|
from extlib import irclib
|
||||||
|
|
||||||
from Module import Module
|
from Module import Module
|
||||||
|
@ -35,6 +37,8 @@ class TextTransform(Module):
|
||||||
|
|
||||||
if self.rot13(what, reply):
|
if self.rot13(what, reply):
|
||||||
return self.reply(connection, replypath, reply[0])
|
return self.reply(connection, replypath, reply[0])
|
||||||
|
elif self.base64(what, reply):
|
||||||
|
return self.reply(connection, replypath, reply[0])
|
||||||
|
|
||||||
def rot13(self, what, reply):
|
def rot13(self, what, reply):
|
||||||
"""
|
"""
|
||||||
|
@ -46,5 +50,18 @@ class TextTransform(Module):
|
||||||
reply[0] = ' '.join(whats[1:]).encode('rot13', 'ignore')
|
reply[0] = ' '.join(whats[1:]).encode('rot13', 'ignore')
|
||||||
return True
|
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
|
# vi:tabstop=4:expandtab:autoindent
|
||||||
# kate: indent-mode python;indent-width 4;replace-tabs on;
|
# kate: indent-mode python;indent-width 4;replace-tabs on;
|
||||||
|
|
Loading…
Reference in New Issue