From a544e65cac5e9dbc33e2afaa964d822dcd4b54fc Mon Sep 17 00:00:00 2001 From: oddluck <39967334+oddluck@users.noreply.github.com> Date: Mon, 10 Feb 2020 18:15:56 +0000 Subject: [PATCH] TextArt: rainbow scroll --- TextArt/plugin.py | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/TextArt/plugin.py b/TextArt/plugin.py index 71c5cc9..ca03549 100644 --- a/TextArt/plugin.py +++ b/TextArt/plugin.py @@ -1663,8 +1663,8 @@ class TextArt(callbacks.Plugin): Stop the scroll. """ if not self.stopped[msg.args[0]]: - self.stopped[msg.args[0]] = True irc.reply("Stopping.") + self.stopped[msg.args[0]] = True cq = wrap(cq) def codes(self, irc, msg, args): @@ -1681,4 +1681,46 @@ class TextArt(callbacks.Plugin): irc.reply("\x031,8888\x031,8989\x031,9090\x031,9191\x031,9292\x031,9393\x031,9494\x031,9595\x031,9696\x031,9797\x031,9898\x031,9999", prefixNick=False) codes = wrap(codes) + def rainbow(self, irc, msg, args, optlist, channel): + """[channel] [--delay ] + Scroll a rainbow. + """ + if not channel: + channel = msg.args[0] + if channel != msg.args[0] and not ircdb.checkCapability(msg.prefix, 'admin'): + irc.errorNoCapability('admin') + return + self.stopped[channel] = False + if 'delay' in optlist: + delay = optlist.get('delay') + else: + delay = self.registryValue('delay', msg.args[0]) + indent = 10 # How many spaces to indent. + while True: # Main program loop. + if self.stopped[channel]: + break + line = '' + line += ' ' * indent + line += '\x034###' + line += '\x037###' + line += '\x038###' + line += '\x039###' + line += '\x0312###' + line += '\x0311###' + line += '\x036###' + if not self.stopped[channel]: + time.sleep(delay) + irc.reply(line, prefixNick=False) + if random.randint(0, 1) == 0: + # Increase the number of spaces: + indent = indent + 1 + if indent > 80: + indent = 80 + else: + # Decrease the number of spaces: + indent = indent - 1 + if indent < 0: + indent = 0 + rainbow = wrap(rainbow, [optional('channel'), getopts({'delay':'float'})]) + Class = TextArt