Rename ASCII plugin to IRCArt

This commit is contained in:
oddluck 2019-12-06 06:53:08 +00:00
parent ce548e233a
commit 9d7c5e0b8c
8 changed files with 32 additions and 32 deletions

View File

@ -6,7 +6,7 @@
### ###
""" """
ASCII: Uses API to retrieve information IRCArt: Make IRC Art
""" """
import supybot import supybot

View File

@ -9,7 +9,7 @@ import supybot.conf as conf
import supybot.registry as registry import supybot.registry as registry
try: try:
from supybot.i18n import PluginInternationalization from supybot.i18n import PluginInternationalization
_ = PluginInternationalization('ASCII') _ = PluginInternationalization('IRCArt')
except: except:
# Placeholder that allows to run the plugin on a bot # Placeholder that allows to run the plugin on a bot
# without the i18n module # without the i18n module
@ -22,45 +22,45 @@ def configure(advanced):
# user or not. You should effect your configuration by manipulating the # user or not. You should effect your configuration by manipulating the
# registry as appropriate. # registry as appropriate.
from supybot.questions import expect, anything, something, yn from supybot.questions import expect, anything, something, yn
conf.registerPlugin('ASCII', True) conf.registerPlugin('IRCArt', True)
ASCII = conf.registerPlugin('ASCII') IRCArt = conf.registerPlugin('IRCArt')
conf.registerGlobalValue(ASCII, 'pasteAPI', conf.registerGlobalValue(IRCArt, 'pasteAPI',
registry.String('', _("""Paste.ee API Key"""))) registry.String('', _("""Paste.ee API Key""")))
conf.registerGlobalValue(ASCII, 'imgurAPI', conf.registerGlobalValue(IRCArt, 'imgurAPI',
registry.String('', _("""Imgur Client ID"""))) registry.String('', _("""Imgur Client ID""")))
conf.registerChannelValue(ASCII, 'pasteEnable', conf.registerChannelValue(IRCArt, 'pasteEnable',
registry.Boolean(False, _("""Turns on and off paste.ee support"""))) registry.Boolean(False, _("""Turns on and off paste.ee support""")))
conf.registerChannelValue(ASCII, 'delay', conf.registerChannelValue(IRCArt, '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(ASCII, 'quantize', conf.registerChannelValue(IRCArt, '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(ASCII, 'resize', conf.registerChannelValue(IRCArt, '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(ASCII, 'speed', conf.registerChannelValue(IRCArt, '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(ASCII, 'imgDefault', conf.registerChannelValue(IRCArt, '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(ASCII, 'asciiWidth', conf.registerChannelValue(IRCArt, '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(ASCII, 'blockWidth', conf.registerChannelValue(IRCArt, '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(ASCII, 'colors', conf.registerChannelValue(IRCArt, '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(ASCII, 'fg', conf.registerChannelValue(IRCArt, '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(ASCII, 'bg', conf.registerChannelValue(IRCArt, '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)""")))

View File

@ -28,18 +28,18 @@ from bs4 import BeautifulSoup
try: try:
from supybot.i18n import PluginInternationalization from supybot.i18n import PluginInternationalization
_ = PluginInternationalization('Weed') _ = PluginInternationalization('IRCArt')
except ImportError: except ImportError:
# Placeholder that allows to run the plugin on a bot # Placeholder that allows to run the plugin on a bot
# without the i18n module # without the i18n module
_ = lambda x: x _ = lambda x: x
class ASCII(callbacks.Plugin): class IRCArt(callbacks.Plugin):
"""Uses API to retrieve information""" """IRCArt: Make IRC Art"""
threaded = True threaded = True
def __init__(self, irc): def __init__(self, irc):
self.__parent = super(ASCII, self) self.__parent = super(IRCArt, self)
self.__parent.__init__(irc) self.__parent.__init__(irc)
self.colors = 99 self.colors = 99
self.stopped = {} self.stopped = {}
@ -711,9 +711,9 @@ class ASCII(callbacks.Plugin):
irc.reply(uploaded_image.link, noLengthCheck=True, private=False, notice=False) irc.reply(uploaded_image.link, noLengthCheck=True, private=False, notice=False)
png = wrap(png, [getopts({'bg':'int', 'fg':'int'}), ('text')]) png = wrap(png, [getopts({'bg':'int', 'fg':'int'}), ('text')])
def ascii(self, irc, msg, args, channel, optlist, text): def artii(self, irc, msg, args, channel, optlist, text):
"""[<channel>] [--font <font>] [--color <color1,color2>] [<text>] """[<channel>] [--font <font>] [--color <color1,color2>] [<text>]
Text to ASCII art Text to ASCII figlet fonts using the artii API
""" """
if not channel: if not channel:
channel = msg.args[0] channel = msg.args[0]
@ -765,11 +765,11 @@ class ASCII(callbacks.Plugin):
if line.strip(): if line.strip():
irc.reply(ircutils.mircColor(line, color1, color2), prefixNick=False, private=False, notice=False, to=channel) irc.reply(ircutils.mircColor(line, color1, color2), prefixNick=False, private=False, notice=False, to=channel)
ascii = wrap(ascii, [optional('channel'), getopts({'font':'text', 'color':'text'}), ('text')]) artii = wrap(artii, [optional('channel'), getopts({'font':'text', 'color':'text'}), ('text')])
def fontlist(self, irc, msg, args): def fontlist(self, irc, msg, args):
""" """
get list of fonts for text-to-ascii-art Get list of artii figlet fonts.
""" """
fontlist = requests.get("https://artii.herokuapp.com/fonts_list") fontlist = requests.get("https://artii.herokuapp.com/fonts_list")
response = sorted(fontlist.text.split('\n')) response = sorted(fontlist.text.split('\n'))
@ -778,7 +778,7 @@ class ASCII(callbacks.Plugin):
def img(self, irc, msg, args, channel, optlist, url): def img(self, irc, msg, args, channel, optlist, url):
"""[<#channel>] [--delay #.#] [--w <###>] [--s <#.#] [--16] [--99] [--83] [--ascii] [--block] [--1/2] [--chars <text>] [--ramp <text>] [--bg <0-98>] [--fg <0-98>] [--no-color] [--invert] <url> """[<#channel>] [--delay #.#] [--w <###>] [--s <#.#] [--16] [--99] [--83] [--ascii] [--block] [--1/2] [--chars <text>] [--ramp <text>] [--bg <0-98>] [--fg <0-98>] [--no-color] [--invert] <url>
Image to ASCII Art. Image to IRC art.
--w columns. --w columns.
--s saturation (1.0). --s saturation (1.0).
--16 colors 0-15. --16 colors 0-15.
@ -1112,7 +1112,7 @@ class ASCII(callbacks.Plugin):
def scroll(self, irc, msg, args, channel, optlist, url): def scroll(self, irc, msg, args, channel, optlist, url):
"""[<channel>] [--delay] <url> """[<channel>] [--delay] <url>
Play ASCII/ANSI art text files from web links. Play IRC art files from web links.
""" """
if not channel: if not channel:
channel = msg.args[0] channel = msg.args[0]
@ -1364,7 +1364,7 @@ class ASCII(callbacks.Plugin):
def toilet(self, irc, msg, args, channel, optlist, text): def toilet(self, irc, msg, args, channel, optlist, text):
"""[<channel>] [--f fontname] [--F filter1,filter2,etc.] [--w] [--delay] <text> """[<channel>] [--f fontname] [--F filter1,filter2,etc.] [--w] [--delay] <text>
Toilet. -f to select font. -F to select filters. Separate multiple filters with a comma. Text to toilet figlets. -f to select font. -F to select filters. Separate multiple filters with a comma.
""" """
if not channel: if not channel:
channel = msg.args[0] channel = msg.args[0]
@ -1449,7 +1449,7 @@ class ASCII(callbacks.Plugin):
def wttr(self, irc, msg, args, channel, optlist, location): def wttr(self, irc, msg, args, channel, optlist, location):
"""[<channel>] [--16] [--99] <location/moon> """[<channel>] [--16] [--99] <location/moon>
ASCII weather report from wttr.in for <location>. IRC art weather report from wttr.in for <location>.
--16 for 16 colors (default). --16 for 16 colors (default).
--99 for 99 colors. --99 for 99 colors.
Get moon phase with 'wttr moon'. Get moon phase with 'wttr moon'.
@ -1592,7 +1592,7 @@ class ASCII(callbacks.Plugin):
def fortune(self, irc, msg, args, channel, optlist): def fortune(self, irc, msg, args, channel, optlist):
"""[<channel>] """[<channel>]
Returns a random ASCII from http://www.asciiartfarts.com/fortune.txt Returns random art fortune from http://www.asciiartfarts.com/fortune.txt
""" """
if not channel: if not channel:
channel = msg.args[0] channel = msg.args[0]
@ -1658,4 +1658,4 @@ class ASCII(callbacks.Plugin):
irc.reply("Stopping.") irc.reply("Stopping.")
cq = wrap(cq) cq = wrap(cq)
Class = ASCII Class = IRCArt

View File

@ -11,7 +11,7 @@ from supybot.test import *
class AdviceTestCase(PluginTestCase): class AdviceTestCase(PluginTestCase):
plugins = ('ASCII',) plugins = ('IRCArt',)
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: