import commands.public, commands.admin, commands.games, commands.statistics
from common import log, queries, font
from events.common import Inform

def process_event(self, connection, event):
    log.info(event) # Log to console.

    # Get and update resources.
    user = queries.create_or_get_and_update_last_event(self, 'user', 'pm', user_name=event.source.nick, event_subject_name=event.target)
    channel = None

    if not event.source.nick == connection.get_nickname():  # Message is not from myself.
        Inform.owners(self, connection, 'PM from %s%s%s: %s%s' % (font.red, event.source.nick, font.grey, font.green, event.arguments[0]))  # Forward message to users with owner rights of home channel.

    # Respond to commands.
    commands.public.do_command(self, connection, event, user, channel)
    commands.admin.do_command(self, connection, event, user, channel)
    commands.statistics.do_command(self, connection, event, user, channel)
    commands.games.do_command(self, connection, event, user, channel)
