diff --git a/botcmd.py b/botcmd.py index 5bdf880..aadc318 100644 --- a/botcmd.py +++ b/botcmd.py @@ -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 ':' diff --git a/ircbot.py b/ircbot.py index 69af3c1..398138b 100644 --- a/ircbot.py +++ b/ircbot.py @@ -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'))