26 lines
880 B
Python
26 lines
880 B
Python
import random
|
|
import pyfiglet
|
|
|
|
from maubot import Plugin, MessageEvent
|
|
from maubot.handlers import command
|
|
|
|
|
|
class FigletBot(Plugin):
|
|
|
|
@command.new("figlet", help="display text in large ascii fonts")
|
|
@command.argument("message", pass_raw=True)
|
|
async def figlet_handler(self, evt: MessageEvent, message: str) -> None:
|
|
message = message.strip()
|
|
fonts = pyfiglet.FigletFont.getFonts()
|
|
if message.lower() == 'star wars' and 'starwars' in fonts:
|
|
fontname = 'starwars'
|
|
elif message.lower() == 'star trek' and 'trek' in fonts:
|
|
fontname = 'trek'
|
|
else:
|
|
fontname = fonts[random.randint(0, len(fonts) - 1)]
|
|
|
|
fig = pyfiglet.Figlet(font=fontname)
|
|
msg = f'Rendering with: {fontname}\n\n```'
|
|
msg += fig.renderText(message).strip()
|
|
msg += '```'
|
|
await evt.respond(msg)
|