Last active
January 23, 2023 18:29
-
-
Save erchn/029bbd79863c4b351445cff7742b7313 to your computer and use it in GitHub Desktop.
Over engineered helper for Slack trolling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import subprocess | |
from string import ascii_letters | |
from optparse import OptionParser | |
parser = OptionParser() | |
parser.add_option( | |
"-y", | |
dest="yellow", | |
default=False, | |
action="store_true", | |
help="Use alphabet-yellow instead of white", | |
) | |
parser.add_option( | |
"-a", | |
dest="alternate", | |
default=False, | |
action="store_true", | |
help="Use alphabet-yellow and alphabet-white alternatingly", | |
) | |
opts, args = parser.parse_args() | |
if opts.alternate: | |
color = ["yellow", "white"] | |
else: | |
color = ["yellow"] if opts.yellow else ["white"] | |
colorstr = ", ".join(set(color)) | |
chars = { | |
**{"@": "at", "!": "exclamation", "#": "hash", "?": "question"}, | |
**{x: x for x in ascii_letters}, | |
} | |
def write_to_clipboard(output): | |
process = subprocess.Popen( | |
"pbcopy", env={"LANG": "en_US.UTF-8"}, stdin=subprocess.PIPE | |
) | |
process.communicate(output.encode("utf-8")) | |
inputstring = input("string to convert: ") if not args else args.pop() | |
out = "".join( | |
[ | |
f":alphabet-{color[ind % len(color)]}-{chars[char]}:" if char in chars else char | |
for ind, char in enumerate(inputstring) | |
] | |
) | |
print(f"\n{out}\n") | |
try: | |
write_to_clipboard(out) | |
print(f"Alphabet {colorstr} string written to your clipboard!") | |
except FileNotFoundError as err: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment