mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-05-02 16:31:13 -05:00
TextArt: Fix private message handling.
This commit is contained in:
parent
67f7903be8
commit
bcb990023f
@ -87,6 +87,8 @@ class TextArt(callbacks.Plugin):
|
|||||||
|
|
||||||
def doPrivmsg(self, irc, msg):
|
def doPrivmsg(self, irc, msg):
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
|
if not irc.isChannel(channel):
|
||||||
|
channel = msg.nick
|
||||||
self.stopped.setdefault(channel, None)
|
self.stopped.setdefault(channel, None)
|
||||||
if msg.args[1].lower().strip()[1:] == "cq":
|
if msg.args[1].lower().strip()[1:] == "cq":
|
||||||
self.stopped[channel] = True
|
self.stopped[channel] = True
|
||||||
@ -466,6 +468,7 @@ class TextArt(callbacks.Plugin):
|
|||||||
png = wrap(png, [getopts({"bg": "int", "fg": "int"}), "text"])
|
png = wrap(png, [getopts({"bg": "int", "fg": "int"}), "text"])
|
||||||
|
|
||||||
async def reply(self, irc, output, channel, delay):
|
async def reply(self, irc, output, channel, delay):
|
||||||
|
self.stopped.setdefault(channel, None)
|
||||||
for line in output:
|
for line in output:
|
||||||
if self.stopped[channel]:
|
if self.stopped[channel]:
|
||||||
return
|
return
|
||||||
@ -1036,7 +1039,7 @@ class TextArt(callbacks.Plugin):
|
|||||||
else:
|
else:
|
||||||
aimg[j] += "{0}".format(gsval)
|
aimg[j] += "{0}".format(gsval)
|
||||||
output = aimg
|
output = aimg
|
||||||
self.stopped[msg.args[0]] = False
|
self.stopped[channel] = False
|
||||||
end_time = time.time()
|
end_time = time.time()
|
||||||
asyncio.run(self.reply(irc, output, channel, delay))
|
asyncio.run(self.reply(irc, output, channel, delay))
|
||||||
if self.registryValue("pasteEnable", msg.args[0]):
|
if self.registryValue("pasteEnable", msg.args[0]):
|
||||||
@ -1101,7 +1104,7 @@ class TextArt(callbacks.Plugin):
|
|||||||
if not irc.isChannel(channel):
|
if not irc.isChannel(channel):
|
||||||
channel = msg.nick
|
channel = msg.nick
|
||||||
optlist = dict(optlist)
|
optlist = dict(optlist)
|
||||||
self.stopped[msg.args[0]] = False
|
self.stopped[channel] = False
|
||||||
if "delay" in optlist:
|
if "delay" in optlist:
|
||||||
delay = optlist.get("delay")
|
delay = optlist.get("delay")
|
||||||
else:
|
else:
|
||||||
@ -1209,7 +1212,7 @@ class TextArt(callbacks.Plugin):
|
|||||||
except:
|
except:
|
||||||
irc.reply("Invalid file type.")
|
irc.reply("Invalid file type.")
|
||||||
return
|
return
|
||||||
self.stopped[msg.args[0]] = False
|
self.stopped[channel] = False
|
||||||
output = re.sub("(\x03(\d+).*)\x03,", "\g<1>\x03\g<2>,", output.decode())
|
output = re.sub("(\x03(\d+).*)\x03,", "\g<1>\x03\g<2>,", output.decode())
|
||||||
output = output.splitlines()
|
output = output.splitlines()
|
||||||
asyncio.run(self.reply(irc, output, channel, delay))
|
asyncio.run(self.reply(irc, output, channel, delay))
|
||||||
@ -1318,7 +1321,7 @@ class TextArt(callbacks.Plugin):
|
|||||||
else:
|
else:
|
||||||
irc.reply("Invalid file type.", private=False, notice=False)
|
irc.reply("Invalid file type.", private=False, notice=False)
|
||||||
return
|
return
|
||||||
self.stopped[msg.args[0]] = False
|
self.stopped[channel] = False
|
||||||
output = output.decode().splitlines()
|
output = output.decode().splitlines()
|
||||||
output = [re.sub("^\x03 ", " ", line) for line in output]
|
output = [re.sub("^\x03 ", " ", line) for line in output]
|
||||||
asyncio.run(self.reply(irc, output, channel, delay))
|
asyncio.run(self.reply(irc, output, channel, delay))
|
||||||
@ -1412,7 +1415,7 @@ class TextArt(callbacks.Plugin):
|
|||||||
notice=False,
|
notice=False,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
self.stopped[msg.args[0]] = False
|
self.stopped[channel] = False
|
||||||
output = output.decode().replace("\r\r\n", "\r\n")
|
output = output.decode().replace("\r\r\n", "\r\n")
|
||||||
output = re.sub("\x03\x03\s*", "\x0F ", output)
|
output = re.sub("\x03\x03\s*", "\x0F ", output)
|
||||||
output = re.sub("\x0F\s*\x03$", "", output)
|
output = re.sub("\x0F\s*\x03$", "", output)
|
||||||
@ -1500,7 +1503,7 @@ class TextArt(callbacks.Plugin):
|
|||||||
except:
|
except:
|
||||||
irc.reply("Error. Have you installed toilet?", private=False, notice=False)
|
irc.reply("Error. Have you installed toilet?", private=False, notice=False)
|
||||||
return
|
return
|
||||||
self.stopped[msg.args[0]] = False
|
self.stopped[channel] = False
|
||||||
output = output.decode().replace("\r\r\n", "\r\n")
|
output = output.decode().replace("\r\r\n", "\r\n")
|
||||||
output = output.splitlines()
|
output = output.splitlines()
|
||||||
asyncio.run(self.reply(irc, output, channel, delay))
|
asyncio.run(self.reply(irc, output, channel, delay))
|
||||||
@ -1600,7 +1603,7 @@ class TextArt(callbacks.Plugin):
|
|||||||
output = self.ansi2irc(output)
|
output = self.ansi2irc(output)
|
||||||
output = re.sub("⚡", "☇ ", output)
|
output = re.sub("⚡", "☇ ", output)
|
||||||
output = re.sub("‘‘", "‘ ", output)
|
output = re.sub("‘‘", "‘ ", output)
|
||||||
self.stopped[msg.args[0]] = False
|
self.stopped[channel] = False
|
||||||
output = output.splitlines()
|
output = output.splitlines()
|
||||||
output = [line.strip("\x0F") for line in output]
|
output = [line.strip("\x0F") for line in output]
|
||||||
asyncio.run(self.reply(irc, output, channel, delay))
|
asyncio.run(self.reply(irc, output, channel, delay))
|
||||||
@ -1661,7 +1664,7 @@ class TextArt(callbacks.Plugin):
|
|||||||
output = output.replace("\x1b(B", "")
|
output = output.replace("\x1b(B", "")
|
||||||
output = output.splitlines()
|
output = output.splitlines()
|
||||||
output = [line.strip("\x0F") for line in output]
|
output = [line.strip("\x0F") for line in output]
|
||||||
self.stopped[msg.args[0]] = False
|
self.stopped[channel] = False
|
||||||
asyncio.run(self.reply(irc, output, channel, delay))
|
asyncio.run(self.reply(irc, output, channel, delay))
|
||||||
if self.registryValue("pasteEnable", msg.args[0]):
|
if self.registryValue("pasteEnable", msg.args[0]):
|
||||||
paste = ""
|
paste = ""
|
||||||
@ -1708,7 +1711,7 @@ class TextArt(callbacks.Plugin):
|
|||||||
delay = optlist.get("delay")
|
delay = optlist.get("delay")
|
||||||
else:
|
else:
|
||||||
delay = self.registryValue("delay", msg.args[0])
|
delay = self.registryValue("delay", msg.args[0])
|
||||||
self.stopped[msg.args[0]] = False
|
self.stopped[channel] = False
|
||||||
data = requests.get("http://www.asciiartfarts.com/fortune.txt", timeout=10)
|
data = requests.get("http://www.asciiartfarts.com/fortune.txt", timeout=10)
|
||||||
fortunes = data.content.decode().split("%\n")
|
fortunes = data.content.decode().split("%\n")
|
||||||
fortune = random.randrange(0, len(fortunes))
|
fortune = random.randrange(0, len(fortunes))
|
||||||
@ -1733,7 +1736,7 @@ class TextArt(callbacks.Plugin):
|
|||||||
delay = optlist.get("delay")
|
delay = optlist.get("delay")
|
||||||
else:
|
else:
|
||||||
delay = self.registryValue("delay", msg.args[0])
|
delay = self.registryValue("delay", msg.args[0])
|
||||||
self.stopped[msg.args[0]] = False
|
self.stopped[channel] = False
|
||||||
ua = random.choice(self.agents)
|
ua = random.choice(self.agents)
|
||||||
header = {"User-Agent": ua}
|
header = {"User-Agent": ua}
|
||||||
data = requests.get(
|
data = requests.get(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user