Add botcmd.on_connect hook, to allow better control over bot bringup
This commit is contained in:
parent
c910f08b1e
commit
1081a6d092
2 changed files with 11 additions and 1 deletions
|
@ -4,6 +4,12 @@
|
||||||
def initialize():
|
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)
|
# handle_message(*, prefix, message, nick, channel, irc)
|
||||||
# Called for PRIVMSGs.
|
# Called for PRIVMSGs.
|
||||||
# prefix is the prefix at the start of the message, without the leading ':'
|
# prefix is the prefix at the start of the message, without the leading ':'
|
||||||
|
|
|
@ -237,9 +237,13 @@ class ServerThread(threading.Thread):
|
||||||
# Run initialization
|
# Run initialization
|
||||||
self.send_line_raw(b'USER HynneFlip a a :' + self.server.realname.encode('utf-8'))
|
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'))
|
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:
|
for channel in self.server.channels:
|
||||||
self.api.join(channel.encode('utf-8'))
|
self.api.join(channel.encode('utf-8'))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue