added .halfwidth

This commit is contained in:
Cephra 2017-08-22 14:57:07 +02:00
parent 87a0111e74
commit da0aea1427

View File

@ -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['<words>'])])
@command
def halfwidth(self, mask: IrcString, target: IrcString, args: DocOptDict):
"""Turns UPPERCASE words into halfwidth characters
%%halfwidth <text>
"""
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('<word>')))
@command
def asshole(self, mask: IrcString, target: IrcString, args: DocOptDict):
"""Checks how much of an asshole you are.