'Add the specified callback.
Args:
obj (Object): the Evennia typeclassed object to be extended.
callback_name (str): the name of the callback to add.
code (str): the Python code associated with this callback.
author (Character or Player, optional): the author of the callback.
valid (bool, optional): should the callback be connected?
parameters (str, optional): optional parameters.
Note:
This method doesn\'t check that the callback type exists.'

def add_callback(self, obj, callback_name, code, author=None, valid=False, parameters=''):

    obj_callbacks = self.db.callbacks.get(obj, {})
    if (not obj_callbacks):
        self.db.callbacks[obj] = {}
        obj_callbacks = self.db.callbacks[obj]
    callbacks = obj_callbacks.get(callback_name, [])
    if (not callbacks):
        obj_callbacks[callback_name] = []
        callbacks = obj_callbacks[callback_name]
    callbacks.append({'created_on': datetime.now(), 'author': author, 'valid': valid, 'code': code, 'parameters': parameters})
    if (not valid):
        self.db.to_valid.append((obj, callback_name, (len(callbacks) - 1)))
    custom_add = self.get_events(obj).get(callback_name, [None, None, None, None])[3]
    if custom_add:
        custom_add(obj, callback_name, (len(callbacks) - 1), parameters)
    definition = dict(callbacks[(-1)])
    definition['obj'] = obj
    definition['name'] = callback_name
    definition['number'] = (len(callbacks) - 1)
    return definition
