-
Notifications
You must be signed in to change notification settings - Fork 11
/
bot.py
357 lines (324 loc) · 13.8 KB
/
bot.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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
import cloudscraper
from os import environ
from requests import get
from pyrogram import Client, filters
API_ID = environ.get("API_ID")
API_HASH = environ.get("API_HASH")
BOT_TOKEN = environ.get("BOT_TOKEN")
AUTH_USERS = {int(x) for x in environ.get("AUTH_USERS").split()}
DLINK_KEY = environ.get("DLINK_KEY", None)
SNACKLINK_KEY = environ.get("SNACKLINK_KEY", None)
ADTIVAL_KEY = environ.get("ADTIVAL_KEY", None)
SHRINKADS_KEY = environ.get("SHRINKADS_KEY", None)
ZAGL_KEY = environ.get("ZAGL_KEY", None)
YOUSHORT_KEY = environ.get("YOUSHORT_KEY", None)
PFL_KEY = environ.get("PFL_KEY", None)
SEARN_KEY = environ.get("SEARN_KEY", None)
CFLY_KEY = environ.get("CFLY_KEY", None)
SHZON_KEY = environ.get("SHZON_KEY", None)
CLKSH_KEY = environ.get("CLKSH_KEY", None)
cfpass = cloudscraper.create_scraper() # bypassing cloudflare
bot = Client(
":memory:",
api_id=API_ID,
api_hash=API_HASH,
bot_token=BOT_TOKEN,
)
@bot.on_message(filters.command(["start", "help"]) & ~filters.edited)
async def start(_, message):
await message.reply(
f"""**Hi {message.chat.first_name}!**
I'm **MultiSafelinkBot**, Just send me a link with some command below.
**Here is my command:**
/adtival <link> - Get a shortlink using adtival
/cfly <link> - Get a shortlink using clicksfly
/clksh <link> - Get a shortlink using clksh
/dlink <link> - Get a shortlink using droplink
/sads <link> - Get a shortlink using shrinkads
/sarn <link> - Get a shortlink using shrinkearn
/snack <link> - Get a shortlink using snacklink
/shzon <link> - Get a shortlink using shortzon
/pfl <link> - Get a shortlink using paid4link
/yshort <link> - Get a shortlink using yourshort
/zagl <link> - Get a shortlink using zagl
More features will added soon:)
**Join here:**
@YBotsSupport
@SpreadNetworks
Maintenance by @Yoga_CIC"""
)
@bot.on_message(filters.command(["adtival", "wts"]) & ~filters.edited)
async def adtival_handler(_, message):
if len(message.command) < 2:
return await message.reply("Give me url to short!")
if message.from_user.id not in AUTH_USERS:
return await message.reply(
"You are not allowed to use me!\n\nContact @Yoga_CIC"
)
if ADTIVAL_KEY is None:
return await message.reply(
"Get `ADTIVAL_KEY` from [adtival](https://www.adtival.network/ref/YogaPranata) and fill it on vars!",
disable_web_page_preview=True,
)
link = message.text.split(None, 1)[1].strip()
link = link.replace(" ", "")
try:
r = get(f"https://www.adtival.network/api?api={ADTIVAL_KEY}&url={link}").json()
short_link = r["shortenedUrl"]
return await message.reply(
f"""Click to copy:\n\n<code>{short_link}</code>.\n\nHere is your [short link]({short_link}).""",
quote=True,
disable_web_page_preview=True,
)
except Exception as e:
return await message.reply(f"Error: {e}\n\nReport to @Yoga_CIC", quote=True)
@bot.on_message(filters.command("dlink") & ~filters.edited)
async def dlink_handler(_, message):
if len(message.command) < 2:
return await message.reply("Give me url to short!")
if message.from_user.id not in AUTH_USERS:
return await message.reply(
"You are not allowed to use me!\n\nContact @Yoga_CIC"
)
if DLINK_KEY is None:
return await message.reply(
"Get `DLINK_KEY` from [droplink](https://droplink.co/ref/YogaPranata) and fill it on vars!",
disable_web_page_preview=True,
)
link = message.text.split(None, 1)[1].strip()
link = link.replace(" ", "")
try:
r = get(f"https://droplink.co/api?api={DLINK_KEY}&url={link}").json()
short_link = r["shortenedUrl"]
return await message.reply(
f"""Click to copy:\n\n<code>{short_link}</code>.\n\nHere is your [short link]({short_link}).""",
quote=True,
disable_web_page_preview=True,
)
except Exception as e:
return await message.reply(f"Error: {e}\n\nReport to @Yoga_CIC", quote=True)
@bot.on_message(filters.command("snack") & ~filters.edited)
async def snack_handler(_, message):
if len(message.command) < 2:
return await message.reply("Give me url to short!")
if message.from_user.id not in AUTH_USERS:
return await message.reply(
"You are not allowed to use me!\n\nContact @Yoga_CIC"
)
if SNACKLINK_KEY is None:
return await message.reply(
"Get `SNACKLINK_KEY` from [snacklink](https://snacklink.co/ref/AdamLuwis) and fill it on vars!",
disable_web_page_preview=True,
)
link = message.text.split(None, 1)[1].strip()
link = link.replace(" ", "")
try:
short_link = "https://ponselharian.com/st/?api={SNACKLINK_KEY}&url={link}"
return await message.reply(
f"""Click to copy:\n\n<code>{short_link}</code>.\n\nHere is your [short link]({short_link}).""",
quote=True,
disable_web_page_preview=True,
)
except Exception as e:
return await message.reply(f"Error: {e}\n\nReport to @Yoga_CIC", quote=True)
@bot.on_message(filters.command("sads") & ~filters.edited)
async def sads_handler(_, message):
if len(message.command) < 2:
return await message.reply("Give me url to short!")
if message.from_user.id not in AUTH_USERS:
return await message.reply(
"You are not allowed to use me!\n\nContact @Yoga_CIC"
)
if SHRINKADS_KEY is None:
return await message.reply(
"Get `SHRINKADS_KEY` from [shrinkads](https://www.shrinkads.com/ref/YogaPranata) and fill it on vars!",
disable_web_page_preview=True,
)
link = message.text.split(None, 1)[1].strip()
link = link.replace(" ", "")
try:
r = get(f"https://www.shrinkads.com/api?api={SHRINKADS_KEY}&url={link}").json()
short_link = r["shortenedUrl"]
return await message.reply(
f"""Click to copy:\n\n<code>{short_link}</code>.\n\nHere is your [short link]({short_link}).""",
quote=True,
disable_web_page_preview=True,
)
except Exception as e:
return await message.reply(f"Error: {e}\n\nReport to @Yoga_CIC", quote=True)
@bot.on_message(filters.command("zagl") & ~filters.edited)
async def zagl_handler(_, message):
if len(message.command) < 2:
return await message.reply("Give me url to short!")
if message.from_user.id not in AUTH_USERS:
return await message.reply(
"You are not allowed to use me!\n\nContact @Yoga_CIC"
)
if ZAGL_KEY is None:
return await message.reply(
"Get `ZAGL_KEY` from [zagl](https://zee.gl/ref/YogaPranata) and fill it on vars!",
disable_web_page_preview=True,
)
link = message.text.split(None, 1)[1].strip()
link = link.replace(" ", "")
try:
r = get(f"https://za.gl/api?api={ZAGL_KEY}&url={link}").json()
short_link = r["shortenedUrl"]
return await message.reply(
f"""Click to copy:\n\n<code>{short_link}</code>.\n\nHere is your [short link]({short_link}).""",
quote=True,
disable_web_page_preview=True,
)
except Exception as e:
return await message.reply(f"Error: {e}\n\nReport to @Yoga_CIC", quote=True)
@bot.on_message(filters.command("yshort") & ~filters.edited)
async def yshort_handler(_, message):
if len(message.command) < 2:
return await message.reply("Give me url to short!")
if message.from_user.id not in AUTH_USERS:
return await message.reply(
"You are not allowed to use me!\n\nContact @Yoga_CIC"
)
if YOUSHORT_KEY is None:
return await message.reply(
"Get `YOUSHORT_KEY` from [youshort](https://youshort.me/ref/YogaPranata) and fill it on vars!",
disable_web_page_preview=True,
)
link = message.text.split(None, 1)[1].strip()
link = link.replace(" ", "")
try:
r = get(f"https://youshort.me/api?api={YOUSHORT_KEY}&url={link}").json()
short_link = r["shortenedUrl"]
return await message.reply(
f"""Click to copy:\n\n<code>{short_link}</code>.\n\nHere is your [short link]({short_link}).""",
quote=True,
disable_web_page_preview=True,
)
except Exception as e:
return await message.reply(f"Error: {e}\n\nReport to @Yoga_CIC", quote=True)
@bot.on_message(filters.command("pfl") & ~filters.edited)
async def pfl_handler(_, message):
if len(message.command) < 2:
return await message.reply("Give me url to short!")
if message.from_user.id not in AUTH_USERS:
return await message.reply(
"You are not allowed to use me!\n\nContact @Yoga_CIC"
)
if PFL_KEY is None:
return await message.reply(
"Get `PFL_KEY` from [paid4link](https://paid4link.com/ref/zYxDevs) and fill it on vars!",
disable_web_page_preview=True,
)
link = message.text.split(None, 1)[1].strip()
link = link.replace(" ", "")
try:
r = cfpass.get(f"https://paid4link.com/api?api={PFL_KEY}&url={link}").json()
short_link = r["shortenedUrl"]
return await message.reply(
f"""Click to copy:\n\n<code>{short_link}</code>.\n\nHere is your [short link]({short_link}).""",
quote=True,
disable_web_page_preview=True,
)
except Exception as e:
return await message.reply(f"Error: {e}\n\nReport to @Yoga_CIC", quote=True)
@bot.on_message(filters.command("sarn") & ~filters.edited)
async def searn_handler(_, message):
if len(message.command) < 2:
return await message.reply("Give me url to short!")
if message.from_user.id not in AUTH_USERS:
return await message.reply(
"You are not allowed to use me!\n\nContact @Yoga_CIC"
)
if SEARN_KEY is None:
return await message.reply(
"Get `SEARN_KEY` from [shrinkearn](https://shrinkearn.com/ref/YogaPranata) and fill it on vars!",
disable_web_page_preview=True,
)
link = message.text.split(None, 1)[1].strip()
link = link.replace(" ", "")
try:
r = get(f"https://shrinkearn.com/api?api={SEARN_KEY}&url={link}").json()
short_link = r["shortenedUrl"]
return await message.reply(
f"""Click to copy:\n\n<code>{short_link}</code>.\n\nHere is your [short link]({short_link}).""",
quote=True,
disable_web_page_preview=True,
)
except Exception as e:
return await message.reply(f"Error: {e}\n\nReport to @Yoga_CIC", quote=True)
@bot.on_message(filters.command("cfly") & ~filters.edited)
async def cfly_handler(_, message):
if len(message.command) < 2:
return await message.reply("Give me url to short!")
if message.from_user.id not in AUTH_USERS:
return await message.reply(
"You are not allowed to use me!\n\nContact @Yoga_CIC"
)
if CFLY_KEY is None:
return await message.reply(
"Get `CFLY_KEY` from [clicksfly](https://clicksfly.com/ref/YogaPranata) and fill it on vars!",
disable_web_page_preview=True,
)
link = message.text.split(None, 1)[1].strip()
link = link.replace(" ", "")
try:
r = get(f"https://clicksfly.com/api?api={CFLY_KEY}&url={link}").json()
short_link = r["shortenedUrl"]
return await message.reply(
f"""Click to copy:\n\n<code>{short_link}</code>.\n\nHere is your [short link]({short_link}).""",
quote=True,
disable_web_page_preview=True,
)
except Exception as e:
return await message.reply(f"Error: {e}\n\nReport to @Yoga_CIC", quote=True)
@bot.on_message(filters.command("shzon") & ~filters.edited)
async def shzon_handler(_, message):
if len(message.command) < 2:
return await message.reply("Give me url to short!")
if message.from_user.id not in AUTH_USERS:
return await message.reply(
"You are not allowed to use me!\n\nContact @Yoga_CIC"
)
if SHZON_KEY is None:
return await message.reply(
"Get `SHZON_KEY` from [shortzon](https://shortzon.com/ref/YogaPranata) and fill it on vars!",
disable_web_page_preview=True,
)
link = message.text.split(None, 1)[1].strip()
link = link.replace(" ", "")
try:
r = get(f"https://shortzon.com/api?api={SHZON_KEY}&url={link}").json()
short_link = r["shortenedUrl"]
return await message.reply(
f"""Click to copy:\n\n<code>{short_link}</code>.\n\nHere is your [short link]({short_link}).""",
quote=True,
disable_web_page_preview=True,
)
except Exception as e:
return await message.reply(f"Error: {e}\n\nReport to @Yoga_CIC", quote=True)
@bot.on_message(filters.command("clksh") & ~filters.edited)
async def clksh_handler(_, message):
if len(message.command) < 2:
return await message.reply("Give me url to short!")
if message.from_user.id not in AUTH_USERS:
return await message.reply(
"You are not allowed to use me!\n\nContact @Yoga_CIC"
)
if CLKSH_KEY is None:
return await message.reply(
"Get `CLKSH_KEY` from [clksh](https://clk.sh/ref/YogaPranata) and fill it on vars!",
disable_web_page_preview=True,
)
link = message.text.split(None, 1)[1].strip()
link = link.replace(" ", "")
try:
r = get(f"https://clk.sh/api?api={CLKSH_KEY}&url={link}").json()
short_link = r["shortenedUrl"]
return await message.reply(
f"""Click to copy:\n\n<code>{short_link}</code>.\n\nHere is your [short link]({short_link}).""",
quote=True,
disable_web_page_preview=True,
)
except Exception as e:
return await message.reply(f"Error: {e}\n\nReport to @Yoga_CIC", quote=True)
bot.run()