From f9740deadaf225cb0d63f5a290f56c8e078c6c65 Mon Sep 17 00:00:00 2001 From: chabisik Date: Sat, 24 Dec 2022 17:47:21 +0100 Subject: [PATCH] Modifying function --- myapp.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/myapp.py b/myapp.py index a279647..3e96a88 100644 --- a/myapp.py +++ b/myapp.py @@ -142,16 +142,17 @@ def database_setter(): passw = str(input("Enter the password: ")) subprocess.run("echo \"INTERNET_PWD='"+passw+"'\" >> "+database_location+"/config.py", shell=True, executable="/bin/bash") -def users_manager(lck, instruction="ADD", phone_number="000000000", duration=60): +def logic_manager(actuator_lck, database_lck, received_dict): dp = datasaver.DataPockets(filename="database_location_path") database_location = dp.get("database_location")[0] - dp = datasaver.DataPockets(filename="database", directory_path=database_location) - if instruction=="ADD" and (phone_number_to_long_format(phone_number) in dp.get("admins") or phone_number_to_long_format(phone_number) in dp.get("upgraded_to_admins")): - dp.append_as_it(pocket_name="guests", what_to_append=phone_number) - elif instruction=="REMOVE": - pass - elif instruction=="UPGRADE": - pass + with database_lck: + dp = datasaver.DataPockets(filename="database", directory_path=database_location) + if instruction=="ADD" and (phone_number_to_long_format(phone_number) in dp.get("admins") or phone_number_to_long_format(phone_number) in dp.get("upgraded_to_admins")): + dp.append_as_it(pocket_name="guests", what_to_append=phone_number) + elif instruction=="REMOVE": + pass + elif instruction=="UPGRADE": + pass def phone_number_to_long_format(number="0000000000"): if len(number)==12 and number[0]=="+": @@ -232,6 +233,7 @@ def receiver(): response_events = {"events":[]} #---action=incoming--- if "action" in data_dict and data_dict["action"]=="incoming": + logic_manager(actuator_lck=actuator_locker, database_lck=database_locker, received_dict=data_dict) for keyword in config.KEYWORDS: if keyword in data_dict["message"].lower(): op = threading.Thread(target=opener, args=(actuator_locker,))