-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathats.py
49 lines (42 loc) · 1.77 KB
/
ats.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""Convert a text message into ascii-art text and its representation in emojis,
suitable for copying and pasting into Slack"""
from art import *
import argparse
def emojify(ascii_art, emoji, blank_emoji):
emojied = []
emojied.append(colonify(blank_emoji))
for each in ascii_art:
if each == " ":
emojied.append(colonify(blank_emoji))
elif each in ("\n"):
emojied.append("\n")
emojied.append(colonify(blank_emoji)) # this will leave one extra blank at the end
elif each in ("\r"):
pass
else:
emojied.append(colonify(emoji))
del emojied[-1] # remove the extra blank
return "".join(emojied)
def colonify(emoji_text):
return "".join([":", emoji_text, ":"])
def main():
parser = argparse.ArgumentParser(description='text to ascii art to slack')
# '5x7' is a tall skinny font that only uses hashtags in output
# Complete font list is available at
# See https://github.com/sepandhaghighi/art/blob/master/FontList.ipynb
parser.add_argument("--font", default='5x7', help='name of art lib font to use')
parser.add_argument("-e", "--emoji", default='smile', help='emoji name')
# a completely blank emoji would work best, but this is an ok substitute in the default emoji pack
parser.add_argument("-b", "--blank-emoji", default='white_small_square')
parser.add_argument("-m", "--message", required=True, help='short text message')
args=parser.parse_args()
print()
print(f"Converting '{args.message}' to representation using {colonify(args.emoji)}")
Art = text2art(args.message, args.font)
Emojified = emojify(Art, args.emoji, args.blank_emoji)
print()
print(Art)
print()
print(Emojified)
if __name__ == "__main__":
main()