Skip to content

Instantly share code, notes, and snippets.

@gbin
Created October 4, 2015 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbin/6cbce1ad86379a02eb10 to your computer and use it in GitHub Desktop.
Save gbin/6cbce1ad86379a02eb10 to your computer and use it in GitHub Desktop.
Errbot recipes: Arguments parsing.
from errbot import BotPlugin, botcmd
from pyfiglet import Figlet, FigletFont
class AsciiArt(BotPlugin):
""" Ascii Art related commands. """
@botcmd(split_args_with=' ')
def big(self, mess, args):
""" Generates a big version of what you want to say."""
fonts = FigletFont.getFonts()
if len(args) <= 1 or args[0] not in fonts:
return ('Syntax: `!big font message` with *font* in:\n`' + ', '.join(fonts) + '`')
font = args[0]
message = ' '.join(args[1:])
return '```\n' + Figlet(font=font).renderText(message) + '\n```'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment