Update main.py
Browse files
main.py
CHANGED
@@ -5,6 +5,7 @@ import uvloop
|
|
5 |
import aiofiles
|
6 |
import aiohttp
|
7 |
import os
|
|
|
8 |
from bs4 import BeautifulSoup
|
9 |
|
10 |
from pydantic import BaseModel
|
@@ -23,7 +24,6 @@ from fastapi.responses import FileResponse
|
|
23 |
from pyrogram.enums import *
|
24 |
from pyrogram.errors import *
|
25 |
from pyrogram.types import *
|
26 |
-
from pyrogram import filters
|
27 |
|
28 |
from config import API_ID, API_HASH, BOT_TOKEN, SESSION
|
29 |
|
@@ -86,6 +86,28 @@ user_client = create_pyrogram(
|
|
86 |
session_string=SESSION
|
87 |
)
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
def get_random_from_channel(link):
|
90 |
clean_link = link.split("?")[0]
|
91 |
target_link = clean_link.split("/c/") if "/c/" in clean_link else clean_link.split("/")
|
@@ -97,29 +119,25 @@ def get_random_from_channel(link):
|
|
97 |
)
|
98 |
return username, random_id
|
99 |
|
100 |
-
async def upload_to_catbox(dl_path: str) -> str:
|
101 |
-
base_url = "https://catbox.moe/user/api.php"
|
102 |
-
proxy_url = f"http://186.26.92.180:58339"
|
103 |
-
async with aiohttp.ClientSession() as session:
|
104 |
-
form_data = aiohttp.FormData()
|
105 |
-
form_data.add_field("reqtype", "fileupload")
|
106 |
-
|
107 |
-
async with aiofiles.open(dl_path, mode="rb") as file:
|
108 |
-
file_data = await file.read()
|
109 |
-
form_data.add_field(
|
110 |
-
"fileToUpload",
|
111 |
-
file_data,
|
112 |
-
filename=dl_path.split("/")[-1],
|
113 |
-
content_type="application/octet-stream"
|
114 |
-
)
|
115 |
-
|
116 |
-
async with session.post(base_url, data=form_data, proxy=proxy_url) as response:
|
117 |
-
response.raise_for_status()
|
118 |
-
return (await response.text()).strip()
|
119 |
-
|
120 |
class ImageInput(BaseModel):
|
121 |
image_base64: str
|
122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
@fast_app.post("/remove-bg-base64")
|
124 |
async def remove_bg_base64(data: ImageInput):
|
125 |
try:
|
@@ -230,26 +248,6 @@ async def get_download_media_file(file_id: str = None):
|
|
230 |
}
|
231 |
"""
|
232 |
|
233 |
-
ALERT_WARN = """
|
234 |
-
π¨ Security Alert: API Key Activity Detected!
|
235 |
-
|
236 |
-
ποΈ Full Log:
|
237 |
-
|
238 |
-
`{text_log}`
|
239 |
-
|
240 |
-
π Need help? Contact support: @xpushz
|
241 |
-
"""
|
242 |
-
|
243 |
-
NOTIF_KEY = """
|
244 |
-
π¨ **Notification: API Key Expired (Premium Required)!**
|
245 |
-
|
246 |
-
Your current API key has expired. To continue using premium features, please upgrade to **Premium v2** first.
|
247 |
-
|
248 |
-
π **API Key:** <spoiler>{api_key}</spoiler>
|
249 |
-
|
250 |
-
π Need help? Contact support: @xpushz
|
251 |
-
"""
|
252 |
-
|
253 |
"""
|
254 |
@fast_app.get("/user/tg/notifications")
|
255 |
async def user_send_notif(user_id: int = None, api_key: str = None):
|
|
|
5 |
import aiofiles
|
6 |
import aiohttp
|
7 |
import os
|
8 |
+
import re
|
9 |
from bs4 import BeautifulSoup
|
10 |
|
11 |
from pydantic import BaseModel
|
|
|
24 |
from pyrogram.enums import *
|
25 |
from pyrogram.errors import *
|
26 |
from pyrogram.types import *
|
|
|
27 |
|
28 |
from config import API_ID, API_HASH, BOT_TOKEN, SESSION
|
29 |
|
|
|
86 |
session_string=SESSION
|
87 |
)
|
88 |
|
89 |
+
def contains_stylish_with_whitelist(text: str) -> bool:
|
90 |
+
emoji_pattern = re.compile(
|
91 |
+
"[\U0001F600-\U0001F64F"
|
92 |
+
"\U0001F300-\U0001F5FF"
|
93 |
+
"\U0001F680-\U0001F6FF"
|
94 |
+
"\U0001F1E6-\U0001F1FF"
|
95 |
+
"\u2600-\u26FF\u2700-\u27BF]+", flags=re.UNICODE
|
96 |
+
)
|
97 |
+
try:
|
98 |
+
text_wo_emoji = emoji_pattern.sub('', text)
|
99 |
+
except TypeError:
|
100 |
+
return False
|
101 |
+
|
102 |
+
words = text_wo_emoji.split()
|
103 |
+
for word in words:
|
104 |
+
if word.lower() in WHITELIST_WORDS:
|
105 |
+
continue
|
106 |
+
for char in word:
|
107 |
+
if ord(char) > 127 and not char.isascii():
|
108 |
+
return True
|
109 |
+
return False
|
110 |
+
|
111 |
def get_random_from_channel(link):
|
112 |
clean_link = link.split("?")[0]
|
113 |
target_link = clean_link.split("/c/") if "/c/" in clean_link else clean_link.split("/")
|
|
|
119 |
)
|
120 |
return username, random_id
|
121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
class ImageInput(BaseModel):
|
123 |
image_base64: str
|
124 |
|
125 |
+
@fast_app.get("/font-check")
|
126 |
+
async def font_check_style(text: str):
|
127 |
+
try:
|
128 |
+
return {
|
129 |
+
"status": True,
|
130 |
+
"is_fonts_detect": contains_stylish_with_whitelist(text)
|
131 |
+
"source_code": "https://github.com/TeamKillerX/Ryzenth"
|
132 |
+
}
|
133 |
+
except Exception as e:
|
134 |
+
return {
|
135 |
+
"status": False,
|
136 |
+
"is_fonts_detect": False,
|
137 |
+
"error": str(e),
|
138 |
+
"source_code": "https://github.com/TeamKillerX/Ryzenth"
|
139 |
+
}
|
140 |
+
|
141 |
@fast_app.post("/remove-bg-base64")
|
142 |
async def remove_bg_base64(data: ImageInput):
|
143 |
try:
|
|
|
248 |
}
|
249 |
"""
|
250 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
"""
|
252 |
@fast_app.get("/user/tg/notifications")
|
253 |
async def user_send_notif(user_id: int = None, api_key: str = None):
|