add IRCServer.send_enabled, to prevent sending after QUIT in signals.py

This commit is contained in:
jesopo 2019-03-05 11:29:28 +00:00
parent 68ebecedfd
commit 91c2ab03ba
2 changed files with 6 additions and 0 deletions

View file

@ -20,6 +20,7 @@ class Module(ModuleManager.BaseModule):
for server in self.bot.servers.values():
line = server.send_quit("Shutting down")
server.send_enabled = False
line.on_send(self._make_hook(server))
def _make_hook(self, server):

View file

@ -58,7 +58,9 @@ class Server(IRCObject.Object):
self.motd_done = False
self.attempted_join = {} # type: typing.Dict[str, typing.Optional[str]]
self.ping_sent = False
self.send_enabled = True
self.events.on("timer.rejoin").hook(self.try_rejoin)
@ -238,6 +240,9 @@ class Server(IRCObject.Object):
return lines
def send(self, line_parsed: IRCLine.ParsedLine):
if not self.send_enabled:
return None
self.events.on("preprocess.send").on(line_parsed.command
).call_unsafe(server=self, line=line_parsed)