Added three command-line args
This commit is contained in:
parent
e65d98deca
commit
8039685e6b
33
main.py
33
main.py
@ -8,8 +8,38 @@ import time
|
||||
import traceback
|
||||
import schedule
|
||||
|
||||
from modules.logging import logWrite
|
||||
from modules.utils import configGet, jsonLoad, jsonSave
|
||||
|
||||
pid = os.getpid()
|
||||
|
||||
if "--move-sent" in sys.argv:
|
||||
for entry in jsonLoad(configGet("index", "locations"))["sent"]:
|
||||
try:
|
||||
shutil.move(configGet("queue", "locations")+os.sep+entry, configGet("sent", "locations")+os.sep+entry)
|
||||
except FileNotFoundError:
|
||||
logWrite(f"File '{entry}' is already moved or does not exist")
|
||||
except Exception as exp:
|
||||
logWrite(f"Could not move sent file '{entry}' to '{configGet('sent', 'locations')}' due to {exp}")
|
||||
|
||||
if "--cleanup" in sys.argv:
|
||||
for entry in jsonLoad(configGet("index", "locations"))["sent"]:
|
||||
try:
|
||||
try:
|
||||
os.remove(configGet("queue", "locations")+os.sep+entry)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
try:
|
||||
os.remove(configGet("sent", "locations")+os.sep+entry)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
except Exception as exp:
|
||||
logWrite(f"Could not remove '{entry}' due to {exp}")
|
||||
|
||||
if "--norun" in sys.argv:
|
||||
logWrite("Argument --norun passed, not running the main script")
|
||||
sys.exit()
|
||||
|
||||
try:
|
||||
from pyrogram import Client, filters, idle # type: ignore
|
||||
from pyrogram.types import ChatPermissions, ReplyKeyboardMarkup, InlineKeyboardMarkup, InlineKeyboardButton, BotCommand, BotCommandScopeChat # type: ignore
|
||||
@ -17,9 +47,6 @@ except ModuleNotFoundError:
|
||||
print(f"Module pyrogram is not installed. Run 'pip3 install -r requirements.txt' and restart the program.", flush=True)
|
||||
sys.exit()
|
||||
|
||||
from modules.logging import logWrite
|
||||
from modules.utils import configGet, jsonLoad, jsonSave
|
||||
|
||||
app = Client("duptsiaposter", bot_token=configGet("bot_token", "bot"), api_id=configGet("api_id", "bot"), api_hash=configGet("api_hash", "bot"))
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user