Last active
July 18, 2019 18:20
-
-
Save deeravenger/452dfd30f0b4fd9a17f2149037f2afc3 to your computer and use it in GitHub Desktop.
Avatimer - change your telegram's profile photo (see https://blog.kuznetsov.io/post/186361320788/avatimer)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!file_exists('madeline.php')) { | |
copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php'); | |
} | |
include 'madeline.php'; | |
$telegram = new \danog\MadelineProto\API('session.madeline'); | |
$telegram->start(); | |
$profile = $telegram->get_self(); | |
if (isset($profile['photo']['photo_id'])) { | |
$inputPhoto = ['_' => 'inputPhoto', 'id' => $profile['photo']['photo_id'], 'access_hash' => 0, 'file_reference' => 0]; | |
$telegram->photos->deletePhotos(['id' => [$inputPhoto]]); | |
} | |
$face = in_array(date('w'), [0, 6], false) ? 'happy' : 'normal'; | |
$path = sprintf('%s/photo/%s.jpg', __DIR__, $face); | |
$telegram->photos->uploadProfilePhoto(['file' => $path]); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment