10.6.11. Class cerebro.events.BeforeEventChangingOfMessage

class cerebro.events.BeforeEventChangingOfMessage(event_type, event_id)[source]

Bases: cerebro.events.BeforeEventMessage

The class for the message editing event. It grants access to the data of the message being modified before writing it into the database.

Methods

The class object is input into the functions before_event and error_event (in case of error) of the module event.

def before_event(event):        
        if event.event_type() == event.EVENT_CHANGING_OF_MESSAGE:
                ...
existing_attachments()[source]
Returns:the list of actual attachments that were added to the message before.
Return type:list(cerebro.aclasses.AbstractAttachment,)
original_message()[source]
Returns:the message in its previous state (before undergoing current modifications).
Return type:cerebro.aclasses.Message
def before_event(event):        
        if event.event_type() == event.EVENT_CHANGING_OF_MESSAGE:
                orig_message = event.original_message()
                
                # Comparing the current (after a message modification) working time value and its original (before the modification) value
                if event.work_time() != orig_message.work_time(): 
                        raise Exception('You can't change the working time!')