Add botcmd.on_connect hook, to allow better control over bot bringup

This commit is contained in:
Juhani Krekelä 2018-01-02 18:31:23 +02:00
parent c910f08b1e
commit 1081a6d092
2 changed files with 11 additions and 1 deletions

View File

@ -4,6 +4,12 @@
def initialize():
...
# on_connect(*, irc)
# Called after IRC bot has connected and sent the USER/NICk commands but not yet attempted anything else
# Blocks the bot until it's done, including PING/PONG handling
def on_connect(*, irc):
...
# handle_message(*, prefix, message, nick, channel, irc)
# Called for PRIVMSGs.
# prefix is the prefix at the start of the message, without the leading ':'

View File

@ -237,9 +237,13 @@ class ServerThread(threading.Thread):
# Run initialization
self.send_line_raw(b'USER HynneFlip a a :' + self.server.realname.encode('utf-8'))
# Set up nick and channels
# Set up nick
self.api.nick(self.server.nick.encode('utf-8'))
# Run the on_connect hook, to allow further setup
botcmd.on_connect(irc = self.api)
# Join channels
for channel in self.server.channels:
self.api.join(channel.encode('utf-8'))