|
|
|
@ -10,8 +10,7 @@ import traceback
|
|
|
|
|
from modules.logging import logWrite
|
|
|
|
|
from modules.utils import configGet, jsonLoad, jsonSave
|
|
|
|
|
|
|
|
|
|
pid = os.getpid()
|
|
|
|
|
|
|
|
|
|
# Args =====================================================================================================================================
|
|
|
|
|
if "--move-sent" in sys.argv:
|
|
|
|
|
for entry in jsonLoad(configGet("index", "locations"))["sent"]:
|
|
|
|
|
try:
|
|
|
|
@ -54,7 +53,10 @@ if "--cleanup-index" in sys.argv:
|
|
|
|
|
if "--norun" in sys.argv:
|
|
|
|
|
logWrite("Argument --norun passed, not running the main script")
|
|
|
|
|
sys.exit()
|
|
|
|
|
#===========================================================================================================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Import ===================================================================================================================================
|
|
|
|
|
try:
|
|
|
|
|
import schedule # type: ignore
|
|
|
|
|
from pyrogram import Client, filters, idle # type: ignore
|
|
|
|
@ -62,7 +64,10 @@ try:
|
|
|
|
|
except ModuleNotFoundError:
|
|
|
|
|
print(f"Required modules are not installed. Run 'pip3 install -r requirements.txt' and restart the program.", flush=True)
|
|
|
|
|
sys.exit()
|
|
|
|
|
#===========================================================================================================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pid = os.getpid()
|
|
|
|
|
app = Client("duptsiaposter", bot_token=configGet("bot_token", "bot"), api_id=configGet("api_id", "bot"), api_hash=configGet("api_hash", "bot"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -151,6 +156,34 @@ def kill(app, msg):
|
|
|
|
|
os.system('kill -9 '+str(pid))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Submission =====================================================================================================================================
|
|
|
|
|
def subLimit(user):
|
|
|
|
|
submit = jsonLoad(configGet("submit", "locations"))
|
|
|
|
|
submit[str(user.id)] = time.time()
|
|
|
|
|
jsonSave(submit, configGet("submit", "locations"))
|
|
|
|
|
|
|
|
|
|
def subLimited(user):
|
|
|
|
|
if user.id == configGet("admin", "reports"):
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
|
submit = jsonLoad(configGet("submit", "locations"))
|
|
|
|
|
if str(user.id) in submit:
|
|
|
|
|
if (time.time - submit[str(user.id)]) > configGet("limit", "submission"):
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
@app.on_message(filters.photo | filters.video | filters.animation)
|
|
|
|
|
def get_submission(_, msg):
|
|
|
|
|
if not subLimited(msg.from_user):
|
|
|
|
|
subLimit(msg.from_user)
|
|
|
|
|
else:
|
|
|
|
|
msg.reply_text(f'You can only submit 1 media per {configGet("limit", "submission")} seconds')
|
|
|
|
|
#===========================================================================================================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for entry in configGet("time", "posting"):
|
|
|
|
|
schedule.every().day.at(entry).do(send_content)
|
|
|
|
|
|
|
|
|
|