-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfiglet.py
47 lines (35 loc) · 963 Bytes
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import shlex
from sopel import module
from pyfiglet import Figlet
def configure(config):
pass
def setup(bot):
pass
@module.commands('figlet', 'f', 'fig')
@module.example('.figlet BIG TEXT')
@module.rate(user=30, channel=10)
def figlet(bot, trigger):
"""Sends BIG TEXT"""
valid_args = ["--font"]
text = trigger.group(2)
if not text:
return bot.reply("I need something to figlet")
args = {}
tmp = shlex.split(text)
for index,word in enumerate(tmp):
if word in valid_args:
args[word.replace("--", "")] = tmp[index + 1]
tmp.pop(index)
tmp.pop(index)
text = " ".join(tmp)
if not args:
font = 'standard'
else:
font = args['font']
try:
fig = Figlet(font=font)
except:
fig = Figlet(font='standard')
for let in fig.renderText(text.strip() or "").rsplit("\n"):
if let.strip():
bot.say(let)