-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
26 lines (22 loc) · 888 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from telethon import TelegramClient, sync
from config import *
from telethon.tl.functions.photos import UploadProfilePhotoRequest, DeletePhotosRequest
from telethon.tl.functions.account import UpdateProfileRequest
from datetime import datetime
from utils import *
import time
client = TelegramClient('TimeAvatar', api_id, api_hash)
client.start()
prev_update_time = ""
while True:
if time_has_changed(prev_update_time):
if addTimeToName:
client(UpdateProfileRequest(
first_name = f"Eugene ({prev_update_time})"
))
prev_update_time = convert_time_to_string(datetime.now())
photos = client.get_profile_photos('me')
file = client.upload_file(f"{images_dir}/{prev_update_time.replace(':', '-')}.jpg")
client(UploadProfilePhotoRequest(file))
client(DeletePhotosRequest(photos))
time.sleep(10)