From 71a18dbc17f99046a08ce69c589b8368ab4087d4 Mon Sep 17 00:00:00 2001 From: GenZmeY Date: Tue, 2 Mar 2021 12:54:06 +0300 Subject: [PATCH] remove gap when changing avatar --- SOURCES/main.py | 3 ++- SOURCES/tg-avatar-alteration | 4 ++-- SPECS/tg-avatar-alteration.spec | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/SOURCES/main.py b/SOURCES/main.py index 6061303..e02f328 100755 --- a/SOURCES/main.py +++ b/SOURCES/main.py @@ -54,9 +54,10 @@ async def main(): index = index + 1440 elif index >= 1440: index = index - 1440 + prev_avatar = await client.get_profile_photos('me') filename = config.IMG_DIR + f'/{index:04}.' + config.IMG_EXT - await client(DeletePhotosRequest(await client.get_profile_photos('me'))) await client(UploadProfilePhotoRequest(await client.upload_file(filename))) + await client(DeletePhotosRequest(prev_avatar)) print('Avatar changed: ' + filename) diff --git a/SOURCES/tg-avatar-alteration b/SOURCES/tg-avatar-alteration index f358895..1d9649d 100644 --- a/SOURCES/tg-avatar-alteration +++ b/SOURCES/tg-avatar-alteration @@ -25,8 +25,8 @@ Cache="/var/cache/tg-avatar-alteration" if [[ $(whoami) == "$TgAaUser" ]]; then /usr/bin/python3 "$App" "$Conf" "$Cache" -elif [[ -n $(groups "${USER}" | grep -Fo 'wheel') ]] || [[ "${EUID}" -eq 0 ]]; then - sudo -u "${TgAaUser}" -s -- /usr/bin/tg-avatar-alteration +elif [[ -n $(groups "$USER" | grep -Fo 'wheel') ]] || [[ "$EUID" -eq 0 ]]; then + sudo -u "$TgAaUser" -s -- /usr/bin/tg-avatar-alteration else echo "You must be ${TgAaUser}, root or sudo-user to run this command" fi diff --git a/SPECS/tg-avatar-alteration.spec b/SPECS/tg-avatar-alteration.spec index 07fb1b4..4107871 100644 --- a/SPECS/tg-avatar-alteration.spec +++ b/SPECS/tg-avatar-alteration.spec @@ -3,7 +3,7 @@ %global user tg-aa-user Name: tg-avatar-alteration -Version: 1.0.0 +Version: 1.0.1 Release: 1%{dist} Summary: telegram avatar alteration Group: Applications/Communications @@ -99,5 +99,8 @@ if [[ "$1" -eq 0 ]]; then # Uninstall fi %changelog +* Tue Mar 02 2021 GenZmeY - 1.0.1-1 +- Removed the gap when changing the avatar. + * Mon Mar 01 2021 GenZmeY - 1.0.0-1 - first version.