HotLints
This commit is contained in:
@@ -57,13 +57,9 @@ def update_cache():
|
||||
|
||||
@Client.on_message(filters.group & ~filters.me)
|
||||
async def admintool_handler(_, message: Message):
|
||||
if (
|
||||
message.sender_chat
|
||||
and (
|
||||
message.sender_chat.type == "supergroup"
|
||||
or message.sender_chat.id
|
||||
== db_cache.get(f"linked{message.chat.id}", 0)
|
||||
)
|
||||
if message.sender_chat and (
|
||||
message.sender_chat.type == "supergroup"
|
||||
or message.sender_chat.id == db_cache.get(f"linked{message.chat.id}", 0)
|
||||
):
|
||||
raise ContinuePropagation
|
||||
|
||||
@@ -90,9 +86,8 @@ async def admintool_handler(_, message: Message):
|
||||
elif message.sender_chat:
|
||||
await message.chat.ban_member(message.sender_chat.id)
|
||||
|
||||
if (
|
||||
message.new_chat_members
|
||||
and db_cache.get(f"welcome_enabled{message.chat.id}", False)
|
||||
if message.new_chat_members and db_cache.get(
|
||||
f"welcome_enabled{message.chat.id}", False
|
||||
):
|
||||
await message.reply(
|
||||
db_cache.get(f"welcome_text{message.chat.id}"),
|
||||
@@ -257,9 +252,7 @@ async def ro(client: Client, message: Message):
|
||||
db.set("core.ats", f"ro{message.chat.id}", perms_list)
|
||||
|
||||
try:
|
||||
await client.set_chat_permissions(
|
||||
message.chat.id, ChatPermissions()
|
||||
)
|
||||
await client.set_chat_permissions(message.chat.id, ChatPermissions())
|
||||
except (UserAdminInvalid, ChatAdminRequired):
|
||||
await message.edit("<b>No rights</b>")
|
||||
else:
|
||||
|
||||
@@ -134,7 +134,7 @@ async def afk_unset(_, message: Message):
|
||||
await message.edit(
|
||||
f"<code>While you were away (for {last_seen}), you received {sum(USERS.values()) + sum(GROUPS.values())} "
|
||||
f"messages from {len(USERS) + len(GROUPS)} chats</code>",
|
||||
)
|
||||
)
|
||||
AFK = False
|
||||
AFK_TIME = ""
|
||||
AFK_REASON = ""
|
||||
@@ -168,5 +168,3 @@ modules_help["afk"] = {
|
||||
"afk [reason]": "Go to AFK mode with reason as anything after .afk\nUsage: <code>.afk <reason></code>",
|
||||
"unafk": "Get out of AFK",
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,13 +15,17 @@ api_url = "https://visioncraft.top"
|
||||
|
||||
async def fetch_models():
|
||||
"""Get all available SDXL models"""
|
||||
async with aiohttp.ClientSession() as session, session.get("https://visioncraft.top/sd/models") as response:
|
||||
async with aiohttp.ClientSession() as session, session.get(
|
||||
"https://visioncraft.top/sd/models"
|
||||
) as response:
|
||||
return await response.json()
|
||||
|
||||
|
||||
async def fetch_upscale_models():
|
||||
"""Get all available upscale models"""
|
||||
async with aiohttp.ClientSession() as session, session.get("https://visioncraft.top/models-upscale") as response:
|
||||
async with aiohttp.ClientSession() as session, session.get(
|
||||
"https://visioncraft.top/models-upscale"
|
||||
) as response:
|
||||
return await response.json()
|
||||
|
||||
|
||||
@@ -35,13 +39,17 @@ async def generate_gifs(data):
|
||||
|
||||
async def generate_images(data):
|
||||
"""Helper Function to generate image using SDXL"""
|
||||
async with aiohttp.ClientSession() as session, session.post(f"{api_url}/sd", json=data) as response:
|
||||
async with aiohttp.ClientSession() as session, session.post(
|
||||
f"{api_url}/sd", json=data
|
||||
) as response:
|
||||
return await response.read()
|
||||
|
||||
|
||||
async def generate_dalle(data):
|
||||
"""Helper Function to generate image using DALL-E 3"""
|
||||
async with aiohttp.ClientSession() as session, session.post(f"{api_url}/dalle", json=data) as response:
|
||||
async with aiohttp.ClientSession() as session, session.post(
|
||||
f"{api_url}/dalle", json=data
|
||||
) as response:
|
||||
return await response.read()
|
||||
|
||||
|
||||
@@ -85,7 +93,9 @@ async def transcribe_audio(api_key, audio_data, language, task):
|
||||
"task": task,
|
||||
}
|
||||
|
||||
async with aiohttp.ClientSession() as session, session.post(f"{api_url}/whisper", json=payload) as response:
|
||||
async with aiohttp.ClientSession() as session, session.post(
|
||||
f"{api_url}/whisper", json=payload
|
||||
) as response:
|
||||
return await response.json()
|
||||
|
||||
|
||||
|
||||
@@ -186,5 +186,3 @@ modules_help["antipm"] = {
|
||||
"a": "Approve User",
|
||||
"d": "DisApprove User",
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ from pyrogram.types import Message
|
||||
from utils.misc import modules_help, prefix
|
||||
|
||||
|
||||
|
||||
def subprocess_run(cmd):
|
||||
reply = ""
|
||||
subproc = Popen(
|
||||
@@ -80,7 +79,7 @@ async def direct_link_generator(_, m: Message):
|
||||
|
||||
|
||||
def gdrive(url: str) -> str:
|
||||
""" GDrive direct links generator """
|
||||
"""GDrive direct links generator"""
|
||||
drive = "https://drive.google.com"
|
||||
try:
|
||||
link = re.findall(r"\bhttps?://drive\.google\.com\S+", url)[0]
|
||||
@@ -132,7 +131,6 @@ def gdrive(url: str) -> str:
|
||||
return reply
|
||||
|
||||
|
||||
|
||||
def yandex_disk(url: str) -> str:
|
||||
"""Yandex.Disk direct links generator
|
||||
Based on https://github.com/wldhx/yadisk-direct"""
|
||||
@@ -180,7 +178,7 @@ def cm_ru(url: str) -> str:
|
||||
|
||||
|
||||
def mediafire(url: str) -> str:
|
||||
""" MediaFire direct links generator """
|
||||
"""MediaFire direct links generator"""
|
||||
try:
|
||||
link = re.findall(r"\bhttps?://.*mediafire\.com\S+", url)[0]
|
||||
except IndexError:
|
||||
@@ -197,7 +195,7 @@ def mediafire(url: str) -> str:
|
||||
|
||||
|
||||
def sourceforge(url: str) -> str:
|
||||
""" SourceForge direct links generator """
|
||||
"""SourceForge direct links generator"""
|
||||
try:
|
||||
link = re.findall(r"\bhttps?://.*sourceforge\.net\S+", url)[0]
|
||||
except IndexError:
|
||||
@@ -222,7 +220,7 @@ def sourceforge(url: str) -> str:
|
||||
|
||||
|
||||
def osdn(url: str) -> str:
|
||||
""" OSDN direct links generator """
|
||||
"""OSDN direct links generator"""
|
||||
osdn_link = "https://osdn.net"
|
||||
try:
|
||||
link = re.findall(r"\bhttps?://.*osdn\.net\S+", url)[0]
|
||||
@@ -243,7 +241,7 @@ def osdn(url: str) -> str:
|
||||
|
||||
|
||||
def androidfilehost(url: str) -> str:
|
||||
""" AFH direct links generator """
|
||||
"""AFH direct links generator"""
|
||||
try:
|
||||
link = re.findall(r"\bhttps?://.*androidfilehost.*fid.*\S+", url)[0]
|
||||
except IndexError:
|
||||
@@ -291,24 +289,25 @@ def androidfilehost(url: str) -> str:
|
||||
|
||||
|
||||
def useragent():
|
||||
"""
|
||||
useragent random setter
|
||||
"""
|
||||
useragents = BeautifulSoup(
|
||||
requests.get(
|
||||
"https://developers.whatismybrowser.com/"
|
||||
"useragents/explore/operating_system_name/android/"
|
||||
).content,
|
||||
"lxml",
|
||||
).findAll("td", {"class": "useragent"})
|
||||
if not useragents:
|
||||
return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"
|
||||
user_agent = choice(useragents)
|
||||
return user_agent.text
|
||||
"""
|
||||
useragent random setter
|
||||
"""
|
||||
useragents = BeautifulSoup(
|
||||
requests.get(
|
||||
"https://developers.whatismybrowser.com/"
|
||||
"useragents/explore/operating_system_name/android/"
|
||||
).content,
|
||||
"lxml",
|
||||
).findAll("td", {"class": "useragent"})
|
||||
if not useragents:
|
||||
return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"
|
||||
user_agent = choice(useragents)
|
||||
return user_agent.text
|
||||
|
||||
|
||||
modules_help["direct"] = {
|
||||
"direct": "Url/reply to Url\
|
||||
"direct": "Url/reply to Url\
|
||||
\n\n<b>Syntax : </b><code>.direct [url/reply] </code>\
|
||||
\n<b>Usage :</b> Generates direct download link from supported URL(s)\
|
||||
\n\n<b>Supported websites : </b><code>Google Drive - MEGA.nz - Cloud Mail - Yandex.Disk - AFH - MediaFire - SourceForge - OSDN</code>"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,17 +49,11 @@ async def help_cmd(_, message: Message):
|
||||
text += f"<b>The number of modules in the userbot: {len(modules_help)}</b>"
|
||||
|
||||
if msg_edited:
|
||||
await message.reply(
|
||||
text, disable_web_page_preview=True
|
||||
)
|
||||
await message.reply(text, disable_web_page_preview=True)
|
||||
else:
|
||||
await message.edit(
|
||||
text, disable_web_page_preview=True
|
||||
)
|
||||
await message.edit(text, disable_web_page_preview=True)
|
||||
elif message.command[1].lower() in modules_help:
|
||||
await message.edit(
|
||||
format_module_help(message.command[1].lower(), prefix)
|
||||
)
|
||||
await message.edit(format_module_help(message.command[1].lower(), prefix))
|
||||
else:
|
||||
command_name = message.command[1].lower()
|
||||
for name, commands in modules_help.items():
|
||||
@@ -74,9 +68,7 @@ async def help_cmd(_, message: Message):
|
||||
f"{' <code>' + cmd[1] + '</code>' if len(cmd) > 1 else ''}"
|
||||
f" — <i>{cmd_desc}</i>",
|
||||
)
|
||||
await message.edit(
|
||||
f"<b>Module {command_name} not found</b>"
|
||||
)
|
||||
await message.edit(f"<b>Module {command_name} not found</b>")
|
||||
# TODO: refactor this cringe
|
||||
command_name = message.command[1].lower()
|
||||
for name, commands in modules_help.items():
|
||||
@@ -91,9 +83,7 @@ async def help_cmd(_, message: Message):
|
||||
f"{' <code>' + cmd[1] + '</code>' if len(cmd) > 1 else ''}"
|
||||
f" — <i>{cmd_desc}</i>",
|
||||
)
|
||||
await message.edit(
|
||||
f"<b>Module {command_name} not found</b>"
|
||||
)
|
||||
await message.edit(f"<b>Module {command_name} not found</b>")
|
||||
|
||||
|
||||
modules_help["help"] = {"help [module/command name]": "Get common/module/command help"}
|
||||
|
||||
@@ -8,6 +8,7 @@ from utils.misc import modules_help, prefix
|
||||
from utils.scripts import format_exc
|
||||
from utils.lexicapi import ImageGeneration, UpscaleImages, ImageModels
|
||||
|
||||
|
||||
@Client.on_message(filters.command("lupscale", prefix) & filters.me)
|
||||
async def lupscale(client: Client, message: Message):
|
||||
"""Upscale Image Using Lexica API"""
|
||||
@@ -22,7 +23,7 @@ async def lupscale(client: Client, message: Message):
|
||||
await message.edit("<b>File not found</b>")
|
||||
return
|
||||
try:
|
||||
with open(photo_data, 'rb') as image_file:
|
||||
with open(photo_data, "rb") as image_file:
|
||||
image = image_file.read()
|
||||
upscaled_image = await UpscaleImages(image)
|
||||
if message.reply_to_message:
|
||||
@@ -30,11 +31,17 @@ async def lupscale(client: Client, message: Message):
|
||||
await message.delete()
|
||||
else:
|
||||
message_id = message.id
|
||||
await client.send_document(message.chat.id, upscaled_image, caption="Upscaled!", reply_to_message_id=message_id)
|
||||
await client.send_document(
|
||||
message.chat.id,
|
||||
upscaled_image,
|
||||
caption="Upscaled!",
|
||||
reply_to_message_id=message_id,
|
||||
)
|
||||
os.remove(upscaled_image)
|
||||
except Exception as e:
|
||||
await message.edit(format_exc(e))
|
||||
|
||||
|
||||
@Client.on_message(filters.command("lgen", prefix) & filters.me)
|
||||
async def lgen(client: Client, message: Message):
|
||||
try:
|
||||
@@ -46,17 +53,23 @@ async def lgen(client: Client, message: Message):
|
||||
if len(message.command) > 2:
|
||||
model_id = int(message.text.split()[1])
|
||||
if model_id not in models_ids:
|
||||
return await message.edit_text(f"<b>Usage: </b><code>{prefix}lgen [model_id]* [prompt/reply to prompt]*</code>\n <b>Available Models and IDs:</b> <blockquote>{models}</blockquote>")
|
||||
return await message.edit_text(
|
||||
f"<b>Usage: </b><code>{prefix}lgen [model_id]* [prompt/reply to prompt]*</code>\n <b>Available Models and IDs:</b> <blockquote>{models}</blockquote>"
|
||||
)
|
||||
message_id = None
|
||||
prompt = ' '.join(message.text.split()[2:])
|
||||
prompt = " ".join(message.text.split()[2:])
|
||||
elif message.reply_to_message and len(message.command) > 1:
|
||||
model_id = int(message.text.split()[1])
|
||||
if model_id not in models_ids:
|
||||
return await message.edit_text(f"<b>Usage: </b><code>{prefix}lgen [model_id]* [prompt/reply to prompt]*</code>\n <b>Available Models and IDs:</b> <blockquote>{models}</blockquote>")
|
||||
return await message.edit_text(
|
||||
f"<b>Usage: </b><code>{prefix}lgen [model_id]* [prompt/reply to prompt]*</code>\n <b>Available Models and IDs:</b> <blockquote>{models}</blockquote>"
|
||||
)
|
||||
message_id = message.reply_to_message.id
|
||||
prompt = message.reply_to_message.text
|
||||
else:
|
||||
return await message.edit_text(f"<b>Usage: </b><code>{prefix}lgen [model_id]* [prompt/reply to prompt]*</code>\n <b>Available Models and IDs:</b> <blockquote>{models}</blockquote>")
|
||||
return await message.edit_text(
|
||||
f"<b>Usage: </b><code>{prefix}lgen [model_id]* [prompt/reply to prompt]*</code>\n <b>Available Models and IDs:</b> <blockquote>{models}</blockquote>"
|
||||
)
|
||||
|
||||
for key, val in models.items():
|
||||
if val == model_id:
|
||||
@@ -68,14 +81,20 @@ async def lgen(client: Client, message: Message):
|
||||
if img == 69:
|
||||
return await message.edit_text("NSFW is not allowed")
|
||||
img_url = img[0]
|
||||
with open("generated_image.png", 'wb') as f:
|
||||
with open("generated_image.png", "wb") as f:
|
||||
f.write(requests.get(img_url, timeout=5).content)
|
||||
|
||||
await client.send_document(message.chat.id, "generated_image.png", caption=f"<b>Prompt: </b><code>{prompt}</code>\n<b>Model: </b><code>{model_name}</code>", reply_to_message_id=message_id)
|
||||
await client.send_document(
|
||||
message.chat.id,
|
||||
"generated_image.png",
|
||||
caption=f"<b>Prompt: </b><code>{prompt}</code>\n<b>Model: </b><code>{model_name}</code>",
|
||||
reply_to_message_id=message_id,
|
||||
)
|
||||
os.remove("generated_image.png")
|
||||
except Exception as e:
|
||||
await message.edit(format_exc(e))
|
||||
|
||||
|
||||
modules_help["lexica"] = {
|
||||
"lgen [model_id]* [prompt/reply to prompt]*": "Generate Image with Lexica API",
|
||||
"lupscale [cap/reply to image]*": "Upscale Image through Lexica API",
|
||||
|
||||
@@ -221,4 +221,3 @@ modules_help["loader"] = {
|
||||
"loadallmods": "Load all custom modules (use it at your own risk)",
|
||||
"updateallmods": "Update all custom modules",
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,8 @@ async def openfile(client: Client, message: Message):
|
||||
)
|
||||
content_new = f"{code_start}\n{content}{code_end}"
|
||||
paste = subprocess.run(
|
||||
["rentry", "new", content_new], capture_output=True, text=True, check=True)
|
||||
["rentry", "new", content_new], capture_output=True, text=True, check=True
|
||||
)
|
||||
await client.send_message("me", paste.stdout, disable_web_page_preview=True)
|
||||
lines = paste.stdout.split("\n")
|
||||
for line in lines:
|
||||
|
||||
@@ -29,9 +29,7 @@ async def ping(_, message: Message):
|
||||
start = perf_counter()
|
||||
await message.edit("<b>Pong!</b>")
|
||||
end = perf_counter()
|
||||
await message.edit(
|
||||
f"<b>Pong! {round(end - start, 3)}s</b>"
|
||||
)
|
||||
await message.edit(f"<b>Pong! {round(end - start, 3)}s</b>")
|
||||
|
||||
|
||||
modules_help["ping"] = {
|
||||
|
||||
@@ -29,14 +29,10 @@ async def setprefix(_, message: Message):
|
||||
if len(message.command) > 1:
|
||||
pref = message.command[1]
|
||||
db.set("core.main", "prefix", pref)
|
||||
await message.edit(
|
||||
f"<b>Prefix [ <code>{pref}</code> ] is set!</b>"
|
||||
)
|
||||
await message.edit(f"<b>Prefix [ <code>{pref}</code> ] is set!</b>")
|
||||
restart()
|
||||
else:
|
||||
await message.edit(
|
||||
"<b>The prefix must not be empty!</b>"
|
||||
)
|
||||
await message.edit("<b>The prefix must not be empty!</b>")
|
||||
|
||||
|
||||
modules_help["prefix"] = {
|
||||
|
||||
@@ -37,9 +37,7 @@ from utils.scripts import format_exc
|
||||
)
|
||||
async def user_exec(client: Client, message: Message):
|
||||
if len(message.command) == 1:
|
||||
await message.edit(
|
||||
"<b>Code to execute isn't provided</b>"
|
||||
)
|
||||
await message.edit("<b>Code to execute isn't provided</b>")
|
||||
return
|
||||
|
||||
code = message.text.split(maxsplit=1)[1]
|
||||
|
||||
@@ -83,8 +83,8 @@ def _check_rmbg(func):
|
||||
if not rmbg_key:
|
||||
await edit_or_reply(
|
||||
message,
|
||||
"<code>Is Your RMBG Api 'rmbg_key' Valid Or You Didn't Add It??</code>"
|
||||
)
|
||||
"<code>Is Your RMBG Api 'rmbg_key' Valid Or You Didn't Add It??</code>",
|
||||
)
|
||||
else:
|
||||
await func(client, message)
|
||||
|
||||
@@ -129,13 +129,14 @@ async def rmbg(client: Client, message: Message):
|
||||
ms = (end - start).seconds
|
||||
await pablo.edit(
|
||||
f"<code>Removed image's Background in {ms} seconds, powered by </code> <b>@moonuserbot</b>"
|
||||
)
|
||||
)
|
||||
if os.path.exists("BG_rem.png"):
|
||||
os.remove("BG_rem.png")
|
||||
else:
|
||||
await pablo.edit(
|
||||
"ReMove.BG API returned Errors. Please report to @moonub_chat"
|
||||
+ f"\n`{output_file_name.content.decode('UTF-8')}")
|
||||
+ f"\n`{output_file_name.content.decode('UTF-8')}"
|
||||
)
|
||||
|
||||
|
||||
@Client.on_message(filters.command("rebg", prefix) & filters.me)
|
||||
@@ -149,9 +150,7 @@ async def rembg(client: Client, message: Message):
|
||||
try:
|
||||
photo_data = await message.reply_to_message.download()
|
||||
except ValueError:
|
||||
await message.edit(
|
||||
"<b>File not found</b>"
|
||||
)
|
||||
await message.edit("<b>File not found</b>")
|
||||
return
|
||||
background_removed_data = remove_background(photo_data)
|
||||
|
||||
|
||||
@@ -10,39 +10,39 @@ from pyrogram.errors import MediaCaptionTooLong, MessageTooLong
|
||||
from utils.misc import prefix, modules_help
|
||||
from utils.scripts import format_exc
|
||||
|
||||
url = 'https://api.safone.dev'
|
||||
url = "https://api.safone.dev"
|
||||
|
||||
headers = {
|
||||
'Accept-Language': 'en-US,en;q=0.9',
|
||||
'Connection': 'keep-alive',
|
||||
'DNT': '1',
|
||||
'Referer': 'https://api.safone.dev/docs',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
|
||||
'accept': 'application/json',
|
||||
'sec-ch-ua': '"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"Linux"'
|
||||
"Accept-Language": "en-US,en;q=0.9",
|
||||
"Connection": "keep-alive",
|
||||
"DNT": "1",
|
||||
"Referer": "https://api.safone.dev/docs",
|
||||
"Sec-Fetch-Dest": "empty",
|
||||
"Sec-Fetch-Mode": "cors",
|
||||
"Sec-Fetch-Site": "same-origin",
|
||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
|
||||
"accept": "application/json",
|
||||
"sec-ch-ua": '"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"',
|
||||
"sec-ch-ua-mobile": "?0",
|
||||
"sec-ch-ua-platform": '"Linux"',
|
||||
}
|
||||
|
||||
|
||||
async def telegraph(title, user_name, content):
|
||||
|
||||
formatted_content = '<br>'.join(content.split('\n'))
|
||||
formatted_content = '<p>' + formatted_content + '</p>'
|
||||
formatted_content = "<br>".join(content.split("\n"))
|
||||
formatted_content = "<p>" + formatted_content + "</p>"
|
||||
|
||||
data = {
|
||||
"title": title,
|
||||
"content": formatted_content,
|
||||
"author_name": user_name
|
||||
}
|
||||
data = {"title": title, "content": formatted_content, "author_name": user_name}
|
||||
|
||||
response = requests.post(url=f"{url}/telegraph/text", headers=headers, json=data, timeout=5)
|
||||
response = requests.post(
|
||||
url=f"{url}/telegraph/text", headers=headers, json=data, timeout=5
|
||||
)
|
||||
|
||||
result = response.json()
|
||||
|
||||
return result['url']
|
||||
return result["url"]
|
||||
|
||||
|
||||
async def voice_characters():
|
||||
|
||||
@@ -50,7 +50,8 @@ async def voice_characters():
|
||||
|
||||
result = response.json()
|
||||
|
||||
return ', '.join(result['characters'])
|
||||
return ", ".join(result["characters"])
|
||||
|
||||
|
||||
@Client.on_message(filters.command("app", prefix) & filters.me)
|
||||
async def app(client: Client, message: Message):
|
||||
@@ -60,9 +61,13 @@ async def app(client: Client, message: Message):
|
||||
if len(message.command) > 1:
|
||||
query = message.text.split(maxsplit=1)[1]
|
||||
else:
|
||||
message.edit_text("What should i search? You didn't provided me with any value to search")
|
||||
message.edit_text(
|
||||
"What should i search? You didn't provided me with any value to search"
|
||||
)
|
||||
|
||||
response = requests.get(url=f"{url}/apps?query={query}&limit=1", headers=headers, timeout=5)
|
||||
response = requests.get(
|
||||
url=f"{url}/apps?query={query}&limit=1", headers=headers, timeout=5
|
||||
)
|
||||
if response.status_code != 200:
|
||||
await message.edit_text("Something went wrong")
|
||||
return
|
||||
@@ -70,30 +75,34 @@ async def app(client: Client, message: Message):
|
||||
result = response.json()
|
||||
|
||||
try:
|
||||
coverImage_url = result['results'][0]['icon']
|
||||
coverImage_url = result["results"][0]["icon"]
|
||||
coverImage = requests.get(url=coverImage_url).content
|
||||
async with aiofiles.open('coverImage.jpg', mode='wb') as f:
|
||||
async with aiofiles.open("coverImage.jpg", mode="wb") as f:
|
||||
await f.write(coverImage)
|
||||
|
||||
except Exception:
|
||||
coverImage = None
|
||||
|
||||
description = result['results'][0]['description']
|
||||
developer = result['results'][0]['developer']
|
||||
IsFree = result['results'][0]['free']
|
||||
genre = result['results'][0]['genre']
|
||||
package_name = result['results'][0]['id']
|
||||
title = result['results'][0]['title']
|
||||
price = result['results'][0]['price']
|
||||
link = result['results'][0]['link']
|
||||
rating = result['results'][0]['rating']
|
||||
description = result["results"][0]["description"]
|
||||
developer = result["results"][0]["developer"]
|
||||
IsFree = result["results"][0]["free"]
|
||||
genre = result["results"][0]["genre"]
|
||||
package_name = result["results"][0]["id"]
|
||||
title = result["results"][0]["title"]
|
||||
price = result["results"][0]["price"]
|
||||
link = result["results"][0]["link"]
|
||||
rating = result["results"][0]["rating"]
|
||||
|
||||
await message.delete()
|
||||
await client.send_media_group(
|
||||
chat_id,
|
||||
[
|
||||
InputMediaPhoto('coverImage.jpg', caption=f"<b>Title:</b> <code>{title}</code>\n<b>Rating:</b> <code>{rating}</code>\n<b>IsFree:</b> <code>{IsFree}</code>\n<b>Price:</b> <code>{price}</code>\n<b>Package Name:</b> <code>{package_name}</code>\n<b>Genres:</b> <code>{genre}</code>\n<b>Developer:</b> <code>{developer}\n<b>Description:</b> {description}\n<b>Link:</b> {link}")
|
||||
])
|
||||
InputMediaPhoto(
|
||||
"coverImage.jpg",
|
||||
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Rating:</b> <code>{rating}</code>\n<b>IsFree:</b> <code>{IsFree}</code>\n<b>Price:</b> <code>{price}</code>\n<b>Package Name:</b> <code>{package_name}</code>\n<b>Genres:</b> <code>{genre}</code>\n<b>Developer:</b> <code>{developer}\n<b>Description:</b> {description}\n<b>Link:</b> {link}",
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
except MediaCaptionTooLong:
|
||||
description = description[:850]
|
||||
@@ -101,13 +110,17 @@ async def app(client: Client, message: Message):
|
||||
await client.send_media_group(
|
||||
chat_id,
|
||||
[
|
||||
InputMediaPhoto('coverImage.jpg', caption=f"<b>Title:</b> <code>{title}</code>\n<b>Rating:</b> <code>{rating}</code>\n<b>IsFree:</b> <code>{IsFree}</code>\n<b>Price:</b> <code>{price}</code>\n<b>Package Name:</b> <code>{package_name}</code>\n<b>Genres:</b> <code>{genre}</code>\n<b>Developer:</b> <code>{developer}\n<b>Description:</b> {description}\n<b>Link:</b> {link}")
|
||||
])
|
||||
InputMediaPhoto(
|
||||
"coverImage.jpg",
|
||||
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Rating:</b> <code>{rating}</code>\n<b>IsFree:</b> <code>{IsFree}</code>\n<b>Price:</b> <code>{price}</code>\n<b>Package Name:</b> <code>{package_name}</code>\n<b>Genres:</b> <code>{genre}</code>\n<b>Developer:</b> <code>{developer}\n<b>Description:</b> {description}\n<b>Link:</b> {link}",
|
||||
)
|
||||
],
|
||||
)
|
||||
except Exception as e:
|
||||
await message.edit_text(format_exc(e))
|
||||
finally:
|
||||
if os.path.exists('coverImage.jpg'):
|
||||
os.remove('coverImage.jpg')
|
||||
if os.path.exists("coverImage.jpg"):
|
||||
os.remove("coverImage.jpg")
|
||||
|
||||
|
||||
@Client.on_message(filters.command("tsearch", prefix) & filters.me)
|
||||
@@ -119,57 +132,73 @@ async def tsearch(client: Client, message: Message):
|
||||
if len(message.command) > 1:
|
||||
query = message.text.split(maxsplit=1)[1]
|
||||
else:
|
||||
message.edit_text("What should i search? You didn't provided me with any value to search")
|
||||
message.edit_text(
|
||||
"What should i search? You didn't provided me with any value to search"
|
||||
)
|
||||
|
||||
response = requests.get(url=f"{url}/torrent?query={query}&limit={limit}", headers=headers)
|
||||
response = requests.get(
|
||||
url=f"{url}/torrent?query={query}&limit={limit}", headers=headers
|
||||
)
|
||||
if response.status_code != 200:
|
||||
await message.edit_text("Something went wrong")
|
||||
return
|
||||
|
||||
result = response.json()
|
||||
|
||||
coverImage_url = result['results'][0]['thumbnail']
|
||||
description = result['results'][0]['description']
|
||||
genre = result['results'][0]['genre']
|
||||
category = result['results'][0]['category']
|
||||
title = result['results'][0]['name']
|
||||
link = result['results'][0]['magnetLink']
|
||||
link_result = await telegraph(title=title,user_name=message.from_user.first_name, content=link)
|
||||
language = result['results'][0]['language']
|
||||
size = result['results'][0]['size']
|
||||
coverImage_url = result["results"][0]["thumbnail"]
|
||||
description = result["results"][0]["description"]
|
||||
genre = result["results"][0]["genre"]
|
||||
category = result["results"][0]["category"]
|
||||
title = result["results"][0]["name"]
|
||||
link = result["results"][0]["magnetLink"]
|
||||
link_result = await telegraph(
|
||||
title=title, user_name=message.from_user.first_name, content=link
|
||||
)
|
||||
language = result["results"][0]["language"]
|
||||
size = result["results"][0]["size"]
|
||||
|
||||
results = []
|
||||
|
||||
for i in range(min(limit, len(result['results']))):
|
||||
descriptions = result['results'][i]['description']
|
||||
genres = result['results'][i]['genre']
|
||||
categorys = result['results'][i]['category']
|
||||
titles = result['results'][i]['name']
|
||||
links = result['results'][i]['magnetLink']
|
||||
languages = result['results'][i]['language']
|
||||
sizes = result['results'][i]['size']
|
||||
for i in range(min(limit, len(result["results"]))):
|
||||
descriptions = result["results"][i]["description"]
|
||||
genres = result["results"][i]["genre"]
|
||||
categorys = result["results"][i]["category"]
|
||||
titles = result["results"][i]["name"]
|
||||
links = result["results"][i]["magnetLink"]
|
||||
languages = result["results"][i]["language"]
|
||||
sizes = result["results"][i]["size"]
|
||||
|
||||
r = f"<b>Title:</b> <code>{titles}</code>\n<b>Category:</b> <code>{categorys}</code>\n<b>Language:</b> <code>{languages}</code>\n<b>Size:</b> <code>{sizes}</code>\n<b>Genres:</b> <code>{genres}</code>\n<b>Description:</b> {descriptions}\n<b>Magnet Link:</b> <code>{links}</code><br>"
|
||||
results.append(r)
|
||||
|
||||
all_results_content = '<br>'.join(results)
|
||||
all_results_content = "<br>".join(results)
|
||||
|
||||
link_results = await telegraph(title="Search Results", user_name=message.from_user.first_name, content=all_results_content)
|
||||
link_results = await telegraph(
|
||||
title="Search Results",
|
||||
user_name=message.from_user.first_name,
|
||||
content=all_results_content,
|
||||
)
|
||||
|
||||
if coverImage_url is not None:
|
||||
coverImage = requests.get(url=coverImage_url).content
|
||||
async with aiofiles.open('coverImage.jpg', mode='wb') as f:
|
||||
async with aiofiles.open("coverImage.jpg", mode="wb") as f:
|
||||
await f.write(coverImage)
|
||||
|
||||
await message.delete()
|
||||
await client.send_media_group(
|
||||
chat_id,
|
||||
[
|
||||
InputMediaPhoto('coverImage.jpg', caption=f"<b>Title:</b> <code>{title}</code>\n<b>Category:</b> <code>{category}</code>\n<b>Language:</b> <code>{language}</code>\n<b>Size:</b> <code>{size}</code>\n<b>Genres:</b> <code>{genre}</code>\n<b>Description:</b> {description}\n<b>Magnet Link:</b> <a href='{link_result}'>Click Here</a>\n<b>More Results:</b> <a href='{link_results}'>Click Here</a>")
|
||||
])
|
||||
InputMediaPhoto(
|
||||
"coverImage.jpg",
|
||||
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Category:</b> <code>{category}</code>\n<b>Language:</b> <code>{language}</code>\n<b>Size:</b> <code>{size}</code>\n<b>Genres:</b> <code>{genre}</code>\n<b>Description:</b> {description}\n<b>Magnet Link:</b> <a href='{link_result}'>Click Here</a>\n<b>More Results:</b> <a href='{link_results}'>Click Here</a>",
|
||||
)
|
||||
],
|
||||
)
|
||||
else:
|
||||
await message.edit_text(f"<b>Title:</b> <code>{title}</code>\n<b>Category:</b> <code>{category}</code>\n<b>Language:</b> <code>{language}</code>\n<b>Size:</b> <code>{size}</code>\n<b>Genres:</b> <code>{genre}</code>\n<b>Description:</b> {description}\n<b>Magnet Link:</b> <a href='{link_result}'>Click Here</a>\n<b>More Results:</b> <a href='{link_results}'>Click Here</a>", disable_web_page_preview=True)
|
||||
|
||||
await message.edit_text(
|
||||
f"<b>Title:</b> <code>{title}</code>\n<b>Category:</b> <code>{category}</code>\n<b>Language:</b> <code>{language}</code>\n<b>Size:</b> <code>{size}</code>\n<b>Genres:</b> <code>{genre}</code>\n<b>Description:</b> {description}\n<b>Magnet Link:</b> <a href='{link_result}'>Click Here</a>\n<b>More Results:</b> <a href='{link_results}'>Click Here</a>",
|
||||
disable_web_page_preview=True,
|
||||
)
|
||||
|
||||
except MediaCaptionTooLong:
|
||||
description = description[:850]
|
||||
@@ -177,18 +206,26 @@ async def tsearch(client: Client, message: Message):
|
||||
await client.send_media_group(
|
||||
chat_id,
|
||||
[
|
||||
InputMediaPhoto('coverImage.jpg', caption=f"<b>Title:</b> <code>{title}</code>\n<b>Category:</b> <code>{category}</code>\n<b>Language:</b> <code>{language}</code>\n<b>Size:</b> <code>{size}</code>\n<b>Genres:</b> <code>{genre}</code>\n<b>Description:</b> {description}\n<b>Magnet Link:</b> <a href='{link_result}'>Click Here</a>")
|
||||
])
|
||||
InputMediaPhoto(
|
||||
"coverImage.jpg",
|
||||
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Category:</b> <code>{category}</code>\n<b>Language:</b> <code>{language}</code>\n<b>Size:</b> <code>{size}</code>\n<b>Genres:</b> <code>{genre}</code>\n<b>Description:</b> {description}\n<b>Magnet Link:</b> <a href='{link_result}'>Click Here</a>",
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
except MessageTooLong:
|
||||
description = description[:150]
|
||||
await message.edit_text(f"<b>Title:</b> <code>{title}</code>\n<b>Category:</b> <code>{category}</code>\n<b>Language:</b> <code>{language}</code>\n<b>Size:</b> <code>{size}</code>\n<b>Genres:</b> <code>{genre}</code>\n<b>Description:</b> {description}\n<b>Magnet Link:</b> <a href='{link_result}'>Click Here</a>", disable_web_page_preview=True)
|
||||
await message.edit_text(
|
||||
f"<b>Title:</b> <code>{title}</code>\n<b>Category:</b> <code>{category}</code>\n<b>Language:</b> <code>{language}</code>\n<b>Size:</b> <code>{size}</code>\n<b>Genres:</b> <code>{genre}</code>\n<b>Description:</b> {description}\n<b>Magnet Link:</b> <a href='{link_result}'>Click Here</a>",
|
||||
disable_web_page_preview=True,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
await message.edit_text(format_exc(e))
|
||||
finally:
|
||||
if os.path.exists('coverImage.jpg'):
|
||||
os.remove('coverImage.jpg')
|
||||
if os.path.exists("coverImage.jpg"):
|
||||
os.remove("coverImage.jpg")
|
||||
|
||||
|
||||
@Client.on_message(filters.command("tts", prefix) & filters.me)
|
||||
async def tts(client: Client, message: Message):
|
||||
@@ -196,58 +233,65 @@ async def tts(client: Client, message: Message):
|
||||
await message.edit_text("<code>Please Wait...</code>")
|
||||
try:
|
||||
if len(message.command) > 2:
|
||||
character, prompt = message.text.split(maxsplit=2)[1:]
|
||||
if character not in characters:
|
||||
await message.edit_text(f"<b>Usage: </b><code>{prefix}tts [character]* [text/reply to text]*</code>\n <b>Available Characters:</b> <blockquote>{characters}</blockquote>")
|
||||
return
|
||||
character, prompt = message.text.split(maxsplit=2)[1:]
|
||||
if character not in characters:
|
||||
await message.edit_text(
|
||||
f"<b>Usage: </b><code>{prefix}tts [character]* [text/reply to text]*</code>\n <b>Available Characters:</b> <blockquote>{characters}</blockquote>"
|
||||
)
|
||||
return
|
||||
|
||||
elif message.reply_to_message and len(message.command) > 1:
|
||||
character = message.text.split(maxsplit=1)[1]
|
||||
if character in characters:
|
||||
prompt = message.reply_to_message.text
|
||||
else:
|
||||
await message.edit_text(f"<b>Usage: </b><code>{prefix}tts [character]* [text/reply to text]*</code>\n <b>Available Characters:</b> <blockquote>{characters}</blockquote>")
|
||||
return
|
||||
character = message.text.split(maxsplit=1)[1]
|
||||
if character in characters:
|
||||
prompt = message.reply_to_message.text
|
||||
else:
|
||||
await message.edit_text(
|
||||
f"<b>Usage: </b><code>{prefix}tts [character]* [text/reply to text]*</code>\n <b>Available Characters:</b> <blockquote>{characters}</blockquote>"
|
||||
)
|
||||
return
|
||||
|
||||
else:
|
||||
await message.edit_text(
|
||||
f"<b>Usage: </b><code>{prefix}tts [character]* [text/reply to text]*</code>\n <b>Available Characters:</b> <blockquote>{characters}</blockquote>"
|
||||
)
|
||||
return
|
||||
await message.edit_text(
|
||||
f"<b>Usage: </b><code>{prefix}tts [character]* [text/reply to text]*</code>\n <b>Available Characters:</b> <blockquote>{characters}</blockquote>"
|
||||
)
|
||||
return
|
||||
|
||||
data = {
|
||||
"text": prompt,
|
||||
"character": character
|
||||
}
|
||||
data = {"text": prompt, "character": character}
|
||||
response = requests.post(url=f"{url}/speech", headers=headers, json=data)
|
||||
if response.status_code != 200:
|
||||
await message.edit_text("Something went wrong")
|
||||
return
|
||||
|
||||
result = response.json()
|
||||
audio_data = result['audio']
|
||||
audio_data = result["audio"]
|
||||
audio_data = base64.b64decode(audio_data)
|
||||
async with aiofiles.open(f'{prompt}.mp3', mode='wb') as f:
|
||||
async with aiofiles.open(f"{prompt}.mp3", mode="wb") as f:
|
||||
await f.write(audio_data)
|
||||
|
||||
await message.delete()
|
||||
await client.send_audio(chat_id=message.chat.id, audio=f'{prompt}.mp3', caption=f"<b>Characters:</b> <code>{character}</code>\n<b>Prompt:</b> <code>{prompt}</code>")
|
||||
await client.send_audio(
|
||||
chat_id=message.chat.id,
|
||||
audio=f"{prompt}.mp3",
|
||||
caption=f"<b>Characters:</b> <code>{character}</code>\n<b>Prompt:</b> <code>{prompt}</code>",
|
||||
)
|
||||
|
||||
except KeyError:
|
||||
try:
|
||||
error = result['error']
|
||||
error = result["error"]
|
||||
await message.edit_text(error)
|
||||
except KeyError:
|
||||
await message.edit_text(f"<b>Usage: </b><code>{prefix}tts [character]* [text/reply to text]*</code>\n <b>Available Characters:</b> <blockquote>{characters}</blockquote>")
|
||||
await message.edit_text(
|
||||
f"<b>Usage: </b><code>{prefix}tts [character]* [text/reply to text]*</code>\n <b>Available Characters:</b> <blockquote>{characters}</blockquote>"
|
||||
)
|
||||
except Exception as e:
|
||||
await message.edit_text(format_exc(e))
|
||||
finally:
|
||||
if os.path.exists(f'{prompt}.mp3'):
|
||||
os.remove(f'{prompt}.mp3')
|
||||
if os.path.exists(f"{prompt}.mp3"):
|
||||
os.remove(f"{prompt}.mp3")
|
||||
|
||||
|
||||
modules_help["safone"] = {
|
||||
"app": "Search for an app on Play Store",
|
||||
"tsearch": "Search Torrent",
|
||||
"tts [character]* [text/reply to text]*": "Convert Text to Speech"
|
||||
"tts [character]* [text/reply to text]*": "Convert Text to Speech",
|
||||
}
|
||||
|
||||
@@ -25,9 +25,7 @@ from utils.scripts import format_exc, format_module_help, format_small_module_he
|
||||
@Client.on_message(filters.command(["sendmod", "sm"], prefix) & filters.me)
|
||||
async def sendmod(client: Client, message: Message):
|
||||
if len(message.command) == 1:
|
||||
await message.edit(
|
||||
"<b>Module name to send is not provided</b>"
|
||||
)
|
||||
await message.edit("<b>Module name to send is not provided</b>")
|
||||
return
|
||||
|
||||
await message.edit("<b>Dispatching...</b>")
|
||||
|
||||
@@ -47,7 +47,7 @@ async def sessions_list(client: Client, message: Message):
|
||||
f"<b>Official status:</b> <code>{'✅' if session.official_app else '❌️'}</code>\n"
|
||||
f"<b>2FA accepted:</b> <code>{'❌️️' if session.password_pending else '✅'}</code>\n"
|
||||
f"<b>Can accept calls / secret chats:</b> {'❌️️' if session.call_requests_disabled else '✅'} / {'❌️️' if session.encrypted_requests_disabled else '✅'}"
|
||||
)
|
||||
)
|
||||
answer = "<b>Active sessions at your account:</b>\n\n"
|
||||
chunk = []
|
||||
for s in formatted_sessions:
|
||||
@@ -62,9 +62,7 @@ async def sessions_list(client: Client, message: Message):
|
||||
await message.delete()
|
||||
|
||||
|
||||
@Client.on_message(
|
||||
filters.command(["sessionkiller", "sk"], prefix) & filters.me
|
||||
)
|
||||
@Client.on_message(filters.command(["sessionkiller", "sk"], prefix) & filters.me)
|
||||
async def sessionkiller(client: Client, message: Message):
|
||||
if len(message.command) == 1:
|
||||
if db.get("core.sessionkiller", "enabled", False):
|
||||
@@ -85,9 +83,7 @@ async def sessionkiller(client: Client, message: Message):
|
||||
"auths_hashes",
|
||||
[
|
||||
auth.hash
|
||||
for auth in (
|
||||
await client.invoke(GetAuthorizations())
|
||||
).authorizations
|
||||
for auth in (await client.invoke(GetAuthorizations())).authorizations
|
||||
],
|
||||
)
|
||||
|
||||
@@ -95,24 +91,18 @@ async def sessionkiller(client: Client, message: Message):
|
||||
db.set("core.sessionkiller", "enabled", False)
|
||||
await message.edit("<b>Sessionkiller disabled!</b>")
|
||||
else:
|
||||
await message.edit(
|
||||
f"<b>Usage: {prefix}sessionkiller [enable|disable]</b>"
|
||||
)
|
||||
await message.edit(f"<b>Usage: {prefix}sessionkiller [enable|disable]</b>")
|
||||
|
||||
|
||||
@Client.on_raw_update()
|
||||
async def check_new_login(
|
||||
client: Client, update: UpdateServiceNotification, _, __
|
||||
):
|
||||
if not isinstance(
|
||||
update, UpdateServiceNotification
|
||||
) or not update.type.startswith("auth"):
|
||||
async def check_new_login(client: Client, update: UpdateServiceNotification, _, __):
|
||||
if not isinstance(update, UpdateServiceNotification) or not update.type.startswith(
|
||||
"auth"
|
||||
):
|
||||
raise ContinuePropagation
|
||||
if not db.get("core.sessionkiller", "enabled", False):
|
||||
raise ContinuePropagation
|
||||
authorizations = (await client.invoke(GetAuthorizations()))[
|
||||
"authorizations"
|
||||
]
|
||||
authorizations = (await client.invoke(GetAuthorizations()))["authorizations"]
|
||||
for auth in authorizations:
|
||||
if auth.current:
|
||||
continue
|
||||
@@ -133,9 +123,9 @@ async def check_new_login(
|
||||
"this feature, I deleted the attacker's session from your account. "
|
||||
"You should change your 2FA password (if enabled), or set it.\n"
|
||||
)
|
||||
logined_time = datetime.utcfromtimestamp(
|
||||
auth.date_created
|
||||
).strftime("%d-%m-%Y %H-%M-%S UTC")
|
||||
logined_time = datetime.utcfromtimestamp(auth.date_created).strftime(
|
||||
"%d-%m-%Y %H-%M-%S UTC"
|
||||
)
|
||||
full_report = (
|
||||
"<b>!!! ACTION REQUIRED !!!</b>\n"
|
||||
+ info_text
|
||||
@@ -155,9 +145,7 @@ async def check_new_login(
|
||||
)
|
||||
# schedule sending report message so user will get notification
|
||||
schedule_date = int(time.time() + 15)
|
||||
await client.send_message(
|
||||
"me", full_report, schedule_date=schedule_date
|
||||
)
|
||||
await client.send_message("me", full_report, schedule_date=schedule_date)
|
||||
return
|
||||
|
||||
|
||||
|
||||
@@ -7,18 +7,26 @@ from pyrogram.errors import RPCError
|
||||
from utils.misc import modules_help, prefix
|
||||
from utils.scripts import edit_or_reply
|
||||
|
||||
|
||||
@Client.on_message(filters.command("sgb", prefix) & filters.me)
|
||||
async def sg(client: Client, message: Message):
|
||||
lol = await edit_or_reply(message, "`Processing please wait`", parse_mode=enums.ParseMode.MARKDOWN)
|
||||
lol = await edit_or_reply(
|
||||
message, "`Processing please wait`", parse_mode=enums.ParseMode.MARKDOWN
|
||||
)
|
||||
if message.reply_to_message and message.reply_to_message.from_user:
|
||||
user_id = message.reply_to_message.from_user.id
|
||||
else:
|
||||
await message.edit(f"<b>Usage: </b><code>{prefix}sgb [id]</code>")
|
||||
return
|
||||
try:
|
||||
await client.send_message("@SangMata_beta_bot","/start", parse_mode=enums.ParseMode.MARKDOWN)
|
||||
await client.send_message(
|
||||
"@SangMata_beta_bot", "/start", parse_mode=enums.ParseMode.MARKDOWN
|
||||
)
|
||||
except RPCError:
|
||||
await lol.edit("**Please unblock @SangMata_beta_bot and try again**", parse_mode=enums.ParseMode.MARKDOWN)
|
||||
await lol.edit(
|
||||
"**Please unblock @SangMata_beta_bot and try again**",
|
||||
parse_mode=enums.ParseMode.MARKDOWN,
|
||||
)
|
||||
return
|
||||
id = "@SangMata_beta_bot"
|
||||
chat = message.chat.id
|
||||
@@ -27,11 +35,12 @@ async def sg(client: Client, message: Message):
|
||||
async for opt in client.get_chat_history("@SangMata_beta_bot", limit=1):
|
||||
hmm = opt.text
|
||||
if hmm.startswith("Forward"):
|
||||
await lol.edit("**Unknown error occurred**", parse_mode=enums.ParseMode.MARKDOWN)
|
||||
await lol.edit(
|
||||
"**Unknown error occurred**", parse_mode=enums.ParseMode.MARKDOWN
|
||||
)
|
||||
return
|
||||
await lol.delete()
|
||||
await opt.copy(chat)
|
||||
|
||||
modules_help["sangmata"] = {
|
||||
"sgb": "reply to any user"
|
||||
}
|
||||
|
||||
modules_help["sangmata"] = {"sgb": "reply to any user"}
|
||||
|
||||
@@ -71,9 +71,7 @@ async def quote_cmd(client: Client, message: Message):
|
||||
url = "https://quotes.fl1yd.su/generate"
|
||||
params = {
|
||||
"messages": [
|
||||
await render_message(client, msg)
|
||||
for msg in messages
|
||||
if not msg.empty
|
||||
await render_message(client, msg) for msg in messages if not msg.empty
|
||||
],
|
||||
"quote_color": "#162330",
|
||||
"text_color": "#fff",
|
||||
@@ -118,9 +116,7 @@ async def fake_quote_cmd(client: Client, message: types.Message):
|
||||
if not fake_quote_text:
|
||||
return await message.edit("<b>Fake quote text is empty</b>")
|
||||
|
||||
q_message = await client.get_messages(
|
||||
message.chat.id, message.reply_to_message.id
|
||||
)
|
||||
q_message = await client.get_messages(message.chat.id, message.reply_to_message.id)
|
||||
q_message.text = fake_quote_text
|
||||
q_message.entities = None
|
||||
if no_reply:
|
||||
@@ -238,9 +234,7 @@ async def render_message(app: Client, message: types.Message) -> dict:
|
||||
author["rank"] = getattr(member, "title", "") or (
|
||||
"owner"
|
||||
if member.status == "creator"
|
||||
else "admin"
|
||||
if member.status == "administrator"
|
||||
else ""
|
||||
else "admin" if member.status == "administrator" else ""
|
||||
)
|
||||
|
||||
if from_user.photo:
|
||||
@@ -273,14 +267,10 @@ async def render_message(app: Client, message: types.Message) -> dict:
|
||||
else:
|
||||
author["id"] = message.sender_chat.id
|
||||
author["name"] = message.sender_chat.title
|
||||
author["rank"] = (
|
||||
"channel" if message.sender_chat.type == "channel" else ""
|
||||
)
|
||||
author["rank"] = "channel" if message.sender_chat.type == "channel" else ""
|
||||
|
||||
if message.sender_chat.photo:
|
||||
author["avatar"] = await get_file(
|
||||
message.sender_chat.photo.big_file_id
|
||||
)
|
||||
author["avatar"] = await get_file(message.sender_chat.photo.big_file_id)
|
||||
else:
|
||||
author["avatar"] = ""
|
||||
author["via_bot"] = message.via_bot.username if message.via_bot else ""
|
||||
@@ -323,65 +313,134 @@ def get_reply_text(reply: types.Message) -> str:
|
||||
return (
|
||||
"📷 Photo" + ("\n" + reply.caption if reply.caption else "")
|
||||
if reply.photo
|
||||
else get_reply_poll_text(reply.poll)
|
||||
if reply.poll
|
||||
else "📍 Location"
|
||||
if reply.location or reply.venue
|
||||
else "👤 Contact"
|
||||
if reply.contact
|
||||
else "🖼 GIF"
|
||||
if reply.animation
|
||||
else "🎧 Music" + get_audio_text(reply.audio)
|
||||
if reply.audio
|
||||
else "📹 Video"
|
||||
if reply.video
|
||||
else "📹 Videomessage"
|
||||
if reply.video_note
|
||||
else "🎵 Voice"
|
||||
if reply.voice
|
||||
else (reply.sticker.emoji + " " if reply.sticker.emoji else "")
|
||||
+ "Sticker"
|
||||
if reply.sticker
|
||||
else "💾 File " + reply.document.file_name
|
||||
if reply.document
|
||||
else "🎮 Game"
|
||||
if reply.game
|
||||
else "🎮 set new record"
|
||||
if reply.game_high_score
|
||||
else f"{reply.dice.emoji} - {reply.dice.value}"
|
||||
if reply.dice
|
||||
else (
|
||||
"👤 joined the group"
|
||||
if reply.new_chat_members[0].id == reply.from_user.id
|
||||
else "👤 invited %s to the group"
|
||||
% (get_full_name(reply.new_chat_members[0]))
|
||||
get_reply_poll_text(reply.poll)
|
||||
if reply.poll
|
||||
else (
|
||||
"📍 Location"
|
||||
if reply.location or reply.venue
|
||||
else (
|
||||
"👤 Contact"
|
||||
if reply.contact
|
||||
else (
|
||||
"🖼 GIF"
|
||||
if reply.animation
|
||||
else (
|
||||
"🎧 Music" + get_audio_text(reply.audio)
|
||||
if reply.audio
|
||||
else (
|
||||
"📹 Video"
|
||||
if reply.video
|
||||
else (
|
||||
"📹 Videomessage"
|
||||
if reply.video_note
|
||||
else (
|
||||
"🎵 Voice"
|
||||
if reply.voice
|
||||
else (
|
||||
(
|
||||
reply.sticker.emoji + " "
|
||||
if reply.sticker.emoji
|
||||
else ""
|
||||
)
|
||||
+ "Sticker"
|
||||
if reply.sticker
|
||||
else (
|
||||
"💾 File " + reply.document.file_name
|
||||
if reply.document
|
||||
else (
|
||||
"🎮 Game"
|
||||
if reply.game
|
||||
else (
|
||||
"🎮 set new record"
|
||||
if reply.game_high_score
|
||||
else (
|
||||
f"{reply.dice.emoji} - {reply.dice.value}"
|
||||
if reply.dice
|
||||
else (
|
||||
(
|
||||
"👤 joined the group"
|
||||
if reply.new_chat_members[
|
||||
0
|
||||
].id
|
||||
== reply.from_user.id
|
||||
else "👤 invited %s to the group"
|
||||
% (
|
||||
get_full_name(
|
||||
reply.new_chat_members[
|
||||
0
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
if reply.new_chat_members
|
||||
else (
|
||||
(
|
||||
"👤 left the group"
|
||||
if reply.left_chat_member.id
|
||||
== reply.from_user.id
|
||||
else "👤 removed %s"
|
||||
% (
|
||||
get_full_name(
|
||||
reply.left_chat_member
|
||||
)
|
||||
)
|
||||
)
|
||||
if reply.left_chat_member
|
||||
else (
|
||||
f"✏ changed group name to {reply.new_chat_title}"
|
||||
if reply.new_chat_title
|
||||
else (
|
||||
"🖼 changed group photo"
|
||||
if reply.new_chat_photo
|
||||
else (
|
||||
"🖼 removed group photo"
|
||||
if reply.delete_chat_photo
|
||||
else (
|
||||
"📍 pinned message"
|
||||
if reply.pinned_message
|
||||
else (
|
||||
"🎤 started a new video chat"
|
||||
if reply.video_chat_started
|
||||
else (
|
||||
"🎤 ended the video chat"
|
||||
if reply.video_chat_ended
|
||||
else (
|
||||
"🎤 invited participants to the video chat"
|
||||
if reply.video_chat_members_invited
|
||||
else (
|
||||
"👥 created the group"
|
||||
if reply.group_chat_created
|
||||
or reply.supergroup_chat_created
|
||||
else (
|
||||
"👥 created the channel"
|
||||
if reply.channel_chat_created
|
||||
else reply.text
|
||||
or "unsupported message"
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
if reply.new_chat_members
|
||||
else (
|
||||
"👤 left the group"
|
||||
if reply.left_chat_member.id == reply.from_user.id
|
||||
else "👤 removed %s" % (get_full_name(reply.left_chat_member))
|
||||
)
|
||||
if reply.left_chat_member
|
||||
else f"✏ changed group name to {reply.new_chat_title}"
|
||||
if reply.new_chat_title
|
||||
else "🖼 changed group photo"
|
||||
if reply.new_chat_photo
|
||||
else "🖼 removed group photo"
|
||||
if reply.delete_chat_photo
|
||||
else "📍 pinned message"
|
||||
if reply.pinned_message
|
||||
else "🎤 started a new video chat"
|
||||
if reply.video_chat_started
|
||||
else "🎤 ended the video chat"
|
||||
if reply.video_chat_ended
|
||||
else "🎤 invited participants to the video chat"
|
||||
if reply.video_chat_members_invited
|
||||
else "👥 created the group"
|
||||
if reply.group_chat_created or reply.supergroup_chat_created
|
||||
else "👥 created the channel"
|
||||
if reply.channel_chat_created
|
||||
else reply.text or "unsupported message"
|
||||
)
|
||||
|
||||
|
||||
@@ -402,9 +461,7 @@ def get_poll_text(poll: types.Poll) -> str:
|
||||
|
||||
def get_reply_poll_text(poll: types.Poll) -> str:
|
||||
if poll.is_anonymous:
|
||||
text = (
|
||||
"📊 Anonymous poll" if poll.type == "regular" else "📊 Anonymous quiz"
|
||||
)
|
||||
text = "📊 Anonymous poll" if poll.type == "regular" else "📊 Anonymous quiz"
|
||||
else:
|
||||
text = "📊 Poll" if poll.type == "regular" else "📊 Quiz"
|
||||
if poll.is_closed:
|
||||
|
||||
@@ -36,10 +36,9 @@ async def kang(client: Client, message: types.Message):
|
||||
|
||||
if len(message.command) < 2:
|
||||
await message.edit(
|
||||
"<b>No arguments provided\n"
|
||||
f"Usage: <code>{prefix}kang [pack]* [emoji]</code></b>",
|
||||
|
||||
)
|
||||
"<b>No arguments provided\n"
|
||||
f"Usage: <code>{prefix}kang [pack]* [emoji]</code></b>",
|
||||
)
|
||||
return
|
||||
|
||||
pack = message.command[1]
|
||||
@@ -49,43 +48,64 @@ async def kang(client: Client, message: types.Message):
|
||||
emoji = "✨"
|
||||
|
||||
await client.unblock_user("@stickers")
|
||||
await interact_with(await client.send_message("@stickers", "/cancel", parse_mode=enums.ParseMode.MARKDOWN))
|
||||
await interact_with(await client.send_message("@stickers", "/addsticker", parse_mode=enums.ParseMode.MARKDOWN))
|
||||
await interact_with(
|
||||
await client.send_message(
|
||||
"@stickers", "/cancel", parse_mode=enums.ParseMode.MARKDOWN
|
||||
)
|
||||
)
|
||||
await interact_with(
|
||||
await client.send_message(
|
||||
"@stickers", "/addsticker", parse_mode=enums.ParseMode.MARKDOWN
|
||||
)
|
||||
)
|
||||
|
||||
result = await interact_with(await client.send_message("@stickers", pack, parse_mode=enums.ParseMode.MARKDOWN))
|
||||
result = await interact_with(
|
||||
await client.send_message(
|
||||
"@stickers", pack, parse_mode=enums.ParseMode.MARKDOWN
|
||||
)
|
||||
)
|
||||
if ".TGS" in result.text:
|
||||
await message.edit("<b>Animated packs aren't supported</b>")
|
||||
return
|
||||
if "StickerExample.psd" not in result.text:
|
||||
await message.edit(
|
||||
"<b>Stickerpack doesn't exitst. Create it using @Stickers bot (via /newpack command)</b>",
|
||||
|
||||
)
|
||||
"<b>Stickerpack doesn't exitst. Create it using @Stickers bot (via /newpack command)</b>",
|
||||
)
|
||||
return
|
||||
|
||||
try:
|
||||
path = await message.reply_to_message.download()
|
||||
except ValueError:
|
||||
await message.edit(
|
||||
"<b>Replied message doesn't contain any downloadable media</b>",
|
||||
|
||||
)
|
||||
"<b>Replied message doesn't contain any downloadable media</b>",
|
||||
)
|
||||
return
|
||||
|
||||
resized = resize_image(path)
|
||||
if os.path.exists(path):
|
||||
os.remove(path)
|
||||
|
||||
await interact_with(await client.send_document("@stickers", resized, parse_mode=enums.ParseMode.MARKDOWN))
|
||||
response = await interact_with(await client.send_message("@stickers", emoji, parse_mode=enums.ParseMode.MARKDOWN))
|
||||
await interact_with(
|
||||
await client.send_document(
|
||||
"@stickers", resized, parse_mode=enums.ParseMode.MARKDOWN
|
||||
)
|
||||
)
|
||||
response = await interact_with(
|
||||
await client.send_message(
|
||||
"@stickers", emoji, parse_mode=enums.ParseMode.MARKDOWN
|
||||
)
|
||||
)
|
||||
if "/done" in response.text:
|
||||
# ok
|
||||
await interact_with(await client.send_message("@stickers", "/done", parse_mode=enums.ParseMode.MARKDOWN))
|
||||
await interact_with(
|
||||
await client.send_message(
|
||||
"@stickers", "/done", parse_mode=enums.ParseMode.MARKDOWN
|
||||
)
|
||||
)
|
||||
await client.delete_messages("@stickers", interact_with_to_delete)
|
||||
await message.edit(
|
||||
f"<b>Sticker added to <a href=https://t.me/addstickers/{pack}>pack</a></b>",
|
||||
|
||||
)
|
||||
f"<b>Sticker added to <a href=https://t.me/addstickers/{pack}>pack</a></b>",
|
||||
)
|
||||
else:
|
||||
await message.edit("<b>Something went wrong. Check history with @stickers</b>")
|
||||
interact_with_to_delete.clear()
|
||||
@@ -106,7 +126,9 @@ async def stick2png(client: Client, message: types.Message):
|
||||
file_io = BytesIO(content)
|
||||
file_io.name = "sticker.png"
|
||||
|
||||
await client.send_document(message.chat.id, file_io, parse_mode=enums.ParseMode.MARKDOWN)
|
||||
await client.send_document(
|
||||
message.chat.id, file_io, parse_mode=enums.ParseMode.MARKDOWN
|
||||
)
|
||||
except Exception as e:
|
||||
await message.edit(format_exc(e))
|
||||
else:
|
||||
@@ -125,7 +147,9 @@ async def resize_cmd(client: Client, message: types.Message):
|
||||
if os.path.exists(path):
|
||||
os.remove(path)
|
||||
|
||||
await client.send_document(message.chat.id, resized, parse_mode=enums.ParseMode.MARKDOWN)
|
||||
await client.send_document(
|
||||
message.chat.id, resized, parse_mode=enums.ParseMode.MARKDOWN
|
||||
)
|
||||
except Exception as e:
|
||||
await message.edit(format_exc(e))
|
||||
else:
|
||||
|
||||
@@ -52,9 +52,7 @@ async def support(_, message: Message):
|
||||
async def version(client: Client, message: Message):
|
||||
changelog = ""
|
||||
ub_version = ".".join(userbot_version.split(".")[:2])
|
||||
async for m in client.search_messages(
|
||||
"moonuserbot", query=f"{userbot_version}."
|
||||
):
|
||||
async for m in client.search_messages("moonuserbot", query=f"{userbot_version}."):
|
||||
if ub_version in m.text:
|
||||
changelog = m.message_id
|
||||
|
||||
|
||||
@@ -66,7 +66,9 @@ async def update(_, message: Message):
|
||||
|
||||
await message.edit("<b>Updating...</b>")
|
||||
try:
|
||||
subprocess.run([sys.executable, "-m", "pip", "install", "-U", "pip"], check=True)
|
||||
subprocess.run(
|
||||
[sys.executable, "-m", "pip", "install", "-U", "pip"], check=True
|
||||
)
|
||||
subprocess.run(["git", "pull"], check=True)
|
||||
subprocess.run(
|
||||
[
|
||||
@@ -78,10 +80,12 @@ async def update(_, message: Message):
|
||||
"-r",
|
||||
"requirements.txt",
|
||||
],
|
||||
check=True
|
||||
check=True,
|
||||
)
|
||||
subprocess.run(
|
||||
[sys.executable, "-m", "pip", "install", "-U", *requirements_list], check=True)
|
||||
[sys.executable, "-m", "pip", "install", "-U", *requirements_list],
|
||||
check=True,
|
||||
)
|
||||
except Exception as e:
|
||||
await message.edit(format_exc(e))
|
||||
db.remove("core.updater", "restart_info")
|
||||
|
||||
@@ -28,9 +28,7 @@ async def upl(client: Client, message: Message):
|
||||
|
||||
try:
|
||||
await message.edit("<b>Uploading Now...</b>")
|
||||
await client.send_document(
|
||||
message.chat.id, link
|
||||
)
|
||||
await client.send_document(message.chat.id, link)
|
||||
await message.delete()
|
||||
except Exception as e:
|
||||
await message.edit(format_exc(e))
|
||||
@@ -57,9 +55,7 @@ async def uplr(client: Client, message: Message):
|
||||
|
||||
try:
|
||||
await message.edit("<b>Uploading Now...</b>")
|
||||
await client.send_document(
|
||||
message.chat.id, link
|
||||
)
|
||||
await client.send_document(message.chat.id, link)
|
||||
await message.delete()
|
||||
except Exception as e:
|
||||
await message.edit(format_exc(e))
|
||||
|
||||
@@ -53,9 +53,7 @@ async def short(_, message: Message):
|
||||
elif message.reply_to_message:
|
||||
link = message.reply_to_message.text
|
||||
else:
|
||||
await message.edit(
|
||||
f"<b>Usage: </b><code>{prefix}short [url to short]</code>"
|
||||
)
|
||||
await message.edit(f"<b>Usage: </b><code>{prefix}short [url to short]</code>")
|
||||
return
|
||||
r = http.request("GET", "https://clck.ru/--?url=" + link)
|
||||
await message.edit(
|
||||
@@ -125,7 +123,7 @@ async def urldl(client: Client, message: Message):
|
||||
"".join(["▰" for _ in range(math.floor(percentage / 5))])
|
||||
+ "".join(["▱" for _ in range(20 - math.floor(percentage / 5))])
|
||||
+ f"\n<b>Progress:</b> {round(percentage, 2)}%"
|
||||
)
|
||||
)
|
||||
eta = downloader.get_eta(human=True)
|
||||
try:
|
||||
m = "<b>Trying to download...</b>\n"
|
||||
@@ -182,15 +180,11 @@ async def upload_cmd(_, message: Message):
|
||||
progress=progress, progress_args=(ms_, c_time, "`Downloading...`")
|
||||
)
|
||||
except ValueError:
|
||||
await message.edit(
|
||||
"<b>File to upload not found</b>"
|
||||
)
|
||||
await message.edit("<b>File to upload not found</b>")
|
||||
return
|
||||
|
||||
if os.path.getsize(file_name) > max_size:
|
||||
await message.edit(
|
||||
f"<b>Files longer than {max_size_mb}MB isn't supported</b>"
|
||||
)
|
||||
await message.edit(f"<b>Files longer than {max_size_mb}MB isn't supported</b>")
|
||||
if os.path.exists(file_name):
|
||||
os.remove(file_name)
|
||||
return
|
||||
@@ -211,7 +205,7 @@ async def upload_cmd(_, message: Message):
|
||||
url = response.text.replace("https://", "")
|
||||
await message.edit(
|
||||
f"<b>Your URL: {url}\nYour file will remain live for {file_age} days</b>",
|
||||
disable_web_page_preview=True
|
||||
disable_web_page_preview=True,
|
||||
)
|
||||
else:
|
||||
await message.edit(
|
||||
|
||||
@@ -108,6 +108,7 @@ async def get_full_user_inf(client: Client, message: Message):
|
||||
except Exception as e:
|
||||
await message.edit(format_exc(e))
|
||||
|
||||
|
||||
modules_help["user_info"] = {
|
||||
"inf [reply|id|username]": "Get brief information about user",
|
||||
"inffull [reply|id|username": "Get full information about user",
|
||||
|
||||
Reference in New Issue
Block a user