diff --git a/dr.botzo.py b/dr.botzo.py index 2c03e90..89c32b8 100755 --- a/dr.botzo.py +++ b/dr.botzo.py @@ -4,6 +4,21 @@ from ConfigParser import ConfigParser, NoSectionError, NoOptionError import os import sys +import irclib + +# handler for when the bot has connected to IRC +def on_connect(connection, event): + # join the specified channel + # TODO: support multiple + if irclib.is_channel(channel): + connection.join(channel) + +##### +# init +##### + +# read config file + config = ConfigParser() config.read([os.path.expanduser('~/.dr.botzo.cfg'), 'dr.botzo.cfg']) @@ -19,4 +34,16 @@ except NoSectionError as e: except NoOptionError as e: sys.exit("Aborted due to error with necessary configuration: " + str(e)) +# start up the IRC bot + +# create IRC and server objects and connect +irc = irclib.IRC() +server = irc.server().connect(server, port, nick, ircname) + +# install handlers +server.add_global_handler("welcome", on_connect) + +# loop forever +irc.process_forever() + # vi:tabstop=4:expandtab:autoindent