diff --git a/.pep8speaks.toml b/.pep8speaks.toml
deleted file mode 100644
index 8b373469..00000000
--- a/.pep8speaks.toml
+++ /dev/null
@@ -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."
\ No newline at end of file
diff --git a/misskaty/__init__.py b/misskaty/__init__.py
index d64b5f70..44c2fbbe 100644
--- a/misskaty/__init__.py
+++ b/misskaty/__init__.py
@@ -40,7 +40,7 @@ MOD_NOLOAD = ["subscene_dl"]
HELPABLE = {}
cleanmode = {}
botStartTime = time.time()
-misskaty_version = "v2.9.2 - Stable"
+misskaty_version = "v2.9.3 - Stable"
# Pyrogram Bot Client
app = Client(
diff --git a/misskaty/plugins/grup_tools.py b/misskaty/plugins/grup_tools.py
index d275867c..32e6fc4d 100644
--- a/misskaty/plugins/grup_tools.py
+++ b/misskaty/plugins/grup_tools.py
@@ -301,35 +301,37 @@ async def kickme(_, message):
@app.on_message(filters.command("users") & filters.user(SUDO))
async def list_users(bot, message):
# 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()
out = "Users Saved In DB Are:\n\n"
async for user in users:
- out += f"{user['name']}"
+ out += f"User ID: {user.get('id')} -> {user.get('name')}"
if user["ban_status"]["is_banned"]:
out += "( Banned User )"
out += "\n"
try:
- await raju.edit_text(out)
+ await msg.edit_text(out)
except MessageTooLong:
with open("users.txt", "w+") as outfile:
outfile.write(out)
await message.reply_document("users.txt", caption="List Of Users")
+ await msg.delete_msg()
@app.on_message(filters.command("chats") & filters.user(SUDO))
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()
out = "Chats Saved In DB Are:\n\n"
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"]:
out += "( Disabled Chat )"
out += "\n"
try:
- await raju.edit_text(out)
+ await msg.edit_text(out)
except MessageTooLong:
with open("chats.txt", "w+") as outfile:
outfile.write(out)
await message.reply_document("chats.txt", caption="List Of Chats")
+ await msg.delete_msg()
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..d8cf62d2 100644
--- a/misskaty/plugins/ytdl_plugins.py
+++ b/misskaty/plugins/ytdl_plugins.py
@@ -103,15 +103,9 @@ async def ytdownv2(self: Client, ctx: Message, strings):
caption = x.caption
markup = x.buttons
photo = x.image_url
- msg = await ctx.reply_photo(
+ await ctx.reply_photo(
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:
await ctx.reply_msg(f"Opps, ERROR: {str(err)}")
@@ -168,6 +162,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/misskaty/vars.py b/misskaty/vars.py
index 6bd35fe9..fc9ec30e 100644
--- a/misskaty/vars.py
+++ b/misskaty/vars.py
@@ -12,24 +12,6 @@ from dotenv import load_dotenv
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):
try:
diff --git a/requirements.txt b/requirements.txt
index fd9efcc8..65b5e1a5 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -18,7 +18,7 @@ psutil
python-dateutil
telegraph
hachoir
-Pillow>=9.5.0
+Pillow==10.0.0
httpx[http2]
git+https://github.com/yasirarism/vcsi
git+https://github.com/yasirarism/iytdl
@@ -27,4 +27,5 @@ telethon
pyrate_limiter
cachetools
cloudscraper
-openai
\ No newline at end of file
+openai
+GitPython
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..753d6f79 100644
--- a/update.py
+++ b/update.py
@@ -1,13 +1,21 @@
import logging
import os
-from subprocess import run as srun
+import subprocess
+import time
+import dotenv
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__)
-CONFIG_FILE_URL = os.environ.get("CONFIG_FILE_URL", "")
+CONFIG_FILE_URL = os.environ.get("CONFIG_FILE_URL")
try:
if len(CONFIG_FILE_URL) == 0:
raise TypeError
@@ -19,42 +27,41 @@ try:
else:
LOGGER.error(f"config.env err: {res.status_code}")
except Exception as e:
- LOGGER.error(f"ENV_URL: {e}")
+ LOGGER.error(f"CONFIG_FILE_URL: {e}")
except:
pass
-load_dotenv("config.env", override=True)
+dotenv.load_dotenv("config.env", override=True)
-UPSTREAM_REPO_URL = os.environ.get("UPSTREAM_REPO_URL", "")
-if len(UPSTREAM_REPO_URL) == 0:
- UPSTREAM_REPO_URL = None
+UPSTREAM_REPO_URL = os.environ.get("UPSTREAM_REPO_URL")
+UPSTREAM_REPO_BRANCH = os.environ.get("UPSTREAM_REPO_BRANCH")
-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 all([UPSTREAM_REPO_URL, UPSTREAM_REPO_BRANCH]):
if os.path.exists(".git"):
- srun(["rm", "-rf", ".git"], check=True)
+ subprocess.run(["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 add . \
- && git commit -sm update -q \
- && git remote add origin {UPSTREAM_REPO_URL} \
- && git fetch origin -q \
- && git reset --hard origin/{UPSTREAM_REPO_BRANCH} -q"
- ],
- shell=True,
- check=True,
- )
-
- if update.returncode == 0:
- LOGGER.error("Successfully updated with latest commit from UPSTREAM_REPO")
- else:
- LOGGER.error(
- "Something went wrong while updating, check UPSTREAM_REPO if valid or not!"
+ try:
+ repo = Repo.init()
+ origin = repo.create_remote("upstream", UPSTREAM_REPO_URL)
+ origin.fetch()
+ repo.create_head(UPSTREAM_REPO_BRANCH, origin.refs[UPSTREAM_REPO_BRANCH])
+ repo.heads[UPSTREAM_REPO_BRANCH].set_tracking_branch(
+ origin.refs[UPSTREAM_REPO_BRANCH]
)
+ repo.heads[UPSTREAM_REPO_BRANCH].checkout(True)
+ ups_rem = repo.remote("upstream")
+ 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:
+ LOGGER.warning(
+ "UPSTREAM_REPO_URL or UPSTREAM_REPO_BRANCH is not defined, Skipping auto update"
+ )