Some fixes

This commit is contained in:
yasir 2023-01-08 21:49:49 +07:00
parent 21e72da94b
commit 9001d0846b
5 changed files with 474 additions and 26 deletions

View file

@ -4,6 +4,7 @@ import os
import traceback
import asyncio
from pyrogram import filters, enums
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from misskaty import app
from misskaty.vars import COMMAND_HANDLER, SUDO
@ -23,7 +24,20 @@ __HELP__ = """
async def log_file(bot, message):
"""Send log file"""
try:
await message.reply_document("MissKatyLogs.txt", caption="Log Bot MissKatyPyro")
await message.reply_document(
"MissKatyLogs.txt",
caption="Log Bot MissKatyPyro",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{message.from_user.id}",
)
]
]
),
)
except Exception as e:
await message.reply(str(e))
@ -64,13 +78,37 @@ async def shell(_, m):
with open("shell_output.txt", "w") as file:
file.write(shell)
with open("shell_output.txt", "rb") as doc:
await m.reply_document(document=doc, file_name=doc.name)
await m.reply_document(
document=doc,
file_name=doc.name,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close", callback_data=f"close#{m.from_user.id}"
)
]
]
),
)
try:
os.remove("shell_output.txt")
except:
pass
elif len(shell) != 0:
await m.reply(shell, parse_mode=enums.ParseMode.HTML)
await m.reply(
shell,
parse_mode=enums.ParseMode.HTML,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close", callback_data=f"close#{m.from_user.id}"
)
]
]
),
)
else:
await m.reply("No Reply")
@ -119,11 +157,32 @@ async def evaluation_cmd_t(_, m):
document="MissKatyEval.txt",
caption=f"<code>{cmd[: 4096 // 4 - 1]}</code>",
disable_notification=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close", callback_data=f"close#{m.from_user.id}"
)
]
]
),
)
os.remove("MissKatyEval.txt")
await status_message.delete()
else:
await status_message.edit(final_output, parse_mode=enums.ParseMode.MARKDOWN)
await status_message.edit(
final_output,
parse_mode=enums.ParseMode.MARKDOWN,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close", callback_data=f"close#{m.from_user.id}"
)
]
]
),
)
async def aexec(code, c, m):

View file

@ -8,6 +8,7 @@
import os
from pyrogram import filters
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from misskaty import app
from misskaty.vars import COMMAND_HANDLER
@ -20,7 +21,18 @@ async def jsonify(_, message):
the_real_message = message.reply_to_message or message
try:
await message.reply_text(f"<code>{the_real_message}</code>")
await message.reply_text(
f"<code>{the_real_message}</code>",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close", callback_data=f"close#{msg.from_user.id}"
)
]
]
),
)
except Exception as e:
with open("json.text", "w+", encoding="utf8") as out_file:
out_file.write(str(the_real_message))
@ -29,5 +41,14 @@ async def jsonify(_, message):
caption=f"<code>{str(e)}</code>",
disable_notification=True,
reply_to_message_id=reply_to_id,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close", callback_data=f"close#{msg.from_user.id}"
)
]
]
),
)
os.remove("json.text")

View file

@ -159,8 +159,8 @@ async def translate(client, message):
target_lang = message.text.split(None, 2)[1]
text = message.text.split(None, 2)[2]
msg = await message.reply("Menerjemahkan...")
my_translator = GoogleTranslator(source="auto", target=target_lang)
try:
my_translator = GoogleTranslator(source="auto", target=target_lang)
result = my_translator.translate(text=text)
await msg.edit(
f"Translation using source = {my_translator.source} and target = {my_translator.target}\n\n-> {result}"
@ -289,6 +289,8 @@ async def showid(client, message):
@app.on_message(filters.command(["info"], COMMAND_HANDLER))
async def who_is(client, message):
# https://github.com/SpEcHiDe/PyroGramBot/blob/master/pyrobot/plugins/admemes/whois.py#L19
if message.sender_chat:
return await message.reply("Not supported channel..")
status_message = await message.reply_text("`Fetching user info...`")
await status_message.edit("`Processing user info...`")
from_user = None

View file

@ -14,6 +14,7 @@ from logging import getLogger
from misskaty import app, BOT_USERNAME
from pyrogram import filters
from pyrogram.errors import MessageTooLong
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from misskaty.vars import COMMAND_HANDLER
from misskaty.core.decorator.errors import capture_err
from misskaty.helper.http import http
@ -77,11 +78,35 @@ async def zonafilm(_, msg):
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
await asyncio.sleep(2)
msgs = ""
if msgs != "":
await msg.reply(head + msgs, True, disable_web_page_preview=True)
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{message.from_user.id}",
)
]
]
),
)
except Exception as e:
LOGGER.error(e)
await m.delete()
@ -127,6 +152,16 @@ async def nodrakor(_, msg):
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
await asyncio.sleep(2)
msgs = ""
@ -161,7 +196,19 @@ async def ngefilm21(_, message):
if not data:
return await msg.edit("Oops, data film tidak ditemukan.")
res = "".join(f"<b>{i['judul']}</b>\n{i['link']}\n" for i in data)
await msg.edit(f"<b>Hasil Scrap dari Ngefilm21:</b>\n{res}")
await msg.edit(
f"<b>Hasil Scrap dari Ngefilm21:</b>\n{res}",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{message.from_user.id}",
)
]
]
),
)
except Exception as e:
await msg.edit(f"ERROR: {str(e)}")
@ -194,6 +241,16 @@ async def movikucc(_, msg):
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
await asyncio.sleep(2)
msgs = ""
@ -202,6 +259,16 @@ async def movikucc(_, msg):
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
except Exception as e:
LOGGER.error(e)
@ -230,6 +297,16 @@ async def movikucc(_, msg):
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
await asyncio.sleep(2)
msgs = ""
@ -238,6 +315,16 @@ async def movikucc(_, msg):
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
except Exception as e:
LOGGER.error(e)
@ -278,6 +365,16 @@ async def savefilm21(_, msg):
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
await asyncio.sleep(2)
msgs = ""
@ -286,6 +383,16 @@ async def savefilm21(_, msg):
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
else:
html = await http.get(SITE, headers=headers)
@ -306,6 +413,16 @@ async def savefilm21(_, msg):
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
await asyncio.sleep(2)
msgs = ""
@ -314,6 +431,16 @@ async def savefilm21(_, msg):
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
except Exception as e:
await m.delete()
@ -353,11 +480,39 @@ async def melongmovie(_, msg):
for c, i in enumerate(data, start=1):
msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Quality:</b> {i['quality']}\n<b>Extract:</b> <code>/{msg.command[0]}_scrap {i['link']}</code>\n\n"
if len(head.encode("utf-8") + msgs.encode("utf-8")) >= 4000:
await msg.reply(head + msgs, True, disable_web_page_preview=True)
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
await asyncio.sleep(2)
msgs = ""
if msgs != "":
await msg.reply(head + msgs, True, disable_web_page_preview=True)
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
except Exception as e:
await m.delete()
LOGGER.error(e)
@ -384,11 +539,39 @@ async def melongmovie(_, msg):
for c, i in enumerate(data, start=1):
msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Quality:</b> {i['quality']}\n<b>Extract:</b> <code>/{msg.command[0]}_scrap {i['link']}</code>\n\n"
if len(head.encode("utf-8") + msgs.encode("utf-8")) >= 4000:
await msg.reply(head + msgs, True, disable_web_page_preview=True)
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
await asyncio.sleep(2)
msgs = ""
if msgs != "":
await msg.reply(head + msgs, True, disable_web_page_preview=True)
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
except Exception as e:
await m.delete()
LOGGER.error(e)
@ -420,11 +603,35 @@ async def pahe_scrap(_, msg):
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
await asyncio.sleep(2)
msgs = ""
if msgs != "":
await msg.reply(head + msgs, True, disable_web_page_preview=True)
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
except Exception as e:
await m.delete()
LOGGER.error(e)
@ -448,11 +655,39 @@ async def terbit21_scrap(_, msg):
for c, i in enumerate(res["result"], start=1):
msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Category:</b> <code>{i['kategori']}</code>\n💠 <b><a href='{i['dl']}'>Download</a></b>\n\n"
if len(head.encode("utf-8") + msgs.encode("utf-8")) >= 4000:
await msg.reply(head + msgs, True, disable_web_page_preview=True)
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
await asyncio.sleep(2)
msgs = ""
if msgs != "":
await msg.reply(head + msgs, True, disable_web_page_preview=True)
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
except Exception as e:
await m.delete()
LOGGER.error(e)
@ -471,11 +706,39 @@ async def terbit21_scrap(_, msg):
for c, i in enumerate(res["result"], start=1):
msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Category:</b> <code>{i['kategori']}</code>\n💠 <b><a href='{i['dl']}'>Download</a></b>\n\n"
if len(head.encode("utf-8") + msgs.encode("utf-8")) >= 4000:
await msg.reply(head + msgs, True, disable_web_page_preview=True)
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
await asyncio.sleep(2)
msgs = ""
if msgs != "":
await msg.reply(head + msgs, True, disable_web_page_preview=True)
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
except Exception as e:
await m.delete()
LOGGER.error(e)
@ -502,11 +765,39 @@ async def lk21_scrap(_, msg):
for c, i in enumerate(res["result"], start=1):
msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Category:</b> <code>{i['kategori']}</code>\n💠 <b><a href='{i['dl']}'>Download</a></b>\n\n"
if len(head.encode("utf-8") + msgs.encode("utf-8")) >= 4000:
await msg.reply(head + msgs, True, disable_web_page_preview=True)
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
await asyncio.sleep(2)
msgs = ""
if msgs != "":
await msg.reply(head + msgs, True, disable_web_page_preview=True)
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
except Exception as e:
await m.delete()
LOGGER.error(e)
@ -528,11 +819,39 @@ async def lk21_scrap(_, msg):
for c, i in enumerate(res["result"], start=1):
msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Category:</b> <code>{i['kategori']}</code>\n💠 <b><a href='{i['dl']}'>Download</a></b>\n\n"
if len(head.encode("utf-8") + msgs.encode("utf-8")) >= 4000:
await msg.reply(head + msgs, True, disable_web_page_preview=True)
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
await asyncio.sleep(2)
msgs = ""
if msgs != "":
await msg.reply(head + msgs, True, disable_web_page_preview=True)
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
except Exception as e:
await m.delete()
LOGGER.error(e)
@ -578,11 +897,35 @@ async def gomov_scrap(_, msg):
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
await asyncio.sleep(2)
msgs = ""
if msgs != "":
await msg.reply(head + msgs, True, disable_web_page_preview=True)
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{msg.from_user.id}",
)
]
]
),
)
except Exception as e:
LOGGER.error(e)
await m.delete()
@ -603,7 +946,18 @@ async def savefilm21_scrap(_, message):
res = soup.find_all(class_="button button-shadow")
res = "".join(f"{i.text}\n{i['href']}\n\n" for i in res)
await message.reply(
f"<b>Hasil Scrap dari {link}</b>:\n\n{res}", disable_web_page_preview=True
f"<b>Hasil Scrap dari {link}</b>:\n\n{res}",
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{message.from_user.id}",
)
]
]
),
)
except IndexError:
return await message.reply(
@ -705,7 +1059,19 @@ async def gomov_zonafilm_dl(_, message):
title = i.find("a").text
link = i.find("a")["href"]
hasil += f"\n{title}\n{link}\n"
await message.reply(hasil)
await message.reply(
hasil,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="❌ Close",
callback_data=f"close#{message.from_user.id}",
)
]
]
),
)
except IndexError:
await message.reply(
f"Gunakan command /{message.command[0]} <b>[link]</b> untuk scrap link download"

View file

@ -85,7 +85,7 @@ async def ceksub(_, m):
)
end_time = perf_counter()
timelog = "{:.2f}".format(end_time - start_time) + " second"
buttons.append([InlineKeyboardButton("Cancel", "cancel")])
buttons.append([InlineKeyboardButton("❌ Cancel", f"close#{m.from_user.id}")])
await pesan.edit(
f"Press the button below to extract subtitles/audio. Only support direct link at this time.\nProcessed in {timelog}",
reply_markup=InlineKeyboardMarkup(buttons),
@ -177,4 +177,4 @@ async def stream_extract(bot, update):
except:
pass
except Exception as e:
await update.message.edit(f"Failed extract sub. \n\nERROR: {e}")
await update.message.edit("Failed extract sub, Maybe unsupported format..")