-
Notifications
You must be signed in to change notification settings - Fork 5
/
figlet.py
29 lines (28 loc) · 1.1 KB
/
figlet.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
import pyfiglet
from ULTRA.utils import admin_cmd
#@command(pattern="^.figlet ?(.*)", outgoing=True)
@borg.on(admin_cmd(pattern=r"figlet ?(.*)"))
async def figlet(event):
if event.fwd_from:
return
CMD_FIG = {"slant": "slant", "3D": "3-d", "5line": "5lineoblique", "alpha": "alphabet", "banner": "banner3-D", "doh": "doh", "iso": "isometric1", "letter": "letters", "allig": "alligator", "dotm": "dotmatrix", "bubble": "bubble", "bulb": "bulbhead", "digi": "digital"}
input_str = event.pattern_match.group(1)
if "|" in input_str:
text, cmd = input_str.split("|", maxsplit=1)
elif input_str is not None:
cmd = None
text = input_str
else:
await event.edit("Please add some text to figlet")
return
if cmd is not None:
try:
font = CMD_FIG[cmd]
except KeyError:
await event.edit("Invalid selected font.")
return
result = pyfiglet.figlet_format(text, font=font)
else:
result = pyfiglet.figlet_format(text)
await event.respond("`{}`".format(result))
await event.delete()