Revert "no longer treat ctrl+c as "shutdown" - bitbotctl will take this job"

This reverts commit 73e6ede8cc.
This commit is contained in:
jesopo 2019-10-11 15:41:51 +01:00
parent 73e6ede8cc
commit 0207e8e2b6

View file

@ -10,6 +10,29 @@ class Module(ModuleManager.BaseModule):
def SIGINT(self, signum, frame): def SIGINT(self, signum, frame):
print() print()
self.bot.trigger(lambda: self._kill(signum))
def _kill(self, signum):
if self._exited:
return
self._exited = True
self.events.on("signal.interrupt").call(signum=signum)
written = False
for server in list(self.bot.servers.values()):
if server.connected:
server.socket.clear_send_buffer()
line = utils.irc.protocol.quit("Shutting down")
sent_line = server.send(line, immediate=True)
sent_line.events.on("send").hook(self._make_hook(server))
server.send_enabled = False
written = True
if not written:
sys.exit()
def _make_hook(self, server): def _make_hook(self, server):
return lambda e: self.bot.disconnect(server) return lambda e: self.bot.disconnect(server)