diff --git a/bot/plugins/useless.py b/bot/plugins/useless.py index 0827889..b0d6e11 100644 --- a/bot/plugins/useless.py +++ b/bot/plugins/useless.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import random +import re import irc3 from docopt import Dict as DocOptDict @@ -324,6 +325,16 @@ class Useless(DatabasePlugin): """ return ' '.join([self._rainbow(i, word) for i, word in enumerate(args[''])]) + @command + def halfwidth(self, mask: IrcString, target: IrcString, args: DocOptDict): + """Turns UPPERCASE words into halfwidth characters + + %%halfwidth + """ + def halfwidth_replace(match): + return "".join(chr(0xFF20+(ord(c)-64)) for c in match.group(0)) + return "[HALFWIDTH] {}".format(re.sub(r'(?:\b)[A-Z]+(?:\b)', halfwidth_replace, args.get(''))) + @command def asshole(self, mask: IrcString, target: IrcString, args: DocOptDict): """Checks how much of an asshole you are.