Add highlight mode for ascii module for real legit spamming

This commit is contained in:
dave 2017-05-13 21:37:28 -07:00
parent 706f789fdb
commit fd51de7f84
3 changed files with 9 additions and 4 deletions

View File

@ -1,5 +1,6 @@
{ {
"line_delay": 1.1, "line_delay": 1.1,
"allow_parallel": false, "allow_parallel": false,
"allow_hilight": true,
"list_max": 15 "list_max": 15
} }

View File

@ -56,14 +56,16 @@ class ASCII(ModuleBase):
if not self.config.get("allow_parallel") and any(self.running_asciis.values()): if not self.config.get("allow_parallel") and any(self.running_asciis.values()):
return return
ascii_name = cmd.args.pop() ascii_name = cmd.args.pop(0)
if not RE_ASCII_FNAME.match(ascii_name): if not RE_ASCII_FNAME.match(ascii_name):
return return
ascii_path = self.getFilePath(ascii_name + ".txt") ascii_path = self.getFilePath(ascii_name + ".txt")
if os.path.exists(ascii_path): if os.path.exists(ascii_path):
self.running_asciis[msg.args[0]] = Thread(target=self.print_ascii, args=(ascii_path, msg.args[0]), args = [ascii_path, msg.args[0]]
daemon=True) if self.config.get("allow_hilight", False) and len(cmd.args) >= 1:
args.append(cmd.args.pop(0))
self.running_asciis[msg.args[0]] = Thread(target=self.print_ascii, args=args, daemon=True)
self.running_asciis[msg.args[0]].start() self.running_asciis[msg.args[0]].start()
return return
@ -72,7 +74,7 @@ class ASCII(ModuleBase):
if self.running_asciis[msg.args[0]]: if self.running_asciis[msg.args[0]]:
self.killed_channels[msg.args[0]] = True self.killed_channels[msg.args[0]] = True
def print_ascii(self, ascii_path, channel): def print_ascii(self, ascii_path, channel, hilight=None):
""" """
Print the contents of ascii_path to channel Print the contents of ascii_path to channel
:param ascii_path: file path to the ascii art file to read and print :param ascii_path: file path to the ascii art file to read and print
@ -86,6 +88,8 @@ class ASCII(ModuleBase):
break break
if not line: if not line:
line = " " line = " "
if hilight:
line = "{}: {}".format(hilight, line)
self.bot.act_PRIVMSG(channel, line) self.bot.act_PRIVMSG(channel, line)
if delay: if delay:
sleep(delay) sleep(delay)