-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeleteAvka.py
More file actions
70 lines (58 loc) · 2.24 KB
/
Copy pathDeleteAvka.py
File metadata and controls
70 lines (58 loc) · 2.24 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# CopyLeft 2026 github.com/i-execute
# Author: I_execute.t.me
# Licensed under AGPLv3.
__version__ = (1, 0, 0)
# meta developer: Execute_forge.t.me
import asyncio
from telethon import functions, types
from .. import loader, utils
@loader.tds
class DeleteAvka(loader.Module):
"""Delete all avatars from your profile"""
strings = {
"name": "DeleteAvka",
"processing": "Processing...",
"no_avatars": "Error: no avatars in your profile",
"deleted": "Deleted: {} avatars",
"error": "Error: {}",
}
strings_ru = {
"processing": "Обработка...",
"no_avatars": "Ошибка: в вашем профиле нет аватарок",
"deleted": "Удалено: {} аватарок",
"error": "Ошибка: {}",
}
@loader.command(
ru_doc="Удалить все аватарки из твоего профиля",
en_doc="Delete all avatars from your profile",
)
async def avkarm(self, message):
"""Delete all avatars from your profile"""
await utils.answer(message, self.strings["processing"])
try:
c = 0
while True:
photos = await self.client(functions.photos.GetUserPhotosRequest(
user_id=types.InputPeerSelf(),
offset=0,
max_id=0,
limit=100
))
if not photos.photos:
if c == 0:
return await utils.answer(message, self.strings["no_avatars"])
break
ids = [
types.InputPhoto(
id=p.id,
access_hash=p.access_hash,
file_reference=p.file_reference
)
for p in photos.photos
]
await self.client(functions.photos.DeletePhotosRequest(id=ids))
c += len(ids)
await asyncio.sleep(0.1)
await utils.answer(message, self.strings["deleted"].format(c))
except Exception as e:
await utils.answer(message, self.strings["error"].format(e))