Updated to latest layer

Fix split msg using latest layer
Fix donate cmd
Add blockquote in imdb and some text
Minor fix ytdl
And other fix..

Signed-off-by: Yasir Aris M <git@yasirdev.my.id>
This commit is contained in:
Yasir Aris M 2023-11-01 23:30:47 +07:00
parent 930a53e4d1
commit f2f6f240eb
8 changed files with 56 additions and 25 deletions

View file

@ -42,7 +42,7 @@ MOD_NOLOAD = ["subscene_dl"]
HELPABLE = {}
cleanmode = {}
botStartTime = time.time()
misskaty_version = "v2.11.4 - Stable"
misskaty_version = "v2.12.1 - Stable"
uvloop.install()
faulthandler_enable()

View file

@ -85,14 +85,13 @@ if __name__ == "__main__":
try:
get_event_loop().run_until_complete(start_bot())
app.loop.run_forever()
# loop.run_until_complete(start_bot())
except KeyboardInterrupt:
pass
except Exception:
err = traceback.format_exc()
LOGGER.info(err)
finally:
loop.stop()
app.loop.stop()
LOGGER.info(
"------------------------ Stopped Services ------------------------"
)

View file

@ -21,11 +21,12 @@ from pyrogram.types import Message
LOGGER = getLogger("MissKaty")
Message.input = property(
lambda m: m.text[m.text.find(m.command[0]) + len(m.command[0]) + 1 :]
if len(m.command) > 1
else None
)
@property
def parse_cmd(m):
msg = m.caption if m.web_page_preview else m.text
if len(m.command) > 1:
return msg.split(None, 1)[1]
return None
async def reply_text(
@ -323,3 +324,4 @@ Message.edit_or_send_as_file = edit_or_send_as_file
Message.reply_or_send_as_file = reply_or_send_as_file
Message.reply_as_file = reply_as_file
Message.delete_msg = delete
Message.input = parse_cmd

View file

@ -1,6 +1,7 @@
import logging
import os
import random
import re
import string
import time
from http.cookies import SimpleCookie
@ -151,3 +152,27 @@ async def search_jw(movie_name: str, locale: Union[str, None] = "ID"):
m_t_ = m_t_[:-2].strip()
break
return m_t_
def isValidURL(str):
# Regex to check valid URL
regex = ("((http|https)://)(www.)?" +
"[a-zA-Z0-9@:%._\\+~#?&//=]" +
"{2,256}\\.[a-z]" +
"{2,6}\\b([-a-zA-Z0-9@:%" +
"._\\+~#?&//=]*)")
# Compile the ReGex
p = re.compile(regex)
# If the string is empty
# return false
if (str == None):
return False
# Return if the string
# matched the ReGex
if(re.search(p, str)):
return True
else:
return False

View file

@ -125,11 +125,12 @@ async def log_file(_, ctx: Message, strings):
@app.on_message(filters.command(["donate"], COMMAND_HANDLER))
async def donate(self: Client, ctx: Message):
with contextlib.suppress(ChatSendPlainForbidden, ChatSendPhotosForbidden):
try:
await ctx.reply_photo(
"https://img.yasirweb.eu.org/file/9427d61d6968b8ee4fb2f.jpg",
caption=f"Hi {ctx.from_user.mention}, If you find this bot useful, you can make a donation to the account below. Because this bot server uses VPS and is not free. Thank You..\n\n<b>Indonesian Payment:</b>\n<b>QRIS:</b> https://img.yasirweb.eu.org/file/b1c86973ae4e55721983a.jpg (Yasir Store)\n<b>Mayar:</b> https://yasirarism.mayar.link/payme\n<b>Bank Jago:</b> 109641845083 (Yasir Aris M)\n\nFor international people can use PayPal to support me or via GitHub Sponsor:\nhttps://paypal.me/yasirarism\nhttps://github.com/sponsors/yasirarism\n\n<b>Source:</b> @BeriKopi",
)
except (ChatSendPlainForbidden, ChatSendPhotosForbidden):
await self.send_message(LOG_CHANNEL, f"❗️ <b>WARNING</b>\nI'm leaving from {ctx.chat.id} since i didn't have sufficient admin permissions.")
await ctx.chat.leave()
@ -400,8 +401,9 @@ async def cmd_eval(self: Client, ctx: Message, strings) -> Optional[str]:
if ctx.from_user.is_self
else await ctx.reply_msg(strings("run_eval"), quote=True)
)
msg = ctx.caption if ctx.web_page_preview else ctx.text
code = (
ctx.text.split(maxsplit=1)[1] if ctx.command else ctx.text.split("\napp.run()")[0]
msg.split(maxsplit=1)[1] if ctx.command else msg.split("\napp.run()")[0]
)
out_buf = io.StringIO()
out = ""
@ -435,15 +437,15 @@ async def cmd_eval(self: Client, ctx: Message, strings) -> Optional[str]:
"cloudscraper": cloudscraper,
"json": json,
"aiohttp": aiohttp,
"print": _print,
"p": _print,
"send": send,
"stdout": out_buf,
"traceback": traceback,
"fetch": fetch,
"replied": ctx.reply_to_message,
"r": ctx.reply_to_message,
"requests": requests,
"soup": BeautifulSoup,
"help": _help,
"h": _help,
}
eval_vars.update(var)
eval_vars.update(teskode)

