Skip to content

Instantly share code, notes, and snippets.

@dmkuznetsov

dmkuznetsov/avatimer.php

Last active Jul 18, 2019
Embed
What would you like to do?
Avatimer - change your telegram's profile photo (see https://blog.kuznetsov.io/post/186361320788/avatimer)
<?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
You can’t perform that action at this time.