-
Notifications
You must be signed in to change notification settings - Fork 5
/
clone.py
163 lines (154 loc) · 6.41 KB
/
clone.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
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
"""Get Telegram Profile Picture and other information
and set as own profile.
Syntax: .clone @username"""
#Copy That Plugin by @ViperAdnan
#modified by @LEGENDX22
#Give credit if you are going to kang it.
import html
import os
from telethon.tl.functions.photos import GetUserPhotosRequest
from telethon.tl.functions.users import GetFullUserRequest
from telethon.tl.types import MessageEntityMentionName
from telethon.utils import get_input_location
from ULTRA.utils import admin_cmd
from telethon.tl import functions
from telethon import events
from telethon.errors import ImageProcessFailedError, PhotoCropSizeSmallError
from telethon.errors.rpcerrorlist import (PhotoExtInvalidError,
UsernameOccupiedError)
from telethon.tl.functions.account import (UpdateProfileRequest,
UpdateUsernameRequest)
from telethon.tl.functions.channels import GetAdminedPublicChannelsRequest
from telethon.tl.functions.photos import (DeletePhotosRequest,
GetUserPhotosRequest,
UploadProfilePhotoRequest)
from telethon.tl.types import InputPhoto, MessageMediaPhoto, User, Chat, Channel
from ULTRA import bot, CMD_HELP , AUTONAME , BIO_MSG , ALIVE_NAME
DEFAULTUSER = str(ALIVE_NAME) if ALIVE_NAME else "Hell User"
DEFAULTUSERBIO = str(BIO_MSG) if BIO_MSG else "LEGEND USE LEGEND-BOT"
BOTLOG_CHATID = Config.PRIVATE_GROUP_BOT_API_ID
BOTLOG = True
@borg.on(admin_cmd(pattern="clone ?(.*)"))
async def _(event):
if event.fwd_from:
return
reply_message = await event.get_reply_message()
replied_user, error_i_a = await get_full_user(event)
if replied_user is None:
await event.edit(str(error_i_a))
return False
user_id = replied_user.user.id
profile_pic = await event.client.download_profile_photo(user_id, Config.TMP_DOWNLOAD_DIRECTORY)
# some people have weird HTML in their names
first_name = html.escape(replied_user.user.first_name)
# https://stackoverflow.com/a/5072031/4723940
# some Deleted Accounts do not have first_name
if first_name is not None:
# some weird people (like me) have more than 4096 characters in their names
first_name = first_name.replace("\u2060", "")
last_name = replied_user.user.last_name
# last_name is not Manadatory in @Telegram
if last_name is not None:
last_name = html.escape(last_name)
last_name = last_name.replace("\u2060", "")
if last_name is None:
last_name = " "
# inspired by https://telegram.dog/afsaI181
user_bio = replied_user.about
if user_bio is not None:
user_bio = replied_user.about
await borg(functions.account.UpdateProfileRequest(
first_name=first_name
))
await borg(functions.account.UpdateProfileRequest(
last_name=last_name
))
await borg(functions.account.UpdateProfileRequest(
about=user_bio
))
n = 1
pfile = await borg.upload_file(profile_pic) # pylint:disable=E060
await borg(functions.photos.UploadProfilePhotoRequest( # pylint:disable=E0602
pfile
))
await event.delete()
await borg.send_message(
event.chat_id,
"**Who Are You? .. **",
reply_to=reply_message
)
if BOTLOG:
await event.client.send_message(BOTLOG_CHATID, f"#CLONED\nSuccesfulley cloned [{first_name}](tg://user?id={user_id })")
@borg.on(admin_cmd(pattern="revert$"))
async def _(event):
if event.fwd_from:
return
name = f"{DEFAULTUSER}"
bio = f"{DEFAULTUSERBIO}"
n = 1
await borg(functions.photos.DeletePhotosRequest(await event.client.get_profile_photos("me", limit= n)))
await borg(functions.account.UpdateProfileRequest(about=f"{bio}"))
await borg(functions.account.UpdateProfileRequest(first_name=f"{name}"))
await event.edit("succesfully reverted to your account back")
if BOTLOG:
await event.client.send_message(BOTLOG_CHATID, f"#REVERT\nSuccesfully reverted back to your profile")
async def get_full_user(event):
if event.reply_to_msg_id:
previous_message = await event.get_reply_message()
if previous_message.forward:
replied_user = await event.client(
GetFullUserRequest(
previous_message.forward.sender_id or previous_message.forward.channel_id
)
)
return replied_user, None
else:
replied_user = await event.client(
GetFullUserRequest(
previous_message.sender_id
)
)
return replied_user, None
else:
input_str = None
try:
input_str = event.pattern_match.group(1)
except IndexError as e:
return None, e
if event.message.entities:
mention_entity = event.message.entities
probable_user_mention_entity = mention_entity[0]
if isinstance(probable_user_mention_entity, MessageEntityMentionName):
user_id = probable_user_mention_entity.user_id
replied_user = await event.client(GetFullUserRequest(user_id))
return replied_user, None
else:
try:
user_object = await event.client.get_entity(input_str)
user_id = user_object.id
replied_user = await event.client(GetFullUserRequest(user_id))
return replied_user, None
except Exception as e:
return None, e
elif event.is_private:
try:
user_id = event.chat_id
replied_user = await event.client(GetFullUserRequest(user_id))
return replied_user, None
except Exception as e:
return None, e
else:
try:
user_object = await event.client.get_entity(int(input_str))
user_id = user_object.id
replied_user = await event.client(GetFullUserRequest(user_id))
return replied_user, None
except Exception as e:
return None, e
CMD_HELP.update({
"clone":
".clone <username/reply>\
\nUsage: steals others profile including dp, name.\
\n\n.revert\
\nUsage: To back to your profile but it'll show ALIVE_NAME instead of your current name and DEFAULT_BIO instead of your current bio\
"})