def run (message):

    # Search for the message type
    tg_type = [message_type for message_type in static_values.possible_message_types \
               if message_type in message]

    # Gran the first entry in the above list.
    # Should never have more than one anyways.
    tg_type = tg_type[0]

    # Check if we already know about this message.
    # Honestly can't think of a case were this
    # will actually happen. Nonetheless, lets
    # check and warn.
    try:
        Logger.get(Logger.message_id == message['message_id'])
        logger.warning('Message {id} already exists in the database.'.format(
            id = message['message_id']
        ))
        return

    except Logger.DoesNotExist:

        # Nope. Create it!
        logger.debug('Storing message id {id} which is a {tg_type} message'.format(
            id = message['message_id'],
            tg_type = tg_type
        ))

        # Start a new Logger instance
        l = Logger(message_id = message['message_id'])

    # Set some fields that are always applicable
    # to any message type
    l.message_type = tg_type
    l.telegram_date = message['date']

    # Populate the 'from' details
    l = _process_from(message, l)

    # Populate the 'chat' details. Chat
    # is the actual person/room the
    # came from
    l = _process_chat(message, l)

    # Process any potential file_id's
    l = _process_file_id(message, l)

    # If there is text, add that too
    l.text = message['text'] if 'text' in message else None

    # Aaand save.
    l.save()

    return
Run
dataset/ETHPy150Open leonjza/hogar/hogar/Plugins/Logger/main.py/run