TextArt: Queue artii replies.

This commit is contained in:
oddluck 2020-07-20 21:50:08 +00:00
parent f9723e4836
commit 6a45509975

View File

@ -223,7 +223,7 @@ class TextArt(callbacks.Plugin):
XYZ[2] = round(Z, 4)
XYZ[0] = (
float(XYZ[0]) / 95.047
) # ref_X = 95.047 Observer= 2°, Illuminant= D65
) # ref_X = 95.047 Observer= 2, Illuminant= D65
XYZ[1] = float(XYZ[1]) / 100.0 # ref_Y = 100.000
XYZ[2] = float(XYZ[2]) / 108.883 # ref_Z = 108.883
num = 0
@ -497,6 +497,10 @@ class TextArt(callbacks.Plugin):
optlist = dict(optlist)
font = None
words = []
if "delay" in optlist:
delay = optlist.get("delay")
else:
delay = self.registryValue("delay", msg.args[0])
if text:
text = text.strip()
if "|" in text:
@ -535,14 +539,11 @@ class TextArt(callbacks.Plugin):
)
)
return
output = []
for line in data.content.decode().splitlines():
if line.strip():
irc.reply(
ircutils.mircColor(line, color1, color2),
prefixNick=False,
private=False,
notice=False,
)
line = ircutils.mircColor(line, color1, color2)
output.append(line)
asyncio.run(self.reply(irc, output, channel, delay))
else:
try:
data = requests.get(
@ -558,15 +559,11 @@ class TextArt(callbacks.Plugin):
) as e:
log.debug("TextArt: error retrieving data for artii: {0}".format(e))
return
output = []
for line in data.content.decode().splitlines():
if line.strip():
irc.reply(
ircutils.mircColor(line, color1, color2),
prefixNick=False,
private=False,
notice=False,
to=channel,
)
line = ircutils.mircColor(line, color1, color2)
output.append(line)
asyncio.run(self.reply(irc, output, channel, delay))
elif "font" not in optlist:
if words:
for word in words:
@ -588,15 +585,11 @@ class TextArt(callbacks.Plugin):
)
)
return
output = []
for line in data.content.decode().splitlines():
if line.strip():
irc.reply(
ircutils.mircColor(line, color1, color2),
prefixNick=False,
private=False,
notice=False,
to=channel,
)
line = ircutils.mircColor(line, color1, color2)
output.append(line)
asyncio.run(self.reply(irc, output, channel, delay))
else:
try:
data = requests.get(
@ -612,18 +605,19 @@ class TextArt(callbacks.Plugin):
) as e:
log.debug("TextArt: error retrieving data for artii: {0}".format(e))
return
output = []
for line in data.content.decode().splitlines():
if line.strip():
irc.reply(
ircutils.mircColor(line, color1, color2),
prefixNick=False,
private=False,
notice=False,
to=channel,
)
line = ircutils.mircColor(line, color1, color2)
output.append(line)
asyncio.run(self.reply(irc, output, channel, delay))
artii = wrap(
artii, [optional("channel"), getopts({"font": "text", "color": "text"}), "text"]
artii,
[
optional("channel"),
getopts({"font": "text", "color": "text", "delay": "float"}),
"text",
],
)
def fontlist(self, irc, msg, args):
@ -826,20 +820,20 @@ class TextArt(callbacks.Plugin):
if color1 == color2:
gsval = " "
else:
gsval = ""
gsval = ""
if color1 == old_color1 and color2 == old_color2:
aimg[k] += gsval
old_char = gsval
elif gsval == " " and color1 == old_color2:
aimg[k] += " "
old_char = gsval
elif gsval == " " and color1 == old_color1 and old_char == "":
elif gsval == " " and color1 == old_color1 and old_char == "":
aimg[k] = aimg[k][:-1]
aimg[k] += "\x0301,{0} ".format(color1)
old_color1 = "01"
old_color2 = color1
old_char = gsval
elif gsval == " " and color1 == old_color1 and old_char == "^":
elif gsval == " " and color1 == old_color1 and old_char == "^":
aimg[k] = aimg[k][:-4]
aimg[k] += "\x0301,{0} ".format(color1)
old_color1 = "01"
@ -848,40 +842,40 @@ class TextArt(callbacks.Plugin):
elif (
gsval == " "
and color1 == old_color1
and old_char == "^^"
and old_char == "^^"
and "tops" not in optlist
):
aimg[k] = aimg[k][:-7]
aimg[k] += "\x03{0},{1} ".format(old_color2, color1)
aimg[k] += "\x03{0},{1} ".format(old_color2, color1)
old_color1 = old_color2
old_color2 = color1
old_char = gsval
elif (
gsval == " "
and color1 == old_color1
and old_char != ""
and old_char != ""
and "tops" not in optlist
):
aimg[k] += ""
old_char = ""
aimg[k] += ""
old_char = ""
elif gsval == " " and "tops" not in optlist:
aimg[k] += "\x03{0}".format(color1)
aimg[k] += "\x03{0}".format(color1)
old_color1 = color1
old_char = "^"
old_char = "^"
elif (
gsval != " "
and color1 == old_color1
and old_char == "^"
and old_char == "^"
and "tops" not in optlist
):
aimg[k] = aimg[k][:-4]
aimg[k] += "\x03{0},{1} ".format(color2, color1)
aimg[k] += "\x03{0},{1} ".format(color2, color1)
old_color1 = color2
old_color2 = color1
old_char = ""
elif gsval != " " and color2 == old_color1 and old_char == "^":
old_char = ""
elif gsval != " " and color2 == old_color1 and old_char == "^":
aimg[k] = aimg[k][:-4]
aimg[k] += "\x03{0},{1} ".format(color1, color2)
aimg[k] += "\x03{0},{1} ".format(color1, color2)
old_color1 = color1
old_color2 = color2
old_char = gsval
@ -889,11 +883,11 @@ class TextArt(callbacks.Plugin):
gsval != " "
and color1 == old_color2
and color2 == old_color1
and old_char == "^^"
and old_char == "^^"
and "tops" not in optlist
):
aimg[k] = aimg[k][:-7]
aimg[k] += "\x03{0},{1}▄▀".format(color1, color2)
aimg[k] += "\x03{0},{1}".format(color1, color2)
old_color1 = color1
old_color2 = color2
old_char = gsval
@ -901,51 +895,51 @@ class TextArt(callbacks.Plugin):
gsval != " "
and color1 == old_color1
and color2 != old_color2
and old_char == "^^"
and old_char == "^^"
and "tops" not in optlist
):
aimg[k] = aimg[k][:-7]
aimg[k] += "\x03{0},{1}\x03{2}".format(
aimg[k] += "\x03{0},{1}\x03{2}".format(
old_color2, color1, color2
)
old_color1 = color2
old_color2 = color1
old_char = ""
old_char = ""
elif (
gsval != " "
and color1 == old_color1
and color2 != old_color2
and old_char == "^"
and old_char == "^"
and "tops" not in optlist
):
aimg[k] = aimg[k][:-4]
aimg[k] += "\x03{0},{1}\x03{2}".format(
aimg[k] += "\x03{0},{1}\x03{2}".format(
old_color2, color1, color2
)
old_color1 = color2
old_color2 = color1
old_char = ""
old_char = ""
elif (
gsval != " "
and color1 == old_color2
and color2 == old_color1
and "tops" not in optlist
):
aimg[k] += ""
old_char = ""
aimg[k] += ""
old_char = ""
elif (
gsval != " " and color1 == old_color2 and "tops" not in optlist
):
aimg[k] += "\x03{0}".format(color2)
aimg[k] += "\x03{0}".format(color2)
old_color1 = color2
old_char = ""
old_char = ""
elif color1 != old_color1 and color2 == old_color2:
aimg[k] += "\x03{0}{1}".format(color1, gsval)
old_color1 = color1
if gsval == " ":
old_char = gsval
else:
old_char = "^"
old_char = "^"
else:
aimg[k] += "\x03{0},{1}{2}".format(color1, color2, gsval)
old_color1 = color1
@ -953,7 +947,7 @@ class TextArt(callbacks.Plugin):
if gsval == " ":
old_char = gsval
else:
old_char = "^^"
old_char = "^^"
if "tops" in optlist:
aimg[k] = re.sub("\x03\d\d,(\d\d\s+\x03)", "\x0301,\g<1>", aimg[k])
aimg[k] = re.sub("\x03\d\d,(\d\d\s+$)", "\x0301,\g<1>", aimg[k])
@ -1601,8 +1595,8 @@ class TextArt(callbacks.Plugin):
file = requests.get("http://wttr.in/{0}".format(location), timeout=10)
output = file.content.decode()
output = self.ansi2irc(output)
output = re.sub("", " ", output)
output = re.sub("", " ", output)
output = re.sub("", " ", output)
output = re.sub("", " ", output)
output = re.sub("\n\nFollow.*$", "", output)
self.stopped[channel] = False
output = output.splitlines()