diff --git a/plugins/Format.py b/plugins/Format.py index 0830a1667..303c2a068 100644 --- a/plugins/Format.py +++ b/plugins/Format.py @@ -108,6 +108,24 @@ class Format(callbacks.Privmsg): return irc.reply(ircutils.mircColor(text, fg=fg, bg=bg)) + def format(self, irc, msg, args): + """ [ ...] + + Expands a Python-style format string using the remaining args. Just be + sure always to use %s, not %d or %f or whatever, because all the args + are strings. + """ + try: + s = args.pop(0) + except IndexError: + raise callbacks.ArgumentError + try: + s %= tuple(args) + except TypeError: + irc.error('Not enough arguments for the format string.') + return + irc.reply(s) + Class = Format