View file

@ -470,17 +470,17 @@ async def imdb_id_callback(self: Client, query: CallbackQuery):
res_str += f"<b>Pemeran:</b> {actor[:-2]}\n\n"
if deskripsi := r_json.get("description"):
summary = GoogleTranslator("auto", "id").translate(deskripsi)
res_str += f"<b>📜 Plot: </b> <code>{summary}</code>\n\n"
res_str += f"<b>📜 Plot:</b>\n<blockquote><code>{summary}</code></blockquote>\n\n"
if keywd := r_json.get("keywords"):
key_ = "".join(
f"#{i.replace(' ', '_').replace('-', '_')}, " for i in keywd.split(",")
)
res_str += f"<b>🔥 Kata Kunci:</b> {key_[:-2]} \n"
res_str += f"<b>🔥 Kata Kunci:</b>\n<blockquote>{key_[:-2]}</blockquote>\n"
if award := sop.select('li[data-testid="award_information"]'):
awards = (
award[0].find(class_="ipc-metadata-list-item__list-content-item").text
)
res_str += f"<b>🏆 Penghargaan:</b> <code>{GoogleTranslator('auto', 'id').translate(awards)}</code>\n"
res_str += f"<b>🏆 Penghargaan:</b>\n<blockquote><code>{GoogleTranslator('auto', 'id').translate(awards)}</code></blockquote>\n"
else:
res_str += "\n"
if ott != "":
@ -633,18 +633,18 @@ async def imdb_en_callback(self: Client, query: CallbackQuery):
)
res_str += f"<b>Stars:</b> {actors[:-2]}\n\n"
if description := r_json.get("description"):
res_str += f"<b>📜 Summary: </b> <code>{description}</code>\n\n"
res_str += f"<b>📜 Summary:</b>\n<blockquote><code>{description}</code></blockquote>\n\n"
if r_json.get("keywords"):
key_ = "".join(
f"#{i.replace(' ', '_').replace('-', '_')}, "
for i in r_json["keywords"].split(",")
)
res_str += f"<b>🔥 Keywords:</b> {key_[:-2]} \n"
res_str += f"<b>🔥 Keywords:</b>\n<blockquote>{key_[:-2]}</blockquote>\n"
if award := sop.select('li[data-testid="award_information"]'):
awards = (
award[0].find(class_="ipc-metadata-list-item__list-content-item").text
)
res_str += f"<b>🏆 Awards:</b> <code>{awards}</code>\n"
res_str += f"<b>🏆 Awards:</b>\n<blockquote><code>{awards}</code></blockquote>\n"
else:
res_str += "\n"
if ott != "":

View file

@ -725,20 +725,20 @@ async def imdb_inl(_, query):
summary = GoogleTranslator("auto", "id").translate(
r_json.get("description")
)
res_str += f"<b>📜 Plot: </b> <code>{summary}</code>\n\n"
res_str += f"<b>📜 Plot:</b>\n<blockquote><code>{summary}</code></blockquote>\n\n"
if r_json.get("keywords"):
key_ = "".join(
f"#{i.replace(' ', '_').replace('-', '_')}, "
for i in r_json["keywords"].split(",")
)
res_str += f"<b>🔥 Kata Kunci:</b> {key_[:-2]} \n"
res_str += f"<b>🔥 Kata Kunci:</b>\n<blockquote>{key_[:-2]}</blockquote>\n"
if award := sop.select('li[data-testid="award_information"]'):
awards = (
award[0]
.find(class_="ipc-metadata-list-item__list-content-item")
.text
)
res_str += f"<b>🏆 Penghargaan:</b> <code>{GoogleTranslator('auto', 'id').translate(awards)}</code>\n"
res_str += f"<b>🏆 Penghargaan:</b>\n<blockquote><code>{GoogleTranslator('auto', 'id').translate(awards)}</code></blockquote>\n"
else:
res_str += "\n"
if ott != "":

View file

@ -27,7 +27,7 @@ from pyrogram.types import (
from misskaty import app
from misskaty.core import pyro_cooldown
from misskaty.core.decorator import capture_err, new_task
from misskaty.helper import fetch, use_chat_lang
from misskaty.helper import fetch, use_chat_lang, isValidURL
from misskaty.vars import COMMAND_HANDLER, LOG_CHANNEL, SUDO
LOGGER = getLogger("MissKaty")
@ -91,12 +91,15 @@ async def ytsearch(_, ctx: Message, strings):
)
@capture_err
@use_chat_lang()
async def ytdownv2(_, ctx: Message, strings):
async def ytdownv2(self, ctx: Message, strings):
if not ctx.from_user:
return await ctx.reply_msg(strings("no_channel"))
if ctx.command and len(ctx.command) == 1:
return await ctx.reply_msg(strings("invalid_link"))
url = ctx.input if ctx.command and len(ctx.command) > 1 else ctx.text
msg = ctx.caption if ctx.web_page_preview else ctx.text
url = msg.split()[1]
if not isValidURL(url):
return await ctx.reply_msg(strings("invalid_link"))
async with iYTDL(log_group_id=0, cache_path="cache", silent=True) as ytdl:
try:
x = await ytdl.parse(url, extract=True)