diff --git a/misskaty/helper/media_helper.py b/misskaty/helper/media_helper.py index 9aeb61be..25926ed9 100644 --- a/misskaty/helper/media_helper.py +++ b/misskaty/helper/media_helper.py @@ -5,14 +5,12 @@ from typing import Tuple from misskaty import BOT_USERNAME from telegraph.aio import Telegraph -from utils import LOGGER async def post_to_telegraph(is_media: bool, title=None, content=None, media=None): telegraph = Telegraph() if telegraph.get_access_token() is None: await telegraph.create_account(short_name=BOT_USERNAME) - LOGGER.info("Create TGH Account ..") if is_media: """Create a Telegram Post Foto/Video""" response = await telegraph.upload_file(media) diff --git a/misskaty/helper/pyro_progress.py b/misskaty/helper/pyro_progress.py index 117f93cf..86f755e6 100644 --- a/misskaty/helper/pyro_progress.py +++ b/misskaty/helper/pyro_progress.py @@ -6,7 +6,7 @@ import asyncio import math import time -from pyrogram.errors import FloodWait, MessageNotModified +from pyrogram.errors import FloodWait, MessageNotModified, MessageIdInvalid async def progress_for_pyrogram(current, total, ud_type, message, start): @@ -43,7 +43,7 @@ async def progress_for_pyrogram(current, total, ud_type, message, start): except FloodWait as e: await asyncio.sleep(e.value) await message.edit(f"{ud_type}\n {tmp}") - except MessageNotModified: + except (MessageNotModified, MessageIdInvalid): pass diff --git a/misskaty/plugins/dev.py b/misskaty/plugins/dev.py index 9e564790..6991e54e 100644 --- a/misskaty/plugins/dev.py +++ b/misskaty/plugins/dev.py @@ -139,13 +139,13 @@ async def shell(_, m): await m.reply("No Reply") -@app.on_message(filters.command(["ev", "run"], COMMAND_HANDLER) & filters.user(SUDO)) -@app.on_edited_message(filters.command(["ev", "run"]) & filters.user(SUDO)) +@app.on_message((filters.command(["ev", "run"], COMMAND_HANDLER) | filters.regex(r"app.run\(\)$")) & filters.user(SUDO)) +@app.on_edited_message((filters.command(["ev", "run"]) | filters.regex(r"app.run\(\)$")) & filters.user(SUDO)) @user.on_message(filters.command(["ev", "run"], ".") & filters.me) async def evaluation_cmd_t(_, m): - cmd = m.text.split(" ", 1) - if len(m.command) == 1: + if len(m.command) == 1 and m.command: return await edit_or_reply(m, text="__No evaluate message!__") + cmd = m.text.split(" ", 1)[1] if m.command else m.text.split("app.run()")[0] status_message = await editPesan(m, "Processing eval pyrogram..") if m.from_user.is_self else await kirimPesan(m, "Processing eval pyrogram..") old_stderr = sys.stderr @@ -155,7 +155,7 @@ async def evaluation_cmd_t(_, m): stdout, stderr, exc = None, None, None try: - await aexec(cmd[1], _, m) + await aexec(cmd, _, m) except Exception: exc = traceback.format_exc() @@ -174,7 +174,7 @@ async def evaluation_cmd_t(_, m): else: evaluation = "Success" - final_output = f"**EVAL**:\n`{cmd[1]}`\n\n**OUTPUT**:\n`{evaluation.strip()}`\n" + final_output = f"**EVAL**:\n`{cmd}`\n\n**OUTPUT**:\n`{evaluation.strip()}`\n" if len(final_output) > 4096: with open("MissKatyEval.txt", "w+", encoding="utf8") as out_file: diff --git a/misskaty/plugins/grup_tools.py b/misskaty/plugins/grup_tools.py index 4d243919..0301c8ef 100644 --- a/misskaty/plugins/grup_tools.py +++ b/misskaty/plugins/grup_tools.py @@ -69,7 +69,7 @@ def welcomepic(pic, user, chat, count, id): return f"downloads/welcome#{id}.png" -@app.on_chat_member_updated(filters.group & filters.chat(-1001128045651)) +@app.on_chat_member_updated(filters.group & filters.chat([-1001128045651, -1001777794636])) async def member_has_joined(c: app, member: ChatMemberUpdated): if not member.new_chat_member or member.new_chat_member.status in {"banned", "left", "restricted"} or member.old_chat_member: return @@ -105,8 +105,8 @@ async def member_has_joined(c: app, member: ChatMemberUpdated): photo=welcomeimg, caption=f"Hai {mention}, Selamat datang digrup {member.chat.title} harap baca rules di pinned message terlebih dahulu.\n\nNama : {first_name}\nID : {id}\nDC ID : {dc}\nTanggal Join : {joined_date}", ) - except: - pass + except Exception as e: + LOGGER.info(e) userspammer = "" # Spamwatch Detection try: diff --git a/misskaty/plugins/mediainfo.py b/misskaty/plugins/mediainfo.py index 8167ee2f..4badc5fe 100644 --- a/misskaty/plugins/mediainfo.py +++ b/misskaty/plugins/mediainfo.py @@ -57,6 +57,7 @@ DETAILS except: try: link = await post_to_telegraph(False, "MissKaty MediaInfo", body_text) + markup = InlineKeyboardMarkup([[InlineKeyboardButton(text="💬 View in Web", url=link)]]) except: markup = None with io.BytesIO(str.encode(body_text)) as out_file: diff --git a/misskaty/plugins/misc_tools.py b/misskaty/plugins/misc_tools.py index e989b487..e4fdb06e 100644 --- a/misskaty/plugins/misc_tools.py +++ b/misskaty/plugins/misc_tools.py @@ -27,7 +27,7 @@ from pyrogram.types import CallbackQuery, InlineKeyboardButton, InlineKeyboardMa from misskaty import BOT_USERNAME, app from misskaty.core.decorator.errors import capture_err from misskaty.core.decorator.ratelimiter import ratelimiter -from misskaty.core.message_utils import hapusPesan, kirimPesan +from misskaty.core.message_utils import editPesan, hapusPesan, kirimPesan from misskaty.helper.http import http from misskaty.helper.tools import rentry from misskaty.vars import COMMAND_HANDLER @@ -58,7 +58,7 @@ def remove_html_tags(text): @app.on_message(filters.command("readqr", COMMAND_HANDLER)) @ratelimiter async def readqr(c, m): - if not m.reply and not m.reply.media and not m.reply.photo: + if not m.reply and (not m.reply.media and not m.reply.photo): return await m.reply("Please reply photo that contain valid QR Code.") foto = await m.reply_to_message.download() myfile = {'file': (foto, open(foto, 'rb'),'application/octet-stream')} @@ -171,12 +171,12 @@ async def translate(client, message): 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}") + await editPesan(msg, f"Translation using source = {my_translator.source} and target = {my_translator.target}\n\n-> {result}") except MessageTooLong: url = await rentry(result) - await msg.edit(f"Your translated text pasted to rentry because has long text:\n{url}") + await editPesan(msg, f"Your translated text pasted to rentry because has long text:\n{url}") except Exception as err: - await msg.edit(f"Error: {str(err)}") + await editPesan(msg, f"Oppss, Error: {str(err)}") @app.on_message(filters.command(["tts"], COMMAND_HANDLER)) diff --git a/misskaty/plugins/ytdl_download_new.py b/misskaty/plugins/ytdl_download_new.py index ff5cf869..6f1e691d 100644 --- a/misskaty/plugins/ytdl_download_new.py +++ b/misskaty/plugins/ytdl_download_new.py @@ -78,7 +78,7 @@ async def ytdownv2(_, message): markup = x.buttons await message.reply_photo(img, caption=caption, reply_markup=markup, quote=True) except Exception as err: - await kirimPesan(message, str(err)) + await kirimPesan(message, f"Opps, ERROR: {str(err)}") @app.on_callback_query(filters.regex(r"^yt_listall")) @@ -139,8 +139,11 @@ async def ytdl_gendl_callback(_, cq: CallbackQuery): ffmpeg_location="/usr/bin/mediaextract", delete_media=True, ) as ytdl: - upload_key = await ytdl.download(cq.message.reply_to_message.command[1], uid, format_, cq, True, 3) - await ytdl.upload(app, upload_key[0], format_, cq, True) + try: + upload_key = await ytdl.download(cq.message.reply_to_message.command[1], uid, format_, cq, True, 3) + await ytdl.upload(app, upload_key[0], format_, cq, True) + except Exception as err: + await cq.edit_message_caption(err) else: uid = callback[2] type_ = callback[3] @@ -151,15 +154,18 @@ async def ytdl_gendl_callback(_, cq: CallbackQuery): ffmpeg_location="/usr/bin/mediaextract", delete_media=True, ) as ytdl: - upload_key = await ytdl.download( - f"https://www.youtube.com/watch?v={key}", - uid, - format_, - cq, - True, - 3, - ) - await ytdl.upload(app, upload_key[0], format_, cq, True) + try: + upload_key = await ytdl.download( + f"https://www.youtube.com/watch?v={key}", + uid, + format_, + cq, + True, + 3, + ) + await ytdl.upload(app, upload_key[0], format_, cq, True) + except Exception as err: + await cq.edit_message_caption(err) @app.on_callback_query(filters.regex(r"^ytdl_scroll"))