forked from TeamUltroid/UltroidAddons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flaticon.py
47 lines (38 loc) · 1.28 KB
/
flaticon.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
# Ultroid - UserBot
# Copyright (C) 2020 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}icon <query>`
Icon search from flaticon.com and uploading as sticker.
"""
import os
import random
import requests
from bs4 import BeautifulSoup as bs
from . import *
@ultroid_cmd(pattern="icon ?(.*)")
async def www(e):
a = e.pattern_match.group(1)
if not a:
return await eor(e, "Give some Text to Get Icon from Flaticon.com")
tt = await eor(e, "`Processing...`")
query = a.replace(" ", "%20")
try:
link = f"https://www.flaticon.com/search?word={query}"
ge = requests.get(link).content
cl = bs(ge, "lxml", from_encoding="utf-8")
results = cl.find_all(
"img", src="https://media.flaticon.com/dist/min/img/loader.gif"
)
dome = results[random.randrange(0, len(results) - 1)]["data-src"]
await download_file(dome, "sticker.webp")
await e.reply(file="sticker.webp")
os.remove("sticker.webp")
await tt.delete()
except Exception as E:
LOGS.info(E)
await tt.edit("`No Results Found`")