This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
CloudBot/plugins/flip.py

66 lines
1.2 KiB
Python
Raw Normal View History

2011-11-20 10:23:31 +01:00
from util import hook
import random
@hook.command
2012-02-29 09:29:53 +01:00
def flip(inp, flip_count=0, say=None):
2012-02-28 03:03:43 +01:00
".flip <text> -- Flips <text> over."
2011-11-20 10:23:31 +01:00
guy = unicode(random.choice(flips), 'utf8')
inp = inp.lower()
inp = inp[::-1]
reps = 0
for n in xrange(len(inp)):
rep = character_replacements.get(inp[n])
if rep:
inp = inp[:n] + rep.decode('utf8') + inp[n + 1:]
reps += 1
if reps == flip_count:
break
say(guy + u"" + inp)
flips = ["(屮ಠ︵ಠ)屮",
"( ノ♉︵♉ )ノ",
"(╯°□°)╯",
"( ノ⊙︵⊙)ノ"]
2012-02-29 09:29:53 +01:00
2011-11-20 10:23:31 +01:00
character_replacements = {
'a': 'ɐ',
'b': 'q',
'c': 'ɔ',
'd': 'p',
'e': 'ǝ',
'f': 'ɟ',
'g': 'b',
'h': 'ɥ',
'i': 'ı',
'j': 'ظ',
'k': 'ʞ',
'l': 'ן',
'm': 'ɯ',
'n': 'u',
'o': 'o',
'p': 'd',
'q': 'b',
'r': 'ɹ',
's': 's',
't': 'ʇ',
'u': 'n',
'v': 'ʌ',
'w': 'ʍ',
'x': 'x',
'y': 'ʎ',
'z': 'z',
'?': '¿',
'.': '˙',
'/': '\\',
'\\': '/',
'(': ')',
')': '(',
'<': '>',
'>': '<',
'[': ']',
']': '[',
'{': '}',
'}': '{',
'\'': ',',
'_': ''}