-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathlogogen.py
100 lines (85 loc) · 2.77 KB
/
logogen.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
# Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >.
#
# This file is part of < https://github.com/DevsExpo/FridayUserBot > project,
# and is released under the "GNU v3.0 License Agreement".
# Please see < https://github.com/DevsExpo/blob/master/LICENSE >
#
# All rights reserved.
from bs4 import *
import shutil
import requests
import os
import base64
import sys
import random
import requests
from main_startup.core.decorators import friday_on_cmd
from main_startup.helper_func.basic_helpers import edit_or_reply, get_text
def download_images(images):
print(f"Total {len(images)} Image Found!")
if len(images) != 0:
count = 0
for i, image in enumerate(images):
try:
image_link = image["data-srcset"]
except:
try:
image_link = image["data-src"]
except:
try:
image_link = image["data-fallback-src"]
except:
try:
image_link = image["src"]
except:
pass
try:
r = requests.get(image_link).content
try:
r = str(r, 'utf-8')
except UnicodeDecodeError:
with open("logo@FridayOT.jpg", "wb+") as f:
f.write(r)
count += 1
except:
pass
def mainne(name, typeo):
url = f"https://www.brandcrowd.com/maker/logos?text={name}&searchtext={typeo}&searchService="
r = requests.get(url)
soup = BeautifulSoup(r.text, 'html.parser')
images = soup.findAll('img')
random.shuffle(images)
if images is not None:
print("level 1 pass")
download_images(images)
@friday_on_cmd(
["logogen"],
is_official=False,
cmd_help={
"help": "Generate Logo With Given Name",
"example": "{ch}logogen (logo text:type)",
},
)
async def logogen(client, message):
pablo = await edit_or_reply(message, "`Creating The Logo.....`")
Godzilla = get_text(message)
if not Godzilla:
await pablo.edit("`Please Give Me A Valid Input. You Can Check Help Menu To Know More!`")
return
lmao = Godzilla.split(":", 1)
try:
typeo = lmao[1]
except BaseException:
typeo = "name"
await pablo.edit(
"Give name and type for logo Idiot. like `.logogen messi:football`")
name = lmao[0]
mainne(name, typeo)
caption = "<b>Logo Generated By FridayUserBot. Get Friday From @FridayOT<b>"
pate = "logo@FridayOT.jpg"
await client.send_photo(message.chat.id, pate)
try:
os.remove(pate)
except:
pass
await pablo.delete()