refactor message event to take chat object literal