Changed bot "mode" behavior

This commit is contained in:
2022-08-30 14:10:05 +02:00
parent 5848bca40a
commit 6e1de38da0
4 changed files with 16 additions and 11 deletions

View File

@@ -206,13 +206,13 @@ def send_content():
# Check last posts forwards
# check_forwards(app)
if configGet("mode") in ["both", "submit"]:
if configGet("submit", "mode"):
@app.on_message(~ filters.scheduled & filters.command(["start"], prefixes="/"))
def cmd_start(app, msg):
if msg.from_user.id not in jsonLoad(configGet("blocked", "locations")):
msg.reply_text(locale("start", "message", locale=msg.from_user.language_code))
if configGet("mode") in ["both", "submit"]:
if configGet("submit", "mode"):
@app.on_message(~ filters.scheduled & filters.command(["rules", "help"], prefixes="/"))
def cmd_rules(app, msg):
if msg.from_user.id not in jsonLoad(configGet("blocked", "locations")):
@@ -263,7 +263,7 @@ def subUnblock(user):
blocked.remove(user)
jsonSave(blocked, configGet("blocked", "locations"))
if configGet("mode") in ["both", "submit"]:
if configGet("submit", "mode"):
@app.on_message(~ filters.scheduled & filters.photo | filters.video | filters.animation | filters.document)
def get_submission(_, msg):
try:
@@ -396,8 +396,8 @@ def callback_query_unblock(app, clb): # type: ignore
# # else:
# # logWrite(f"Got raw update of type {type(update)} with contents {update}", debug=True)
if configGet("mode") in ["both", "post"]:
if configGet("post", "mode"):
for entry in configGet("time", "posting"):
schedule.every().day.at(entry).do(send_content)
@@ -425,11 +425,11 @@ if __name__ == "__main__":
if configGet("startup", "reports"):
app.send_message(configGet("admin"), locale("startup", "message", locale=configGet("locale")).format(str(pid))) # type: ignore
if configGet("mode") in ["both", "post"]:
if configGet("post", "mode"):
t = Thread(target=background_task)
t.start()
if configGet("mode") in ["both", "submit"]:
if configGet("submit", "mode"):
# Registering user commands
for entry in os.listdir(configGet("locale", "locations")):
if entry.endswith(".json"):
@@ -446,7 +446,7 @@ if __name__ == "__main__":
# Registering admin commands
commands_admin_list = []
if configGet("mode") in ["both", "submit"]:
if configGet("submit", "mode"):
for command in configGet("commands"):
commands_admin_list.append(BotCommand(command, locale(command, "commands", locale=configGet("locale"))))
for command in configGet("commands_admin"):