mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2025-12-29 09:44:50 +00:00
Add auto updater and fix genss because pillow v10 (#127)
* auto updater tess
* forgot
* fixx
* tess lagi
* pusing
* no cache
* ok
* Update update.py
* Update requirements.txt
* Update requirements.txt
* Lock pillow version
* Fix error
* Update __init__.py
* style: format code with black and isort (#126)
Format code with black and isort
This commit fixes the style issues introduced in 0188bba according to the output
from Black and isort.
Details: https://app.deepsource.com/gh/yasirarism/MissKatyPyro/transform/dbe242ae-b4d5-4a9a-8998-ba9fe569a4e0/
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
---------
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
This commit is contained in:
parent
5c642ddeb2
commit
3bebdfee43
9 changed files with 58 additions and 86 deletions
|
|
@ -1,15 +0,0 @@
|
||||||
# File : .pep8speaks.yml
|
|
||||||
|
|
||||||
scanner:
|
|
||||||
linter: flake8
|
|
||||||
|
|
||||||
flake8:
|
|
||||||
max-line-length: 100
|
|
||||||
ignore:
|
|
||||||
- W503 # line break before binary operator
|
|
||||||
|
|
||||||
message:
|
|
||||||
opened:
|
|
||||||
header: "@{name}, Thanks for opening this PR."
|
|
||||||
updated:
|
|
||||||
header: "@{name}, Thanks for updating this PR."
|
|
||||||
|
|
@ -40,7 +40,7 @@ MOD_NOLOAD = ["subscene_dl"]
|
||||||
HELPABLE = {}
|
HELPABLE = {}
|
||||||
cleanmode = {}
|
cleanmode = {}
|
||||||
botStartTime = time.time()
|
botStartTime = time.time()
|
||||||
misskaty_version = "v2.9.2 - Stable"
|
misskaty_version = "v2.9.3 - Stable"
|
||||||
|
|
||||||
# Pyrogram Bot Client
|
# Pyrogram Bot Client
|
||||||
app = Client(
|
app = Client(
|
||||||
|
|
|
||||||
|
|
@ -301,35 +301,37 @@ async def kickme(_, message):
|
||||||
@app.on_message(filters.command("users") & filters.user(SUDO))
|
@app.on_message(filters.command("users") & filters.user(SUDO))
|
||||||
async def list_users(bot, message):
|
async def list_users(bot, message):
|
||||||
# https://t.me/GetTGLink/4184
|
# https://t.me/GetTGLink/4184
|
||||||
raju = await message.reply("Getting List Of Users")
|
msg = await message.reply("Getting List Of Users")
|
||||||
users = await db.get_all_users()
|
users = await db.get_all_users()
|
||||||
out = "Users Saved In DB Are:\n\n"
|
out = "Users Saved In DB Are:\n\n"
|
||||||
async for user in users:
|
async for user in users:
|
||||||
out += f"<a href=tg://user?id={user['id']}>{user['name']}</a>"
|
out += f"User ID: {user.get('id')} -> {user.get('name')}"
|
||||||
if user["ban_status"]["is_banned"]:
|
if user["ban_status"]["is_banned"]:
|
||||||
out += "( Banned User )"
|
out += "( Banned User )"
|
||||||
out += "\n"
|
out += "\n"
|
||||||
try:
|
try:
|
||||||
await raju.edit_text(out)
|
await msg.edit_text(out)
|
||||||
except MessageTooLong:
|
except MessageTooLong:
|
||||||
with open("users.txt", "w+") as outfile:
|
with open("users.txt", "w+") as outfile:
|
||||||
outfile.write(out)
|
outfile.write(out)
|
||||||
await message.reply_document("users.txt", caption="List Of Users")
|
await message.reply_document("users.txt", caption="List Of Users")
|
||||||
|
await msg.delete_msg()
|
||||||
|
|
||||||
|
|
||||||
@app.on_message(filters.command("chats") & filters.user(SUDO))
|
@app.on_message(filters.command("chats") & filters.user(SUDO))
|
||||||
async def list_chats(bot, message):
|
async def list_chats(bot, message):
|
||||||
raju = await message.reply("Getting List Of chats")
|
msg = await message.reply("Getting List Of chats")
|
||||||
chats = await db.get_all_chats()
|
chats = await db.get_all_chats()
|
||||||
out = "Chats Saved In DB Are:\n\n"
|
out = "Chats Saved In DB Are:\n\n"
|
||||||
async for chat in chats:
|
async for chat in chats:
|
||||||
out += f"**Title:** `{chat['title']}`\n**- ID:** `{chat['id']}`"
|
out += f"Title: {chat.get('title')} ({chat.get('id')}) "
|
||||||
if chat["chat_status"]["is_disabled"]:
|
if chat["chat_status"]["is_disabled"]:
|
||||||
out += "( Disabled Chat )"
|
out += "( Disabled Chat )"
|
||||||
out += "\n"
|
out += "\n"
|
||||||
try:
|
try:
|
||||||
await raju.edit_text(out)
|
await msg.edit_text(out)
|
||||||
except MessageTooLong:
|
except MessageTooLong:
|
||||||
with open("chats.txt", "w+") as outfile:
|
with open("chats.txt", "w+") as outfile:
|
||||||
outfile.write(out)
|
outfile.write(out)
|
||||||
await message.reply_document("chats.txt", caption="List Of Chats")
|
await message.reply_document("chats.txt", caption="List Of Chats")
|
||||||
|
await msg.delete_msg()
|
||||||
|
|
|
||||||
|
|
@ -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"
|
f"<b>Pip Command:</b> pip3 install {res['info'].get('name', 'Unknown')}\n"
|
||||||
)
|
)
|
||||||
msg += f"<b>Keywords:</b> {res['info'].get('keywords', '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:
|
except Exception as err:
|
||||||
await callback_query.message.edit_msg(f"ERROR: {err}", reply_markup=keyboard)
|
await callback_query.message.edit_msg(f"ERROR: {err}", reply_markup=keyboard)
|
||||||
return
|
|
||||||
await callback_query.message.edit_msg(msg, reply_markup=keyboard)
|
|
||||||
|
|
|
||||||
|
|
@ -103,15 +103,9 @@ async def ytdownv2(self: Client, ctx: Message, strings):
|
||||||
caption = x.caption
|
caption = x.caption
|
||||||
markup = x.buttons
|
markup = x.buttons
|
||||||
photo = x.image_url
|
photo = x.image_url
|
||||||
msg = await ctx.reply_photo(
|
await ctx.reply_photo(
|
||||||
photo, caption=caption, reply_markup=markup, quote=True
|
photo, caption=caption, reply_markup=markup, quote=True
|
||||||
)
|
)
|
||||||
await msg.wait_for_click(from_user_id=ctx.from_user.id, timeout=30)
|
|
||||||
except ListenerTimeout:
|
|
||||||
try:
|
|
||||||
await msg.edit_caption(strings("exp_task", context="general"))
|
|
||||||
except MessageIdInvalid:
|
|
||||||
pass
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
await ctx.reply_msg(f"Opps, ERROR: {str(err)}")
|
await ctx.reply_msg(f"Opps, ERROR: {str(err)}")
|
||||||
|
|
||||||
|
|
@ -168,6 +162,8 @@ async def ytdl_extractinfo_callback(self: Client, cq: CallbackQuery, strings):
|
||||||
@ratelimiter
|
@ratelimiter
|
||||||
@use_chat_lang()
|
@use_chat_lang()
|
||||||
async def ytdl_gendl_callback(self: Client, cq: CallbackQuery, strings):
|
async def ytdl_gendl_callback(self: Client, cq: CallbackQuery, strings):
|
||||||
|
if not cq.message.reply_to_message.from_user:
|
||||||
|
return
|
||||||
match = cq.data.split("|")
|
match = cq.data.split("|")
|
||||||
if cq.from_user.id != cq.message.reply_to_message.from_user.id:
|
if cq.from_user.id != cq.message.reply_to_message.from_user.id:
|
||||||
return await cq.answer(strings("unauth"), True)
|
return await cq.answer(strings("unauth"), True)
|
||||||
|
|
|
||||||
|
|
@ -12,24 +12,6 @@ from dotenv import load_dotenv
|
||||||
|
|
||||||
LOGGER = getLogger(__name__)
|
LOGGER = getLogger(__name__)
|
||||||
|
|
||||||
CONFIG_FILE_URL = os.environ.get("CONFIG_FILE_URL", "")
|
|
||||||
try:
|
|
||||||
if len(CONFIG_FILE_URL) == 0:
|
|
||||||
raise TypeError
|
|
||||||
try:
|
|
||||||
res = requests.get(CONFIG_FILE_URL)
|
|
||||||
if res.status_code == 200:
|
|
||||||
with open("config.env", "wb+") as f:
|
|
||||||
f.write(res.content)
|
|
||||||
else:
|
|
||||||
LOGGER.error(f"config.env err: {res.status_code}")
|
|
||||||
except Exception as e:
|
|
||||||
LOGGER.error(f"ENV_URL: {e}")
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
load_dotenv("config.env", override=True)
|
|
||||||
|
|
||||||
|
|
||||||
def getConfig(name: str):
|
def getConfig(name: str):
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ psutil
|
||||||
python-dateutil
|
python-dateutil
|
||||||
telegraph
|
telegraph
|
||||||
hachoir
|
hachoir
|
||||||
Pillow>=9.5.0
|
Pillow==10.0.0
|
||||||
httpx[http2]
|
httpx[http2]
|
||||||
git+https://github.com/yasirarism/vcsi
|
git+https://github.com/yasirarism/vcsi
|
||||||
git+https://github.com/yasirarism/iytdl
|
git+https://github.com/yasirarism/iytdl
|
||||||
|
|
@ -28,3 +28,4 @@ pyrate_limiter
|
||||||
cachetools
|
cachetools
|
||||||
cloudscraper
|
cloudscraper
|
||||||
openai
|
openai
|
||||||
|
GitPython
|
||||||
|
|
|
||||||
2
start.sh
2
start.sh
|
|
@ -1 +1 @@
|
||||||
python3 -m misskaty
|
python3 update.py && python3 -m misskaty
|
||||||
|
|
|
||||||
71
update.py
71
update.py
|
|
@ -1,13 +1,21 @@
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from subprocess import run as srun
|
import subprocess
|
||||||
|
import time
|
||||||
|
|
||||||
|
import dotenv
|
||||||
import requests
|
import requests
|
||||||
from dotenv import load_dotenv
|
from git import Repo
|
||||||
|
|
||||||
|
logging.basicConfig(
|
||||||
|
format="[%(levelname)s] - [%(asctime)s] [%(filename)s:%(lineno)d] %(message)s",
|
||||||
|
handlers=[logging.FileHandler("log.txt"), logging.StreamHandler()],
|
||||||
|
level=logging.INFO,
|
||||||
|
)
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
CONFIG_FILE_URL = os.environ.get("CONFIG_FILE_URL", "")
|
CONFIG_FILE_URL = os.environ.get("CONFIG_FILE_URL")
|
||||||
try:
|
try:
|
||||||
if len(CONFIG_FILE_URL) == 0:
|
if len(CONFIG_FILE_URL) == 0:
|
||||||
raise TypeError
|
raise TypeError
|
||||||
|
|
@ -19,42 +27,41 @@ try:
|
||||||
else:
|
else:
|
||||||
LOGGER.error(f"config.env err: {res.status_code}")
|
LOGGER.error(f"config.env err: {res.status_code}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOGGER.error(f"ENV_URL: {e}")
|
LOGGER.error(f"CONFIG_FILE_URL: {e}")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
load_dotenv("config.env", override=True)
|
dotenv.load_dotenv("config.env", override=True)
|
||||||
|
|
||||||
UPSTREAM_REPO_URL = os.environ.get("UPSTREAM_REPO_URL", "")
|
UPSTREAM_REPO_URL = os.environ.get("UPSTREAM_REPO_URL")
|
||||||
if len(UPSTREAM_REPO_URL) == 0:
|
UPSTREAM_REPO_BRANCH = os.environ.get("UPSTREAM_REPO_BRANCH")
|
||||||
UPSTREAM_REPO_URL = None
|
|
||||||
|
|
||||||
UPSTREAM_REPO_BRANCH = os.environ.get("UPSTREAM_REPO_BRANCH", "")
|
if all([UPSTREAM_REPO_URL, 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"):
|
if os.path.exists(".git"):
|
||||||
srun(["rm", "-rf", ".git"], check=True)
|
subprocess.run(["rm", "-rf", ".git"])
|
||||||
|
|
||||||
update = srun(
|
try:
|
||||||
[
|
repo = Repo.init()
|
||||||
f"git init -q \
|
origin = repo.create_remote("upstream", UPSTREAM_REPO_URL)
|
||||||
&& git config --global user.email mail@yasir.eu.org \
|
origin.fetch()
|
||||||
&& git config --global user.name yasirarism \
|
repo.create_head(UPSTREAM_REPO_BRANCH, origin.refs[UPSTREAM_REPO_BRANCH])
|
||||||
&& git add . \
|
repo.heads[UPSTREAM_REPO_BRANCH].set_tracking_branch(
|
||||||
&& git commit -sm update -q \
|
origin.refs[UPSTREAM_REPO_BRANCH]
|
||||||
&& git remote add origin {UPSTREAM_REPO_URL} \
|
|
||||||
&& git fetch origin -q \
|
|
||||||
&& git reset --hard origin/{UPSTREAM_REPO_BRANCH} -q"
|
|
||||||
],
|
|
||||||
shell=True,
|
|
||||||
check=True,
|
|
||||||
)
|
)
|
||||||
|
repo.heads[UPSTREAM_REPO_BRANCH].checkout(True)
|
||||||
if update.returncode == 0:
|
ups_rem = repo.remote("upstream")
|
||||||
LOGGER.error("Successfully updated with latest commit from UPSTREAM_REPO")
|
ups_rem.fetch(UPSTREAM_REPO_BRANCH)
|
||||||
|
LOGGER.info(f"Successfully update with latest branch > {UPSTREAM_REPO_BRANCH}")
|
||||||
|
except Exception as e:
|
||||||
|
LOGGER.error(e)
|
||||||
|
pass
|
||||||
|
# time.sleep(6)
|
||||||
|
# update = subprocess.run(['pip3', 'install', '-U', '-r', 'requirements.txt'])
|
||||||
|
# if update.returncode == 0:
|
||||||
|
# LOGGER.info("Successfully update package pip python")
|
||||||
|
# else:
|
||||||
|
# LOGGER.warning("Unsuccessfully update package pip python")
|
||||||
else:
|
else:
|
||||||
LOGGER.error(
|
LOGGER.warning(
|
||||||
"Something went wrong while updating, check UPSTREAM_REPO if valid or not!"
|
"UPSTREAM_REPO_URL or UPSTREAM_REPO_BRANCH is not defined, Skipping auto update"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue