From 673ecaaab98eba474f313b3419d2e07f92bbf7dd Mon Sep 17 00:00:00 2001 From: profitroll Date: Thu, 11 Aug 2022 10:24:57 +0200 Subject: [PATCH] Admin config path changed --- config.json | 2 +- main.py | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/config.json b/config.json index d9ad106..bcbbdfc 100644 --- a/config.json +++ b/config.json @@ -2,13 +2,13 @@ "module": null, "locale": "en", "locale_fallback": "en", + "admin": 0, "bot": { "api_id": 0, "api_hash": "", "bot_token": "" }, "reports": { - "admin": 0, "sent": false, "error": true, "startup": true, diff --git a/main.py b/main.py index 18a1703..855dbc8 100644 --- a/main.py +++ b/main.py @@ -109,7 +109,7 @@ def send_content(): else: logWrite(locale("post_empty", "console", locale=configGet("locale"))) 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 index = jsonLoad(configGet("index", "locations")) @@ -154,14 +154,14 @@ def send_content(): shutil.move(candidate, configGet("sent", "locations")+os.sep+candidate_file) 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 ])) # type: ignore except Exception as exp: logWrite(f"Could not send content due to {exp}\nTraceback: {traceback.format_exc()}") 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="/")) @@ -177,7 +177,7 @@ def start(app, msg): @app.on_message(~ filters.scheduled & filters.command(["kill", "die", "reboot"], prefixes=["", "/"])) 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))) killProc(pid) @@ -189,7 +189,7 @@ def subLimit(user): jsonSave(submit, configGet("submit", "locations")) def subLimited(user): - if user.id == configGet("admin", "reports"): + if user.id == configGet("admin"): return False else: submit = jsonLoad(configGet("submit", "locations")) @@ -255,9 +255,9 @@ def get_submission(_, msg): if msg.from_user.phone_number != None: 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 += [ [ 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) subLimit(msg.from_user) - + else: msg.reply_text(locale("sub_cooldown", "message", locale=user_locale).format(str(configGet("timeout", "submission")))) @@ -341,7 +341,7 @@ def background_task(): except KeyboardInterrupt: logWrite(locale("keyboard_interrupt", "console", locale=configGet("locale"))) 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) if __name__ == "__main__": @@ -350,7 +350,7 @@ if __name__ == "__main__": app.start() # type: ignore 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.start() @@ -370,11 +370,11 @@ if __name__ == "__main__": app.set_bot_commands([ # type: ignore BotCommand("reboot", locale("reboot", "commands_admin", locale=configGet("locale"))), ], - scope=BotCommandScopeChat(chat_id=configGet("admin", "reports"))) + scope=BotCommandScopeChat(chat_id=configGet("admin"))) 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))) killProc(pid) \ No newline at end of file