from common import log, do_everything_to, queries

def process_event(self, connection, event):
    log.info(event)    # Handy for debugging. Keep this.
    self.db.run("UPDATE rotbot_host SET connection_succeeds = connection_succeeds + 1 WHERE id=%s", [self.network.id])

    # Identify with NickServ.
    if self.network.password:   # Password saved.
        connection.privmsg("NickServ", "identify " + self.network.password) # Identify with NickServ.

    connection.mode(connection.get_nickname(), "+x")

    do_everything_to.join(self, connection, self.network.home_channel)  # Join home channel.

    # Join channels with the autojoin setting.
    channels = queries.get_autojoin_channels(self)  # Get channels with autojoin setting.
    for channel in channels:
        connection.join(channel)    # Join channels with autojoin function.
