forked from TeamUltroid/Ultroid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspecialtools.py
362 lines (332 loc) · 10.2 KB
/
specialtools.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
358
359
360
361
362
# Ultroid - UserBot
# Copyright (C) 2021-2022 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
"""
✘ Commands Available -
• `{i}wspr <username>`
Send secret message..
• `{i}q <color-optional>`
• `{i}q @username`
• `{i}q r <color-optional>`
• `{i}q count` : `multiple quotes`
Create quotes..
• `{i}sticker <query>`
Search Stickers as Per ur Wish..
• `{i}getaudio <reply to an audio>`
Download Audio To put in ur Desired Video/Gif.
• `{i}addaudio <reply to Video/gif>`
It will put the above audio to the replied video/gif.
• `{i}dob <date of birth>`
Put in dd/mm/yy Format only(eg .dob 01/01/1999).
• `{i}wall <query>`
Search Hd Wallpaper as Per ur Wish..
"""
import os
import time
from datetime import datetime as dt
from random import choice
from shutil import rmtree
import pytz
from bs4 import BeautifulSoup as bs
from pyUltroid.functions.google_image import googleimagesdownload
from pyUltroid.functions.tools import metadata
from telethon.tl.types import DocumentAttributeVideo
from . import (
HNDLR,
async_searcher,
bash,
downloader,
eod,
get_string,
mediainfo,
quotly,
ultroid_bot,
ultroid_cmd,
uploader,
)
from .carbon import all_col
File = []
@ultroid_cmd(
pattern="getaudio$",
)
async def daudtoid(e):
if not e.reply_to:
return await eod(e, get_string("spcltool_1"))
r = await e.get_reply_message()
if not mediainfo(r.media).startswith(("audio", "video")):
return await eod(e, get_string("spcltool_1"))
xxx = await e.eor(get_string("com_1"))
dl = r.file.name or "input.mp4"
c_time = time.time()
file = await downloader(
"resources/downloads/" + dl,
r.media.document,
xxx,
c_time,
"Downloading " + dl + "...",
)
File.append(file.name)
await xxx.edit(get_string("spcltool_2"))
@ultroid_cmd(
pattern="addaudio$",
)
async def adaudroid(e):
if not e.reply_to:
return await eod(e, get_string("spcltool_3"))
r = await e.get_reply_message()
if not mediainfo(r.media).startswith("video"):
return await eod(e, get_string("spcltool_3"))
if not (File and os.path.exists(File[0])):
return await e.edit(f"`First reply an audio with {HNDLR}addaudio`")
xxx = await e.eor(get_string("com_1"))
dl = r.file.name or "input.mp4"
c_time = time.time()
file = await downloader(
"resources/downloads/" + dl,
r.media.document,
xxx,
c_time,
"Downloading " + dl + "...",
)
await xxx.edit(get_string("spcltool_5"))
await bash(
f'ffmpeg -i "{file.name}" -i "{File[0]}" -shortest -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 output.mp4'
)
out = "output.mp4"
mmmm = await uploader(
out,
out,
time.time(),
xxx,
"Uploading " + out + "...",
)
data = await metadata(out)
width = data["width"]
height = data["height"]
duration = data["duration"]
attributes = [
DocumentAttributeVideo(
duration=duration, w=width, h=height, supports_streaming=True
)
]
await e.client.send_file(
e.chat_id,
mmmm,
thumb="resources/extras/ultroid.jpg",
attributes=attributes,
force_document=False,
reply_to=e.reply_to_msg_id,
)
await xxx.delete()
os.remove(out)
os.remove(file.name)
File.clear()
os.remove(File[0])
@ultroid_cmd(
pattern=r"dob( (.*)|$)",
)
async def hbd(event):
match = event.pattern_match.group(1).strip()
if not match:
return await event.eor(get_string("spcltool_6"))
if event.reply_to_msg_id:
kk = await event.get_reply_message()
nam = await kk.get_sender()
name = nam.first_name
else:
name = ultroid_bot.me.first_name
zn = pytz.timezone("Asia/Kolkata")
abhi = dt.now(zn)
kk = match.split("/")
p = kk[0]
r = kk[1]
s = kk[2]
day = int(p)
month = r
try:
jn = dt.strptime(match, "%d/%m/%Y")
except BaseException:
return await event.eor(get_string("spcltool_6"))
jnm = zn.localize(jn)
zinda = abhi - jnm
barsh = (zinda.total_seconds()) / (365.242 * 24 * 3600)
saal = int(barsh)
mash = (barsh - saal) * 12
mahina = int(mash)
divas = (mash - mahina) * (365.242 / 12)
din = int(divas)
samay = (divas - din) * 24
ghanta = int(samay)
pehl = (samay - ghanta) * 60
mi = int(pehl)
sec = (pehl - mi) * 60
slive = int(sec)
y = int(s) + int(saal) + 1
m = int(r)
brth = dt(y, m, day)
cm = dt(abhi.year, brth.month, brth.day)
ish = (cm - abhi.today()).days + 1
dan = ish
if dan == 0:
hp = "`Happy BirthDay To U🎉🎊`"
elif dan < 0:
okk = 365 + ish
hp = f"{okk} Days Left 🥳"
elif dan > 0:
hp = f"{ish} Days Left 🥳"
if month == "12":
sign = "Sagittarius" if (day < 22) else "Capricorn"
elif month == "01":
sign = "Capricorn" if (day < 20) else "Aquarius"
elif month == "02":
sign = "Aquarius" if (day < 19) else "Pisces"
elif month == "03":
sign = "Pisces" if (day < 21) else "Aries"
elif month == "04":
sign = "Aries" if (day < 20) else "Taurus"
elif month == "05":
sign = "Taurus" if (day < 21) else "Gemini"
elif month == "06":
sign = "Gemini" if (day < 21) else "Cancer"
elif month == "07":
sign = "Cancer" if (day < 23) else "Leo"
elif month == "08":
sign = "Leo" if (day < 23) else "Virgo"
elif month == "09":
sign = "Virgo" if (day < 23) else "Libra"
elif month == "10":
sign = "Libra" if (day < 23) else "Scorpion"
elif month == "11":
sign = "Scorpio" if (day < 22) else "Sagittarius"
json = await async_searcher(
f"https://aztro.sameerkumar.website/?sign={sign}&day=today",
post=True,
re_json=True,
)
dd = json.get("current_date")
ds = json.get("description")
lt = json.get("lucky_time")
md = json.get("mood")
cl = json.get("color")
ln = json.get("lucky_number")
await event.delete()
await event.client.send_message(
event.chat_id,
f"""
Name -: {name}
D.O.B -: {match}
Lived -: {saal}yr, {mahina}m, {din}d, {ghanta}hr, {mi}min, {slive}sec
Birthday -: {hp}
Zodiac -: {sign}
**Horoscope On {dd} -**
`{ds}`
Lucky Time :- {lt}
Lucky Number :- {ln}
Lucky Color :- {cl}
Mood :- {md}
""",
reply_to=event.reply_to_msg_id,
)
@ultroid_cmd(pattern="sticker( (.*)|$)")
async def _(event):
x = event.pattern_match.group(1).strip()
if not x:
return await event.eor("`Give something to search`")
uu = await event.eor(get_string("com_1"))
z = bs(
await async_searcher("https://combot.org/telegram/stickers?q=" + x),
"html.parser",
)
packs = z.find_all("div", "sticker-pack__header")
sticks = {
c.a["href"]: c.find("div", {"class": "sticker-pack__title"}).text for c in packs
}
if not sticks:
return await uu.edit(get_string("spcltool_9"))
a = "SᴛɪᴄᴋEʀs Aᴠᴀɪʟᴀʙʟᴇ ~\n\n"
for _, value in sticks.items():
a += f"<a href={_}>{value}</a>\n"
await uu.edit(a, parse_mode="html")
@ultroid_cmd(pattern="wall( (.*)|$)")
async def wall(event):
inp = event.pattern_match.group(1).strip()
if not inp:
return await event.eor("`Give me something to search..`")
nn = await event.eor(get_string("com_1"))
query = f"hd {inp}"
gi = googleimagesdownload()
args = {
"keywords": query,
"limit": 10,
"format": "jpg",
"output_directory": "./resources/downloads/",
}
await gi.download(args)
xx = choice(os.listdir(os.path.abspath(f"./resources/downloads/{query}/")))
await event.client.send_file(event.chat_id, f"./resources/downloads/{query}/{xx}")
rmtree(f"./resources/downloads/{query}/")
await nn.delete()
@ultroid_cmd(pattern="q( (.*)|$)", manager=True, allow_pm=True)
async def quott_(event):
match = event.pattern_match.group(1).strip()
if not event.is_reply:
return await event.eor("`Reply to Message..`")
msg = await event.eor(get_string("com_1"))
reply = await event.get_reply_message()
replied_to, reply_ = None, None
if match:
spli_ = match.split(maxsplit=1)
if (spli_[0] in ["r", "reply"]) or (
spli_[0].isdigit() and int(spli_[0]) in range(1, 21)
):
if spli_[0].isdigit():
if not event.client._bot:
reply_ = await event.client.get_messages(
event.chat_id,
min_id=event.reply_to_msg_id - 1,
reverse=True,
limit=int(spli_[0]),
)
else:
id_ = reply.id
reply_ = []
for msg_ in range(id_, id_ + int(spli_[0])):
msh = await event.client.get_messages(event.chat_id, ids=msg_)
if msh:
reply_.append(msh)
else:
replied_to = await reply.get_reply_message()
try:
match = spli_[1]
except IndexError:
match = None
user = None
if not reply_:
reply_ = reply
if match:
match = match.split(maxsplit=1)
if match:
if match[0].startswith("@") or match[0].isdigit():
try:
match_ = await event.client.parse_id(match[0])
user = await event.client.get_entity(match_)
except ValueError:
pass
match = match[1] if len(match) == 2 else None
else:
match = match[0]
if match == "random":
match = choice(all_col)
try:
file = await quotly.create_quotly(
reply_, bg=match, reply=replied_to, sender=user
)
except Exception as er:
return await msg.edit(str(er))
message = await reply.reply("Quotly by Ultroid", file=file)
os.remove(file)
await msg.delete()
return message