Multiple scripting functions related to messages

As requested by Axem, adds a hook which gets executed once a message has been received.
Also adds some functions related to messages.