Modifying function

This commit is contained in:
chabisik 2022-12-24 17:47:21 +01:00
parent 1607eac1c9
commit f9740deada

View file

@ -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,))