black
This commit is contained in:
5
app.py
5
app.py
@@ -1,10 +1,11 @@
|
||||
from flask import Flask
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
@app.route('/')
|
||||
@app.route("/")
|
||||
def hello_world():
|
||||
return 'This is Moon'
|
||||
return "This is Moon"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -63,7 +63,7 @@ if __name__ == "__main__":
|
||||
"Custom modules: @moonub_modules\n"
|
||||
"Chat: @moonub_chat\n"
|
||||
f"For restart, enter:</b>\n"
|
||||
f"<code>{restart}</code>"
|
||||
f"<code>{restart}</code>",
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"[ERROR]: Sending Message to me failed! {e}")
|
||||
|
||||
@@ -108,7 +108,9 @@ async def vdxl(c: Client, message: Message):
|
||||
prompt = message.reply_to_message.caption[len(f"{m}") :].strip()
|
||||
image_path = await message.reply_to_message.download()
|
||||
with open(image_path, "rb") as image_file:
|
||||
image_data = base64.b64encode(image_file.read()).decode("utf-8")
|
||||
image_data = base64.b64encode(image_file.read()).decode(
|
||||
"utf-8"
|
||||
)
|
||||
img2img = True
|
||||
model_found = True
|
||||
break
|
||||
@@ -181,9 +183,13 @@ async def vdxl(c: Client, message: Message):
|
||||
try:
|
||||
details = response["detail"]
|
||||
mes = response["message"]
|
||||
return await message.edit_text(f"<b>{details}: </b><code>{mes}</code>")
|
||||
return await message.edit_text(
|
||||
f"<b>{details}: </b><code>{mes}</code>"
|
||||
)
|
||||
except KeyError:
|
||||
return await message.edit_text("An Error Occurred, please try again later")
|
||||
return await message.edit_text(
|
||||
"An Error Occurred, please try again later"
|
||||
)
|
||||
|
||||
except MessageTooLong:
|
||||
await message.edit_text(
|
||||
@@ -240,7 +246,9 @@ async def vdxl2(c: Client, message: Message):
|
||||
prompt = message.reply_to_message.caption[len(f"{m}") :].strip()
|
||||
image_path = await message.reply_to_message.download()
|
||||
with open(image_path, "rb") as image_file:
|
||||
image_data = base64.b64encode(image_file.read()).decode("utf-8")
|
||||
image_data = base64.b64encode(image_file.read()).decode(
|
||||
"utf-8"
|
||||
)
|
||||
img2img = True
|
||||
model_found = True
|
||||
break
|
||||
@@ -313,9 +321,13 @@ async def vdxl2(c: Client, message: Message):
|
||||
try:
|
||||
details = response["detail"]
|
||||
mes = response["message"]
|
||||
return await message.edit_text(f"<b>{details}: </b><code>{mes}</code>")
|
||||
return await message.edit_text(
|
||||
f"<b>{details}: </b><code>{mes}</code>"
|
||||
)
|
||||
except KeyError:
|
||||
return await message.edit_text("An Error Occurred, please try again later")
|
||||
return await message.edit_text(
|
||||
"An Error Occurred, please try again later"
|
||||
)
|
||||
|
||||
except MessageTooLong:
|
||||
await message.edit_text(
|
||||
@@ -372,7 +384,9 @@ async def vdxl3(c: Client, message: Message):
|
||||
prompt = message.reply_to_message.caption[len(f"{m}") :].strip()
|
||||
image_path = await message.reply_to_message.download()
|
||||
with open(image_path, "rb") as image_file:
|
||||
image_data = base64.b64encode(image_file.read()).decode("utf-8")
|
||||
image_data = base64.b64encode(image_file.read()).decode(
|
||||
"utf-8"
|
||||
)
|
||||
img2img = True
|
||||
model_found = True
|
||||
break
|
||||
@@ -445,9 +459,13 @@ async def vdxl3(c: Client, message: Message):
|
||||
try:
|
||||
details = response["detail"]
|
||||
mes = response["message"]
|
||||
return await message.edit_text(f"<b>{details}: </b><code>{mes}</code>")
|
||||
return await message.edit_text(
|
||||
f"<b>{details}: </b><code>{mes}</code>"
|
||||
)
|
||||
except KeyError:
|
||||
return await message.edit_text("An Error Occurred, please try again later")
|
||||
return await message.edit_text(
|
||||
"An Error Occurred, please try again later"
|
||||
)
|
||||
|
||||
except MessageTooLong:
|
||||
await message.edit_text(
|
||||
@@ -504,7 +522,9 @@ async def vfxl(c: Client, message: Message):
|
||||
prompt = message.reply_to_message.caption[len(f"{m}") :].strip()
|
||||
image_path = await message.reply_to_message.download()
|
||||
with open(image_path, "rb") as image_file:
|
||||
image_data = base64.b64encode(image_file.read()).decode("utf-8")
|
||||
image_data = base64.b64encode(image_file.read()).decode(
|
||||
"utf-8"
|
||||
)
|
||||
img2img = True
|
||||
model_found = True
|
||||
break
|
||||
@@ -581,9 +601,13 @@ async def vfxl(c: Client, message: Message):
|
||||
try:
|
||||
details = response["detail"]
|
||||
mes = response["message"]
|
||||
return await message.edit_text(f"<b>{details}: </b><code>{mes}</code>")
|
||||
return await message.edit_text(
|
||||
f"<b>{details}: </b><code>{mes}</code>"
|
||||
)
|
||||
except KeyError:
|
||||
return await message.edit_text("An Error Occurred, please try again later")
|
||||
return await message.edit_text(
|
||||
"An Error Occurred, please try again later"
|
||||
)
|
||||
|
||||
except MessageTooLong:
|
||||
await message.edit_text(
|
||||
@@ -640,7 +664,9 @@ async def vpxl(c: Client, message: Message):
|
||||
prompt = message.reply_to_message.caption[len(f"{m}") :].strip()
|
||||
image_path = await message.reply_to_message.download()
|
||||
with open(image_path, "rb") as image_file:
|
||||
image_data = base64.b64encode(image_file.read()).decode("utf-8")
|
||||
image_data = base64.b64encode(image_file.read()).decode(
|
||||
"utf-8"
|
||||
)
|
||||
img2img = True
|
||||
model_found = True
|
||||
break
|
||||
@@ -717,9 +743,13 @@ async def vpxl(c: Client, message: Message):
|
||||
try:
|
||||
details = response["detail"]
|
||||
mes = response["message"]
|
||||
return await message.edit_text(f"<b>{details}: </b><code>{mes}</code>")
|
||||
return await message.edit_text(
|
||||
f"<b>{details}: </b><code>{mes}</code>"
|
||||
)
|
||||
except KeyError:
|
||||
return await message.edit_text("An Error Occurred, please try again later")
|
||||
return await message.edit_text(
|
||||
"An Error Occurred, please try again later"
|
||||
)
|
||||
|
||||
except MessageTooLong:
|
||||
await message.edit_text(
|
||||
@@ -776,7 +806,9 @@ async def vpixl(c: Client, message: Message):
|
||||
prompt = message.reply_to_message.caption[len(f"{m}") :].strip()
|
||||
image_path = await message.reply_to_message.download()
|
||||
with open(image_path, "rb") as image_file:
|
||||
image_data = base64.b64encode(image_file.read()).decode("utf-8")
|
||||
image_data = base64.b64encode(image_file.read()).decode(
|
||||
"utf-8"
|
||||
)
|
||||
img2img = True
|
||||
model_found = True
|
||||
break
|
||||
@@ -912,7 +944,9 @@ async def vkxl(c: Client, message: Message):
|
||||
prompt = message.reply_to_message.caption[len(f"{m}") :].strip()
|
||||
image_path = await message.reply_to_message.download()
|
||||
with open(image_path, "rb") as image_file:
|
||||
image_data = base64.b64encode(image_file.read()).decode("utf-8")
|
||||
image_data = base64.b64encode(image_file.read()).decode(
|
||||
"utf-8"
|
||||
)
|
||||
img2img = True
|
||||
model_found = True
|
||||
break
|
||||
@@ -985,9 +1019,13 @@ async def vkxl(c: Client, message: Message):
|
||||
try:
|
||||
details = response["detail"]
|
||||
mes = response["message"]
|
||||
return await message.edit_text(f"<b>{details}: </b><code>{mes}</code>")
|
||||
return await message.edit_text(
|
||||
f"<b>{details}: </b><code>{mes}</code>"
|
||||
)
|
||||
except KeyError:
|
||||
return await message.edit_text("An Error Occurred, please try again later")
|
||||
return await message.edit_text(
|
||||
"An Error Occurred, please try again later"
|
||||
)
|
||||
|
||||
except MessageTooLong:
|
||||
await message.edit_text(
|
||||
|
||||
@@ -20,6 +20,7 @@ from utils.scripts import format_module_help, with_reply
|
||||
current_page = 0
|
||||
total_pages = 0
|
||||
|
||||
|
||||
async def send_page(message, module_list, page, total_pages):
|
||||
start_index = (page - 1) * 10
|
||||
end_index = start_index + 10
|
||||
@@ -63,6 +64,7 @@ async def help_cmd(_, message: Message):
|
||||
if not module_found:
|
||||
await message.edit(f"<b>Module or command {command_name} not found</b>")
|
||||
|
||||
|
||||
@Client.on_message(filters.command(["pn", "pp", "pq"], prefix) & filters.me)
|
||||
@with_reply
|
||||
async def handle_navigation(_, message: Message):
|
||||
@@ -71,14 +73,18 @@ async def handle_navigation(_, message: Message):
|
||||
if message.command[0].lower() == "pn":
|
||||
if current_page < total_pages:
|
||||
current_page += 1
|
||||
await send_page(message, list(modules_help.keys()), current_page, total_pages)
|
||||
await send_page(
|
||||
message, list(modules_help.keys()), current_page, total_pages
|
||||
)
|
||||
return await message.reply_to_message.delete()
|
||||
else:
|
||||
await message.edit("No more pages available.")
|
||||
elif message.command[0].lower() == "pp":
|
||||
if current_page > 1:
|
||||
current_page -= 1
|
||||
await send_page(message, list(modules_help.keys()), current_page, total_pages)
|
||||
await send_page(
|
||||
message, list(modules_help.keys()), current_page, total_pages
|
||||
)
|
||||
return await message.reply_to_message.delete()
|
||||
else:
|
||||
return await message.edit("This is the first page.")
|
||||
|
||||
@@ -146,7 +146,10 @@ async def unload_mods(_, message: Message):
|
||||
if os.path.exists(f"{BASE_PATH}/modules/custom_modules/{module_name}.py"):
|
||||
os.remove(f"{BASE_PATH}/modules/custom_modules/{module_name}.py")
|
||||
if module_name == "musicbot":
|
||||
subprocess.run([sys.executable, "-m", "pip", "uninstall", "-y", "requirements.txt"], cwd=f"{BASE_PATH}/musicbot")
|
||||
subprocess.run(
|
||||
[sys.executable, "-m", "pip", "uninstall", "-y", "requirements.txt"],
|
||||
cwd=f"{BASE_PATH}/musicbot",
|
||||
)
|
||||
shutil.rmtree(f"{BASE_PATH}/musicbot")
|
||||
await message.edit(f"<b>The module <code>{module_name}</code> removed!</b>")
|
||||
restart()
|
||||
|
||||
@@ -67,7 +67,6 @@ def check_extension(file_path):
|
||||
return extensions.get(ext, "<pre>")
|
||||
|
||||
|
||||
|
||||
@Client.on_message(filters.command("open", prefix) & filters.me)
|
||||
async def openfile(client: Client, message: Message):
|
||||
if not message.reply_to_message:
|
||||
|
||||
@@ -73,7 +73,7 @@ async def update(_, message: Message):
|
||||
|
||||
await message.edit("<b>Updating...</b>")
|
||||
try:
|
||||
if not check_command('termux-setup-storage'):
|
||||
if not check_command("termux-setup-storage"):
|
||||
subprocess.run(
|
||||
[sys.executable, "-m", "pip", "install", "-U", "pip"], check=True
|
||||
)
|
||||
|
||||
@@ -56,9 +56,7 @@ async def dlf(client: Client, message: Message):
|
||||
await client.download_media(message.reply_to_message)
|
||||
await message.edit("<b>Downloaded Successfully!</b>")
|
||||
else:
|
||||
await message.edit(
|
||||
f"<b>Usage: </b><code>{prefix}dlf [reply to a file]</code>"
|
||||
)
|
||||
await message.edit(f"<b>Usage: </b><code>{prefix}dlf [reply to a file]</code>")
|
||||
|
||||
|
||||
@Client.on_message(filters.command("moonlogs", prefix) & filters.me)
|
||||
@@ -69,9 +67,7 @@ async def mupl(client: Client, message: Message):
|
||||
await message.edit("<b>Uploading Now...</b>")
|
||||
await client.send_document(message.chat.id, link)
|
||||
await message.delete()
|
||||
return await message.edit(
|
||||
"<b>Error: </b><code>LOGS</code> file doesn't exist."
|
||||
)
|
||||
return await message.edit("<b>Error: </b><code>LOGS</code> file doesn't exist.")
|
||||
except Exception as e:
|
||||
await message.edit(format_exc(e))
|
||||
|
||||
@@ -110,5 +106,5 @@ modules_help["uplud"] = {
|
||||
"upl [filepath]/[reply to path]*": "Upload a file from your local machine to Telegram",
|
||||
"dlf": "Download a file from Telegram to your local machine",
|
||||
"uplr [filepath]/[reply to path]*": "Upload a file from your local machine to Telegram, delete the file after uploading",
|
||||
"moonlogs": "Upload the moonlogs.txt file to Telegram"
|
||||
"moonlogs": "Upload the moonlogs.txt file to Telegram",
|
||||
}
|
||||
|
||||
@@ -28,4 +28,6 @@ cohere_key = os.getenv("COHERE_KEY", env.str("COHERE_KEY", ""))
|
||||
pm_limit = int(os.getenv("PM_LIMIT", env.int("PM_LIMIT", 4)))
|
||||
|
||||
test_server = bool(os.getenv("TEST_SERVER", env.bool("TEST_SERVER", False)))
|
||||
modules_repo_branch = os.getenv("MODULES_REPO_BRANCH", env.str("MODULES_REPO_BRANCH", "master"))
|
||||
modules_repo_branch = os.getenv(
|
||||
"MODULES_REPO_BRANCH", env.str("MODULES_REPO_BRANCH", "master")
|
||||
)
|
||||
|
||||
@@ -908,10 +908,7 @@ class PromoteHandler:
|
||||
user_id,
|
||||
privileges=ChatPrivileges(**self.common_privileges_promote),
|
||||
)
|
||||
if (
|
||||
len(self.cause.split()) > 1
|
||||
and self.message.chat.type == "group"
|
||||
):
|
||||
if len(self.cause.split()) > 1 and self.message.chat.type == "group":
|
||||
await self.client.set_administrator_title(
|
||||
self.chat_id,
|
||||
user_id,
|
||||
|
||||
@@ -5,11 +5,11 @@ from lexica import AsyncClient, Client
|
||||
|
||||
|
||||
def ImageModels():
|
||||
models = Client().models['models']['image']
|
||||
models = Client().models["models"]["image"]
|
||||
dict_models = {}
|
||||
for model in models:
|
||||
model_id = model['id']
|
||||
model_name = model['name']
|
||||
model_id = model["id"]
|
||||
model_name = model["name"]
|
||||
dict_models[model_name] = model_id
|
||||
return dict_models
|
||||
|
||||
@@ -17,18 +17,18 @@ def ImageModels():
|
||||
async def ImageGeneration(model, prompt):
|
||||
try:
|
||||
output = await AsyncClient().generate(model, prompt, "")
|
||||
if output['code'] != 1:
|
||||
if output["code"] != 1:
|
||||
return 2
|
||||
if output['code'] == 69:
|
||||
return output['code']
|
||||
task_id, request_id = output['task_id'], output['request_id']
|
||||
if output["code"] == 69:
|
||||
return output["code"]
|
||||
task_id, request_id = output["task_id"], output["request_id"]
|
||||
await asyncio.sleep(20)
|
||||
tries = 0
|
||||
image_url = None
|
||||
resp = await AsyncClient().getImages(task_id, request_id)
|
||||
while True:
|
||||
if resp['code'] == 2:
|
||||
image_url = resp['img_urls']
|
||||
if resp["code"] == 2:
|
||||
image_url = resp["img_urls"]
|
||||
break
|
||||
if tries > 15:
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user