Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# vim: noai:ts=4:sw=4:expandtab:syntax=python
import re
from xbotpp.modules import Module
class lolcrypt(Module):
Provide lolcryption.
def __init__(self):
def action(self, bot, event, args, buf):
Lolcrypt the given arguments, or the buffer (if present)
Pass "-d" as the first parameter to de-lolcrypt.
if len(args) is 0 and buf == "":
return "%slolcrypt [-d] <text> or %scommand | lolcrypt [-d]" % (,
delol = (len(args) != 0 and args[0] == "-d")
cipher = list("aeioubcdfghjklmnpqrstvwxyz")
text = buf if buf != "" else " ".join(args[1:]) if delol else " ".join(args[0:])
mod = lambda a, n: ((a%n)+n)%n
buf = ""
for char in text:
caps = re.match("[A-Z]", char)
char = char.lower()
if not char in cipher:
buf += char.upper() if caps else char
i = cipher.index(char)
if re.match("[" + "".join(cipher[0:5]) + "]", char):
if delol:
char = cipher[mod(i-2,5)]
char = cipher[(i+2)%5]
if delol:
char = cipher[mod(i-15,21)+5]
char = cipher[(i+5)%21+5]
buf += char.upper() if caps else char
return buf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.