Convert receiver.php to Python