Admin config path changed

This commit is contained in:
Profitroll 2022-08-11 10:24:57 +02:00
parent d1f2401f51
commit 673ecaaab9
2 changed files with 13 additions and 13 deletions

View File

@ -2,13 +2,13 @@
"module": null, "module": null,
"locale": "en", "locale": "en",
"locale_fallback": "en", "locale_fallback": "en",
"admin": 0,
"bot": { "bot": {
"api_id": 0, "api_id": 0,
"api_hash": "", "api_hash": "",
"bot_token": "" "bot_token": ""
}, },
"reports": { "reports": {
"admin": 0,
"sent": false, "sent": false,
"error": true, "error": true,
"startup": true, "startup": true,

24
main.py
View File

@ -109,7 +109,7 @@ def send_content():
else: else:
logWrite(locale("post_empty", "console", locale=configGet("locale"))) logWrite(locale("post_empty", "console", locale=configGet("locale")))
if configGet("error", "reports"): if configGet("error", "reports"):
app.send_message(configGet("admin", "reports"), locale("post_empty", "message", locale=configGet("locale"))) # type: ignore app.send_message(configGet("admin"), locale("post_empty", "message", locale=configGet("locale"))) # type: ignore
return return
index = jsonLoad(configGet("index", "locations")) index = jsonLoad(configGet("index", "locations"))
@ -154,14 +154,14 @@ def send_content():
shutil.move(candidate, configGet("sent", "locations")+os.sep+candidate_file) shutil.move(candidate, configGet("sent", "locations")+os.sep+candidate_file)
if configGet("sent", "reports"): if configGet("sent", "reports"):
app.send_message(configGet("admin", "reports"), f"Posted `{candidate_file}`", disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup([ app.send_message(configGet("admin"), f"Posted `{candidate_file}`", disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup([
[InlineKeyboardButton("View in channel", url=sent.link)] # type: ignore [InlineKeyboardButton("View in channel", url=sent.link)] # type: ignore
])) # type: ignore ])) # type: ignore
except Exception as exp: except Exception as exp:
logWrite(f"Could not send content due to {exp}\nTraceback: {traceback.format_exc()}") logWrite(f"Could not send content due to {exp}\nTraceback: {traceback.format_exc()}")
if configGet("error", "reports"): if configGet("error", "reports"):
app.send_message(configGet("admin", "reports"), locale("post_exception", "message", locale=configGet("locale")).format(exp, traceback.format_exc())) # type: ignore app.send_message(configGet("admin"), locale("post_exception", "message", locale=configGet("locale")).format(exp, traceback.format_exc())) # type: ignore
@app.on_message(~ filters.scheduled & filters.command(["start"], prefixes="/")) @app.on_message(~ filters.scheduled & filters.command(["start"], prefixes="/"))
@ -177,7 +177,7 @@ def start(app, msg):
@app.on_message(~ filters.scheduled & filters.command(["kill", "die", "reboot"], prefixes=["", "/"])) @app.on_message(~ filters.scheduled & filters.command(["kill", "die", "reboot"], prefixes=["", "/"]))
def kill(app, msg): def kill(app, msg):
if msg.from_user.id == configGet("admin", "reports"): if msg.from_user.id == configGet("admin"):
msg.reply_text(locale("shutdown", "message", locale=configGet("locale")).format(str(pid))) msg.reply_text(locale("shutdown", "message", locale=configGet("locale")).format(str(pid)))
killProc(pid) killProc(pid)
@ -189,7 +189,7 @@ def subLimit(user):
jsonSave(submit, configGet("submit", "locations")) jsonSave(submit, configGet("submit", "locations"))
def subLimited(user): def subLimited(user):
if user.id == configGet("admin", "reports"): if user.id == configGet("admin"):
return False return False
else: else:
submit = jsonLoad(configGet("submit", "locations")) submit = jsonLoad(configGet("submit", "locations"))
@ -255,9 +255,9 @@ def get_submission(_, msg):
if msg.from_user.phone_number != None: if msg.from_user.phone_number != None:
caption += f" ({msg.from_user.phone_number})" caption += f" ({msg.from_user.phone_number})"
msg.copy(configGet("admin", "reports"), caption=caption, reply_markup=InlineKeyboardMarkup(buttons)) msg.copy(configGet("admin"), caption=caption, reply_markup=InlineKeyboardMarkup(buttons))
if msg.from_user.id != configGet("admin", "reports"): if msg.from_user.id != configGet("admin"):
buttons += [ buttons += [
[ [
InlineKeyboardButton(text=locale("sub_block", "button", locale=configGet("locale")), callback_data=f"sub_block_{msg.from_user.id}") InlineKeyboardButton(text=locale("sub_block", "button", locale=configGet("locale")), callback_data=f"sub_block_{msg.from_user.id}")
@ -269,7 +269,7 @@ def get_submission(_, msg):
msg.reply_text(locale("sub_sent", "message", locale=user_locale), quote=True) msg.reply_text(locale("sub_sent", "message", locale=user_locale), quote=True)
subLimit(msg.from_user) subLimit(msg.from_user)
else: else:
msg.reply_text(locale("sub_cooldown", "message", locale=user_locale).format(str(configGet("timeout", "submission")))) msg.reply_text(locale("sub_cooldown", "message", locale=user_locale).format(str(configGet("timeout", "submission"))))
@ -341,7 +341,7 @@ def background_task():
except KeyboardInterrupt: except KeyboardInterrupt:
logWrite(locale("keyboard_interrupt", "console", locale=configGet("locale"))) logWrite(locale("keyboard_interrupt", "console", locale=configGet("locale")))
if configGet("shutdown", "reports"): if configGet("shutdown", "reports"):
app.send_message(configGet("admin", "reports"), locale("shutdown", "message", locale=configGet("locale")).format(str(pid))) # type: ignore app.send_message(configGet("admin"), locale("shutdown", "message", locale=configGet("locale")).format(str(pid))) # type: ignore
killProc(pid) killProc(pid)
if __name__ == "__main__": if __name__ == "__main__":
@ -350,7 +350,7 @@ if __name__ == "__main__":
app.start() # type: ignore app.start() # type: ignore
if configGet("startup", "reports"): if configGet("startup", "reports"):
app.send_message(configGet("admin", "reports"), locale("startup", "message", locale=configGet("locale")).format(str(pid))) # type: ignore app.send_message(configGet("admin"), locale("startup", "message", locale=configGet("locale")).format(str(pid))) # type: ignore
t = Thread(target=background_task) t = Thread(target=background_task)
t.start() t.start()
@ -370,11 +370,11 @@ if __name__ == "__main__":
app.set_bot_commands([ # type: ignore app.set_bot_commands([ # type: ignore
BotCommand("reboot", locale("reboot", "commands_admin", locale=configGet("locale"))), BotCommand("reboot", locale("reboot", "commands_admin", locale=configGet("locale"))),
], ],
scope=BotCommandScopeChat(chat_id=configGet("admin", "reports"))) scope=BotCommandScopeChat(chat_id=configGet("admin")))
idle() idle()
app.send_message(configGet("admin", "reports"), locale("shutdown", "message", locale=configGet("locale")).format(str(pid))) # type: ignore app.send_message(configGet("admin"), locale("shutdown", "message", locale=configGet("locale")).format(str(pid))) # type: ignore
logWrite(locale("shutdown", "console", locale=configGet("locale")).format(str(pid))) logWrite(locale("shutdown", "console", locale=configGet("locale")).format(str(pid)))
killProc(pid) killProc(pid)