from common import log, queries
from common.networkservices import NickServ

def process_event(self, connection, event):
    log.info(event)

    # Get and update resources.
    old_user = queries.create_or_get_and_update_last_event(self, 'user', 'nc', user_name=event.source.nick, event_subject_name=event.target)
    new_user = queries.create_or_get_and_update_last_event(self, 'user', 'nc', user_name=event.target, event_subject_name=event.source.nick)

    # Keep preferred nick.
    if event.source.nick == connection.nickname:    # Preffered nick being changed.
        NickServ.recover_nick(connection, self.password)
