diff --git a/misskaty/plugins/pypi_search.py b/misskaty/plugins/pypi_search.py index 2cc6377d..a54a8e2e 100644 --- a/misskaty/plugins/pypi_search.py +++ b/misskaty/plugins/pypi_search.py @@ -149,7 +149,6 @@ async def pypi_getdata(self: Client, callback_query: CallbackQuery): f"Pip Command: pip3 install {res['info'].get('name', 'Unknown')}\n" ) msg += f"Keywords: {res['info'].get('keywords', 'Unknown')}\n" + await callback_query.message.edit_msg(msg, reply_markup=keyboard) except Exception as err: await callback_query.message.edit_msg(f"ERROR: {err}", reply_markup=keyboard) - return - await callback_query.message.edit_msg(msg, reply_markup=keyboard) diff --git a/misskaty/plugins/ytdl_plugins.py b/misskaty/plugins/ytdl_plugins.py index 1a1278dd..80b0874a 100644 --- a/misskaty/plugins/ytdl_plugins.py +++ b/misskaty/plugins/ytdl_plugins.py @@ -168,6 +168,8 @@ async def ytdl_extractinfo_callback(self: Client, cq: CallbackQuery, strings): @ratelimiter @use_chat_lang() async def ytdl_gendl_callback(self: Client, cq: CallbackQuery, strings): + if not cq.message.reply_to_message.from_user: + return match = cq.data.split("|") if cq.from_user.id != cq.message.reply_to_message.from_user.id: return await cq.answer(strings("unauth"), True) diff --git a/start.sh b/start.sh index 8db221d8..1d9128b9 100644 --- a/start.sh +++ b/start.sh @@ -1 +1 @@ -python3 -m misskaty +python3 update.py && python3 -m misskaty diff --git a/update.py b/update.py index c7d2f894..20e31466 100644 --- a/update.py +++ b/update.py @@ -1,5 +1,6 @@ import logging import os +import sys from subprocess import run as srun import requests @@ -7,23 +8,23 @@ from dotenv import load_dotenv LOGGER = logging.getLogger(__name__) -CONFIG_FILE_URL = os.environ.get("CONFIG_FILE_URL", "") -try: - if len(CONFIG_FILE_URL) == 0: - raise TypeError +CONFIG_FILE_URL = environ.get("CONFIG_FILE_URL", "") +if len(CONFIG_FILE_URL) != 0: try: res = requests.get(CONFIG_FILE_URL) if res.status_code == 200: - with open("config.env", "wb+") as f: - f.write(res.content) + with open("config.env", "wb+") as c: + c.write(res.content) + LOGGER.info("Config env has successfully writed") else: - LOGGER.error(f"config.env err: {res.status_code}") + LOGGER.info( + f"config.env error: {res.status_code}\nMake sure ur config.env found in workdir, will continuing with config.env on workdir" + ) except Exception as e: - LOGGER.error(f"ENV_URL: {e}") -except: - pass + LOGGER.error(f"Something wrong while downloading config.env > {str(e)}") + sys.exit(0) -load_dotenv("config.env", override=True) +load_dotenv('config.env', override=True) UPSTREAM_REPO_URL = os.environ.get("UPSTREAM_REPO_URL", "") if len(UPSTREAM_REPO_URL) == 0: @@ -33,28 +34,19 @@ UPSTREAM_REPO_BRANCH = os.environ.get("UPSTREAM_REPO_BRANCH", "") if len(UPSTREAM_REPO_BRANCH) == 0: UPSTREAM_REPO_BRANCH = "master" -if UPSTREAM_REPO_URL is not None: - if os.path.exists(".git"): - srun(["rm", "-rf", ".git"], check=True) - - update = srun( - [ - f"git init -q \ +if UPSTREAM_REPO is not None and UPSTREAM_BRANCH is not None: + if os.path.exists('.git'): + srun(["rm", "-rf", ".git"]) + update = srun([f"git init -q \ && git config --global user.email mail@yasir.eu.org \ - && git config --global user.name yasirarism \ + && git config --global user.name YasirArisM \ && git add . \ && git commit -sm update -q \ - && git remote add origin {UPSTREAM_REPO_URL} \ + && git remote add origin {UPSTREAM_REPO} \ && git fetch origin -q \ - && git reset --hard origin/{UPSTREAM_REPO_BRANCH} -q" - ], - shell=True, - check=True, - ) - + && git reset --hard origin/{UPSTREAM_BRANCH} -q"], shell=True) if update.returncode == 0: - LOGGER.error("Successfully updated with latest commit from UPSTREAM_REPO") + logging.info(f'Successfully updated with latest commit branch > {UPSTREAM_BRANCH}') else: - LOGGER.error( - "Something went wrong while updating, check UPSTREAM_REPO if valid or not!" - ) + logging.error(f'Something went wrong while updating, check UPSTREAM_REPO if valid or not! return code: {update.returncode}') + sys.exit(1) \ No newline at end of file