TextArt: maxLength config for text to figlets

This commit is contained in:
oddluck 2020-03-18 02:21:52 +00:00
parent 3ee4f502ec
commit 7226e2c377
2 changed files with 24 additions and 15 deletions

View File

@ -49,46 +49,49 @@ def configure(advanced):
TextArt = conf.registerPlugin('TextArt')
conf.registerGlobalValue(TextArt, 'pasteAPI',
registry.String('', _("""Paste.ee API Key""")))
registry.String('', _("""Paste.ee API Key""")))
conf.registerGlobalValue(TextArt, 'imgurAPI',
registry.String('', _("""Imgur Client ID""")))
registry.String('', _("""Imgur Client ID""")))
conf.registerChannelValue(TextArt, 'pasteEnable',
registry.Boolean(False, _("""Turns on and off paste.ee support""")))
registry.Boolean(False, _("""Turns on and off paste.ee support""")))
conf.registerChannelValue(TextArt, 'showStats',
registry.Boolean(False, _("""Turns on and off showing render stats.""")))
registry.Boolean(False, _("""Turns on and off showing render stats.""")))
conf.registerChannelValue(TextArt, 'delay',
registry.Float(1.0, _("""Set the time delay betwen lines. Not currently implemented.""")))
registry.Float(1.0, _("""Set the time delay betwen lines. Not currently implemented.""")))
conf.registerChannelValue(TextArt, 'quantize',
registry.Boolean(False, _("""Enable quantizing to 256 colors before rendering. Results in much faster rendering at a slight decrease in quality. Default: False""")))
registry.Boolean(False, _("""Enable quantizing to 256 colors before rendering. Results in much faster rendering at a slight decrease in quality. Default: False""")))
conf.registerChannelValue(TextArt, 'resize',
registry.Integer(3, _("""Set the resize algorithm. 0 = nearest, 1 = lanczos, 2 = bilinear, 3 = bicubic, 4 = box, 5 = hamming""")))
registry.Integer(3, _("""Set the resize algorithm. 0 = nearest, 1 = lanczos, 2 = bilinear, 3 = bicubic, 4 = box, 5 = hamming""")))
conf.registerChannelValue(TextArt, 'speed',
registry.String('Slow', _("""Set the speed of the color rendering. 'Slow' (default) to use CIEDE2000 color difference. 'Fast' to use Euclidean color difference.""")))
registry.String('Slow', _("""Set the speed of the color rendering. 'Slow' (default) to use CIEDE2000 color difference. 'Fast' to use Euclidean color difference.""")))
conf.registerChannelValue(TextArt, 'imgDefault',
registry.String('1/2', _("""Set the default art type for the img command. Options are 'ascii', '1/2' (default), '1/4', 'block', and 'no-color'""")))
registry.String('1/2', _("""Set the default art type for the img command. Options are 'ascii', '1/2' (default), '1/4', 'block', and 'no-color'""")))
conf.registerChannelValue(TextArt, 'asciiWidth',
registry.Integer(100, _("""Set the default column width for ascii art images""")))
registry.Integer(100, _("""Set the default column width for ascii art images""")))
conf.registerChannelValue(TextArt, 'blockWidth',
registry.Integer(80, _("""Set the default column width for 1/2 and 1/4 block art images""")))
registry.Integer(80, _("""Set the default column width for 1/2 and 1/4 block art images""")))
conf.registerChannelValue(TextArt, 'colors',
registry.Integer(99, _("""Set the default number of colors to use. Options are 16 for colors 0-15 only, 83 for colors 16-98 only, and 99 (default) to use all available colors""")))
registry.Integer(99, _("""Set the default number of colors to use. Options are 16 for colors 0-15 only, 83 for colors 16-98 only, and 99 (default) to use all available colors""")))
conf.registerChannelValue(TextArt, 'fg',
registry.Integer(99, _("""Set the default foreground color for ascii art images. 0-98. 99 is disabled (default)""")))
registry.Integer(99, _("""Set the default foreground color for ascii art images. 0-98. 99 is disabled (default)""")))
conf.registerChannelValue(TextArt, 'bg',
registry.Integer(99, _("""Set the default background color for ascii art images. 0-98. 99 is disabled (default)""")))
registry.Integer(99, _("""Set the default background color for ascii art images. 0-98. 99 is disabled (default)""")))
conf.registerChannelValue(TextArt, 'maxLength',
registry.Integer(20, _("""Set the maximum character length for text to figlet inputs""")))
conf.registerGlobalValue(TextArt, 'userAgents',
registry.CommaSeparatedListOfStrings(["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0"], _("""Reported user agent when fetching links""")))
registry.CommaSeparatedListOfStrings(["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0"], _("""Reported user agent when fetching links""")))

View File

@ -417,6 +417,8 @@ class TextArt(callbacks.Plugin):
if not channel:
channel = msg.args[0]
channel = msg.args[0]
if len(text) > self.registryValue('maxLength', msg.channel):
return
optlist = dict(optlist)
font = None
words = []
@ -1012,6 +1014,8 @@ class TextArt(callbacks.Plugin):
if channel != msg.args[0] and not ircdb.checkCapability(msg.prefix, 'admin'):
irc.errorNoCapability('admin')
return
if len(text) > self.registryValue('maxLength', msg.channel):
return
optlist = dict(optlist)
opts = ''
if 'f' in optlist:
@ -1070,6 +1074,8 @@ class TextArt(callbacks.Plugin):
if channel != msg.args[0] and not ircdb.checkCapability(msg.prefix, 'admin'):
irc.errorNoCapability('admin')
return
if len(text) > self.registryValue('maxLength', msg.channel):
return
optlist = dict(optlist)
opts = ''
if 'f' in optlist: