forked from christhenoob13/facebotv2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.py
More file actions
78 lines (74 loc) · 2.5 KB
/
util.py
File metadata and controls
78 lines (74 loc) · 2.5 KB
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
import re
import requests
user_agent = "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Mobile Safari/537.36"
# Text fonts
def font(type, text):
real = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
def tae(fon, lis):
output = ""
for char in lis:
if char not in list(real):
output += char
else:
vh = real.index(char)
output += fon[vh]
return output
match type:
case 'bold':
BOLD = "𝗮𝗯𝗰𝗱𝗲𝗳𝗴𝗵𝗶𝗷𝗸𝗹𝗺𝗻𝗼𝗽𝗾𝗿𝘀𝘁𝘂𝘃𝘄𝘅𝘆𝘇𝗔𝗕𝗖𝗗𝗘𝗙𝗚𝗛𝗜𝗝𝗞𝗟𝗠𝗡𝗢𝗣𝗤𝗥𝗦𝗧𝗨𝗩𝗪𝗫𝗬𝗭𝟬𝟭𝟮𝟯𝟰𝟱𝟲𝟳𝟴𝟵"
return tae(BOLD, list(text))
case 'mono':
MONO = "𝚊𝚋𝚌𝚍𝚎𝚏𝚐𝚑𝚒𝚓𝚔𝚕𝚖𝚗𝚘𝚙𝚚𝚛𝚜𝚝𝚞𝚟𝚠𝚡𝚢𝚣𝙰𝙱𝙲𝙳𝙴𝙵𝙶𝙷𝙸𝙹𝙺𝙻𝙼𝙽𝙾𝙿𝚀𝚁𝚂𝚃𝚄𝚅𝚆𝚇𝚈𝚉𝟶𝟷𝟸𝟹𝟺𝟻𝟼𝟽𝟾𝟿"
return tae(MONO, list(text))
case _:
return text
def text_formatter(text):
match = re.findall(r":(\w+)\[([^\]]+)\]", text)
if len(match) < 1:
return text
else:
output = text
for TYPE, TEXT in match:
prince_text = font(TYPE, TEXT)
output = output.replace(f":{TYPE}[{TEXT}]", prince_text)
return output
# upload image to imgbb
def upload_imgbb(data):
KEY = "e58feb5f42f2cc77afd40a42e5f9747c"
base_url = "https://api.imgbb.com/1/upload"
params = {
"name": 'greegmon',
"key": KEY,
"expiration": 1512000 # 25 weeks, remove this to set no expiration
}
data = {"image": data}
try:
res = requests.post(base_url,
params=params,
data=data,
timeout=10
)
img = res.json()
if img.get('success'):
return {
"image_url": img["data"]["url"],
"width": img["data"]["width"],
"height": img["data"]["height"]
}
return {
"error": img["error"]["message"]
}
except Exception as e:
print("\033[0;31mERROR: \033[0m", e)
return {"error": 'Error while uploading the image'}
# get the link uid
def getUid(link):
if not link.startswith('https://') or 'facebook.com' not in link:
return {"error": 'Invalid link'}
res = requests.get(link)
if res.status_code == 200:
pattern = r'(?<=fb://profile/)\d+'
match = re.search(pattern, res.text)
if match:
return match.group(0)
return {"error": 'Couldn\'t get the user id'}