Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions modules/aiutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ async def upscale(c: Client, message: Message):
i = await message.edit("<code>Processing...</code>")

api_key = vca_api_key
image = open(photo_data, "rb").read()
with open(photo_data, "rb") as image_file:
image = image_file.read()
upscaled_image_data = await upscale_request(api_key, image)
with open("upscaled_image.png", "wb") as file:
file.write(upscaled_image_data)
Expand All @@ -314,7 +315,8 @@ async def whisp(message: Message):
await message.edit("<code>Processing...</code>")

api_key = vca_api_key
audio = open(audio_data, "rb").read()
with open(audio_data, "rb") as audio_file:
audio = audio_file.read()
language = "auto"
task = "transcribe"
task_result = await transcribe_audio(api_key, audio, language, task)
Expand Down
3 changes: 2 additions & 1 deletion modules/lexica.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ async def lupscale(client: Client, message: Message):
await message.edit("<b>File not found</b>")
return
try:
image = open(photo_data, 'rb').read()
with open(photo_data, 'rb') as image_file:
image = image_file.read()
upscaled_image = await UpscaleImages(image)
if message.reply_to_message:
message_id = message.reply_to_message.id
Expand Down
21 changes: 11 additions & 10 deletions utils/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,27 @@ def humanbytes(size):


async def edit_or_send_as_file(
text: str,
tex: str,
message: Message,
client: Client,
caption: str = "<code>Result!</code>",
file_name: str = "result",
):
"""Send As File If Len Of Text Exceeds Tg Limit Else Edit Message"""
if not text:
if not tex:
await message.edit("<code>Wait, What?</code>")
return
if len(text) > 1024:
if len(tex) > 1024:
await message.edit("<code>OutPut is Too Large, Sending As File!</code>")
file_names = f"{file_name}.text"
open(file_names, "w").write(text)
file_names = f"{file_name}.txt"
with open(file_names, "w") as fn:
fn.write(tex)
await client.send_document(message.chat.id, file_names, caption=caption)
await message.delete()
if os.path.exists(file_names):
os.remove(file_names)
return
return await message.edit(text)
return await message.edit(tex)


def get_text(message: Message) -> [None, str]:
Expand Down Expand Up @@ -190,13 +191,13 @@ def mediainfo(media):
return m


async def edit_or_reply(message, text):
async def edit_or_reply(message, txt):
"""Edit Message If Its From Self, Else Reply To Message"""
if not message:
return await message.edit(text)
return await message.edit(txt)
if not message.from_user:
return await message.edit(text)
return await message.edit(text)
return await message.edit(txt)
return await message.edit(txt)


def text(message: types.Message) -> str:
Expand Down