-
Notifications
You must be signed in to change notification settings - Fork 3
/
usernamestealer.py
214 lines (188 loc) · 8.3 KB
/
usernamestealer.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# █ █ █ █▄▀ ▄▀█ █▀▄▀█ █▀█ █▀█ █ █
# █▀█ █ █ █ █▀█ █ ▀ █ █▄█ █▀▄ █▄█
# 🔒 Licensed under the GNU GPLv3
# 🌐 https://www.gnu.org/licenses/agpl-3.0.html
# 👤 https://t.me/hikamoru
# meta developer: @hikamorumods
# pusechka @saint_players thanks for the idea
import logging
import requests
from telethon.tl.types import Message
from telethon.tl.functions.channels import CreateChannelRequest, UpdateUsernameRequest
from telethon.tl.types import InputPeerChannel
from .. import loader, utils
from ..inline.types import InlineCall
logger = logging.getLogger(__name__)
@loader.tds
class UserStealer(loader.Module):
"""
Username tracking module.
"""
strings = {
"name": "UsernameChecker",
"create_channel": "📂 Create channel",
"user_free": "⚡️ Username @{} is free, quickly take it.",
"user_busy": "😥 Username @{} is busy. Do you want to enable tracking?",
"yes": "🛟 Yes",
"nope": "🧰 No",
"free_now": "🌟 Username {} is free, do you want to create a channel?",
"not_args": "🚫 Enter the user for check",
"status": "🆔 Username @{} is being tracked\n🟢 Status: free",
"status_busy": "🆔 Username @{} is being tracked\n🟡 Status: busy",
"none": "❌ No username is being tracked.",
"done": "🦉 Done, wait till username will be free",
"created": "🌟 Channel created, go to username @{}",
"tg_bug": "🐞 Telegram has bugs, if the channel is not created, try to create it manually",
}
strings_ru = {
"create_channel": "📂 Создать канал",
"user_free": "⚡️ Юзернейм @{} свободен, быстро забирай его.",
"user_busy": "😥 Юзернейм @{} занят. Хотите включить отслеживание?",
"yes": "🛟 Да",
"nope": "🧰 Нет",
"free_now": "🌟 Юзернейм {} свободен, хотите создать канал?",
"not_args": "🚫 Укажи юзернейм для проверки",
"status": "🆔 Юзернейм @{} отслеживается\n🟢 Статус: свободен",
"status_busy": "🆔 Юзернейм @{} отслеживается\n🟡 Статус: занят",
"none": "❌ Ни один юзернейм не отслеживается.",
"done": "🦉 Готово, жди пока юзернейм освободится",
"created": "🌟 Канал создан, переходи по юзернейму @{}",
"tg_bug": "🐞 У телеграма баги, если канал не создан, попробуй создать его вручную",
}
@loader.loop(interval=30, autostart=True)
async def _steal(self):
user = self.db.get("usernames_to_check", "username")
if user == "none":
return
else:
r = requests.get(url=f"https://t.me/{user}")
if (
r.text.find(
'If you have <strong>Telegram</strong>, you can contact <a class="tgme_username_link"'
)
>= 0
):
self._markup = lambda: self.inline.generate_markup(
[
{"text": self.strings("create_channel"), "callback": self.create_inline, "args": (user,),},
{"text": "Отмена", "callback": self.delete, },
]
)
await self.inline.bot.send_message(
self._client.tg_id,
self.strings("user_free").format(user),
disable_web_page_preview=True,
reply_markup=self._markup()
)
self.db.set("usernames_to_check", "username", "none")
else:
pass
@loader.command()
async def ucheckcmd(self, message: Message):
"""> Enter the user for check (without @)"""
args = utils.get_args_raw(message)
r = requests.get(url=f"https://t.me/{args}")
if args.startswith('@'):
args = args[1:]
if not args:
return await utils.answer(message, self.strings("not_args"))
if (
r.text.find(
'If you have <strong>Telegram</strong>, you can contact <a class="tgme_username_link"'
)
>= 0
):
await self.inline.form(
text=self.strings("free_now").format(args),
reply_markup=[
[
{
"text": self.strings("yes"),
"callback": self.create,
"args": (args,),
},
{"text": self.strings("nope"), "action": "close"},
],
], **{'video': 'https://te.legra.ph/file/a14a9ff4071d079272171.mp4'},
message=message,
)
else:
await self.inline.form(
text=self.strings("user_busy").format(args),
reply_markup=[
[
{
"text": self.strings("yes"),
"callback": self.owo,
"args": (args,),
},
{"text": self.strings("nope"), "action": "close"},
],
], **{"video": "https://te.legra.ph/file/90fbbd0deabfc5e740eb3.mp4"},
message=message,
)
@loader.command()
async def myus(self, message: Message):
"""> Check status of the user being tracked"""
proc = self.db.get("usernames_to_check", "username")
if proc == 'none':
await utils.answer(message, self.strings("none"))
else:
r = requests.get(url=f"https://t.me/{proc}")
if (
r.text.find(
'If you have <strong>Telegram</strong>, you can contact <a class="tgme_username_link"'
)
>= 0
):
await utils.answer(message, self.strings("status").format(proc))
else:
await utils.answer(message, self.strings("status_busy").format(proc))
async def owo(self, call: InlineCall, text: str):
self.db.set("usernames_to_check", "username", text)
await call.edit(self.strings("done"))
async def create(self, call: InlineCall, text: str):
channel = await self.client(
CreateChannelRequest(f"{text}", f"{text}", megagroup=False)
)
channel_id = channel.__dict__["chats"][0].__dict__["id"]
channel_hash = channel.__dict__["chats"][0].__dict__["access_hash"]
try:
await self.client(
UpdateUsernameRequest(
InputPeerChannel(channel_id=channel_id,
access_hash=channel_hash),
text,
)
)
await call.edit(self.strings("created").format(text))
except:
await call.edit(
self.strings("tg_bug"),
)
await self.client.delete_dialog(channel_id)
async def create_inline(self, call: InlineCall, text: str):
channel = await self.client(
CreateChannelRequest(f"{text}", f"{text}", megagroup=False)
)
channel_id = channel.__dict__["chats"][0].__dict__["id"]
channel_hash = channel.__dict__["chats"][0].__dict__["access_hash"]
try:
await self.client(
UpdateUsernameRequest(
InputPeerChannel(channel_id=channel_id,
access_hash=channel_hash),
text,
)
)
await call.answer(self.strings("created").format(text))
await call.delete()
except:
await call.answer(
self.strings("tg_bug"),
show_alert=True
)
await self.client.delete_dialog(channel_id)
await call.delete()
async def delete(self, call: InlineCall):
await call.delete()