mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2026-01-01 10:34:51 +00:00
auto updater tess
This commit is contained in:
parent
5c642ddeb2
commit
ffd8794db0
4 changed files with 26 additions and 33 deletions
|
|
@ -149,7 +149,6 @@ async def pypi_getdata(self: Client, callback_query: CallbackQuery):
|
|||
f"<b>Pip Command:</b> pip3 install {res['info'].get('name', 'Unknown')}\n"
|
||||
)
|
||||
msg += f"<b>Keywords:</b> {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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
2
start.sh
2
start.sh
|
|
@ -1 +1 @@
|
|||
python3 -m misskaty
|
||||
python3 update.py && python3 -m misskaty
|
||||
|
|
|
|||
52
update.py
52
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)
|
||||
Loading…
Reference in a new issue