From e2aba35a7c7e6320f892852f5437d4212015207f Mon Sep 17 00:00:00 2001 From: Abhi Date: Fri, 31 May 2024 20:52:47 +0530 Subject: [PATCH] rename lupscale & add `asq` and `gemini` from safone and upscale as visioncraft removed it --- modules/lexica.py | 7 ++++--- modules/safone.py | 49 ++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/modules/lexica.py b/modules/lexica.py index 57d1959..9e03e82 100644 --- a/modules/lexica.py +++ b/modules/lexica.py @@ -9,8 +9,8 @@ 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): +@Client.on_message(filters.command("upscale", prefix) & filters.me) +async def upscale(client: Client, message: Message): """Upscale Image Using Lexica API""" await message.edit("Processing...") @@ -84,6 +84,7 @@ async def lgen(client: Client, message: Message): with open("generated_image.png", "wb") as f: f.write(requests.get(img_url, timeout=5).content) + await message.delete() await client.send_document( message.chat.id, "generated_image.png", @@ -97,5 +98,5 @@ async def lgen(client: Client, message: Message): 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", + "upscale [cap/reply to image]*": "Upscale Image through Lexica API", } diff --git a/modules/safone.py b/modules/safone.py index 966e877..f68250f 100644 --- a/modules/safone.py +++ b/modules/safone.py @@ -3,7 +3,7 @@ import requests import aiofiles import base64 -from pyrogram import Client, filters +from pyrogram import Client, enums, filters from pyrogram.types import Message, InputMediaPhoto from pyrogram.errors import MediaCaptionTooLong, MessageTooLong @@ -53,6 +53,48 @@ async def voice_characters(): return ", ".join(result["characters"]) +@Client.on_message(filters.command("asq", prefix) & filters.me) +async def asq(_, message: Message): + if len(message.command) > 1: + query = message.text.split(maxsplit=1)[1] + else: + await message.edit_text("Query not provided!") + return + await message.edit_text("Processing...") + response = requests.get(url=f"{url}/asq?query={query}", headers=headers, timeout=5) + if response.status_code != 200: + await message.edit_text("Something went wrong!") + return + + result = response.json() + + ans = result["answer"] + await message.edit_text( + f"Q. {query}\n A. {ans}", parse_mode=enums.ParseMode.MARKDOWN + ) + + +@Client.on_message(filters.command("sgemini", prefix) & filters.me) +async def sgemini(_, message: Message): + if len(message.command) > 1: + prompt = message.text.split(maxsplit=1)[1] + else: + await message.edit_text("prompt not provided!") + return + await message.edit_text("Processing...") + response = requests.get(url=f"{url}/bard?query={prompt}", headers=headers) + if response.status_code != 200: + await message.edit_text("Something went wrong!") + return + + result = response.json() + + ans = result["message"] + await message.edit_text( + f"Prompt: {prompt}\n Ans: {ans}", parse_mode=enums.ParseMode.MARKDOWN + ) + + @Client.on_message(filters.command("app", prefix) & filters.me) async def app(client: Client, message: Message): try: @@ -291,7 +333,8 @@ async def tts(client: Client, message: Message): modules_help["safone"] = { - "app": "Search for an app on Play Store", - "tsearch": "Search Torrent", + "asq [query]*": "Asq" + "app [query]*": "Search for an app on Play Store", + "tsearch [query]*": "Search Torrent", "tts [character]* [text/reply to text]*": "Convert Text to Speech", }