Add botcmd.on_quit hook for bot cleanup
This commit is contained in:
parent
a74173fee2
commit
03f0011e62
2 changed files with 10 additions and 0 deletions
|
@ -12,6 +12,13 @@ def initialize(*, config):
|
|||
def on_connect(*, irc):
|
||||
...
|
||||
|
||||
# on_quit(*, irc)
|
||||
# Called just before IRC bot sends QUIT
|
||||
# Blocks the bot until it's done, including PING/PONG handling
|
||||
# irc is the IRC API object
|
||||
def on_quit(*, irc):
|
||||
...
|
||||
|
||||
# handle_message(*, prefix, message, nick, channel, irc)
|
||||
# Called for PRIVMSGs.
|
||||
# prefix is the prefix at the start of the message, without the leading ':'
|
||||
|
|
|
@ -307,6 +307,9 @@ class ServerThread(threading.Thread):
|
|||
reconnecting = self.mainloop()
|
||||
|
||||
if not reconnecting:
|
||||
# Run bot cleanup code
|
||||
botcmd.on_quit(irc = self.api)
|
||||
|
||||
# Tell the server we're quiting
|
||||
self.send_line_raw(b'QUIT :%s exiting normally' % self.server.username.encode('utf-8'))
|
||||
self.server_socket.close()
|
||||
|
|
Loading…
Reference in a new issue