from common import log, do_everything_to

def process_event(self, connection, event):
    log.info(event)    # Handy for debugging. Keep this.
    if self.password:   # Id with NickServ
        connection.privmsg("NickServ", "identify " + connection.nickname + " " + self.password) # Identify with NickServ.
    channels = self.db.all("SELECT name FROM channels WHERE network='" + self.network + "' AND autojoin=True")
    connection.mode(connection.get_nickname(), "+x")
    connection.join(self.homechannel)
    for channel in channels:    # Join channels with autojoin function.
        connection.join(channel)
    do_everything_to.join(self, connection, self.homechannel)
    connection.who(connection.get_nickname())   # Get whoreply to add bot to protectees.
