Rewrite get_message into python