Compare commits

..

No commits in common. "0e14ca600ff6fa0a67044a6d76f2b545132fc990" and "f0c333968bf68424d163ca43b1b77b595432d83b" have entirely different histories.

2 changed files with 22 additions and 23 deletions

@ -5,11 +5,11 @@ except ModuleNotFoundError:
from json import JSONDecodeError as JSONDecodeError
from json import loads, dumps
from sys import exit
from os import sep, kill
from os import name as osname
from traceback import print_exc
import os
import sys
import traceback
from signal import SIGKILL # type: ignore
from modules.logging import logWrite
def jsonLoad(filename):
@ -18,10 +18,10 @@ def jsonLoad(filename):
try:
output = loads(file.read())
except JSONDecodeError:
logWrite(f"Could not load json file {filename}: file seems to be incorrect!\n{print_exc()}")
logWrite(f"Could not load json file {filename}: file seems to be incorrect!\n{traceback.print_exc()}")
raise
except FileNotFoundError:
logWrite(f"Could not load json file {filename}: file does not seem to exist!\n{print_exc()}")
logWrite(f"Could not load json file {filename}: file does not seem to exist!\n{traceback.print_exc()}")
raise
file.close()
return output
@ -33,7 +33,7 @@ def jsonSave(contents, filename):
file.write(dumps(contents, ensure_ascii=False, indent=4))
file.close()
except Exception as exp:
logWrite(f"Could not save json file {filename}: {exp}\n{print_exc()}")
logWrite(f"Could not save json file {filename}: {exp}\n{traceback.print_exc()}")
return
@ -83,13 +83,13 @@ def locale(key: str, *args: str, locale=configGet("locale")):
locale = configGet("locale")
try:
this_dict = jsonLoad(f'{configGet("locale", "locations")}{sep}{locale}.json')
this_dict = jsonLoad(f'{configGet("locale", "locations")}{os.sep}{locale}.json')
except FileNotFoundError:
try:
this_dict = jsonLoad(f'{configGet("locale", "locations")}{sep}{configGet("locale")}.json')
this_dict = jsonLoad(f'{configGet("locale", "locations")}{os.sep}{configGet("locale")}.json')
except FileNotFoundError:
try:
this_dict = jsonLoad(f'{configGet("locale_fallback", "locations")}{sep}{configGet("locale")}.json')
this_dict = jsonLoad(f'{configGet("locale_fallback", "locations")}{os.sep}{configGet("locale")}.json')
except:
return f'⚠️ Locale in config is invalid: could not get "{key}" in {str(args)} from locale "{locale}"'
@ -103,15 +103,14 @@ def locale(key: str, *args: str, locale=configGet("locale")):
return f'⚠️ Locale in config is invalid: could not get "{key}" in {str(args)} from locale "{locale}"'
try:
from psutil import Process
import psutil
except ModuleNotFoundError:
print(locale("deps_missing", "console", locale=configGet("locale")), flush=True)
exit()
sys.exit()
def killProc(pid):
if osname == "posix":
from signal import SIGKILL # type: ignore
kill(pid, SIGKILL)
if os.name == "posix":
os.kill(pid, SIGKILL)
else:
p = Process(pid)
p = psutil.Process(pid)
p.kill()

@ -58,11 +58,11 @@ if "--norun" in argv:
# Import ===================================================================================================================================
try:
import schedule
from pyrogram.sync import idle
from pyrogram.client import Client
from pyrogram import filters
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, BotCommand, BotCommandScopeChat
import schedule # type: ignore
from pyrogram import Client, filters, idle # type: ignore
from pyrogram.types import ChatPermissions, ReplyKeyboardMarkup, InlineKeyboardMarkup, InlineKeyboardButton, BotCommand, BotCommandScopeChat # type: ignore
from pyrogram.raw.types import UpdateChannelMessageForwards, InputChannel, InputPeerChannel
from pyrogram.raw.functions.stats import GetMessagePublicForwards
except ModuleNotFoundError:
print(locale("deps_missing", "console", locale=configGet("locale_log")), flush=True)
exit()
@ -181,7 +181,7 @@ def send_content():
return
index["sent"].append(candidate_file)
index["last_id"] = sent.id # type: ignore
index["last_id"] = sent.id
jsonSave(index, configGet("index", "locations"))
@ -458,7 +458,7 @@ if __name__ == "__main__":
app.send_message(configGet("admin"), locale("startup", "message", locale=configGet("locale")).format(str(pid))) # type: ignore
if configGet("post", "mode"):
t = Thread(target=background_task) # type: ignore
t = Thread(target=background_task)
t.start()
if configGet("submit", "mode"):