Modifying function
This commit is contained in:
parent
1607eac1c9
commit
f9740deada
1 changed files with 10 additions and 8 deletions
18
myapp.py
18
myapp.py
|
@ -142,16 +142,17 @@ def database_setter():
|
||||||
passw = str(input("Enter the password: "))
|
passw = str(input("Enter the password: "))
|
||||||
subprocess.run("echo \"INTERNET_PWD='"+passw+"'\" >> "+database_location+"/config.py", shell=True, executable="/bin/bash")
|
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")
|
dp = datasaver.DataPockets(filename="database_location_path")
|
||||||
database_location = dp.get("database_location")[0]
|
database_location = dp.get("database_location")[0]
|
||||||
dp = datasaver.DataPockets(filename="database", directory_path=database_location)
|
with database_lck:
|
||||||
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 = datasaver.DataPockets(filename="database", directory_path=database_location)
|
||||||
dp.append_as_it(pocket_name="guests", what_to_append=phone_number)
|
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")):
|
||||||
elif instruction=="REMOVE":
|
dp.append_as_it(pocket_name="guests", what_to_append=phone_number)
|
||||||
pass
|
elif instruction=="REMOVE":
|
||||||
elif instruction=="UPGRADE":
|
pass
|
||||||
pass
|
elif instruction=="UPGRADE":
|
||||||
|
pass
|
||||||
|
|
||||||
def phone_number_to_long_format(number="0000000000"):
|
def phone_number_to_long_format(number="0000000000"):
|
||||||
if len(number)==12 and number[0]=="+":
|
if len(number)==12 and number[0]=="+":
|
||||||
|
@ -232,6 +233,7 @@ def receiver():
|
||||||
response_events = {"events":[]}
|
response_events = {"events":[]}
|
||||||
#---action=incoming---
|
#---action=incoming---
|
||||||
if "action" in data_dict and data_dict["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:
|
for keyword in config.KEYWORDS:
|
||||||
if keyword in data_dict["message"].lower():
|
if keyword in data_dict["message"].lower():
|
||||||
op = threading.Thread(target=opener, args=(actuator_locker,))
|
op = threading.Thread(target=opener, args=(actuator_locker,))
|
||||||
|
|
Loading…
Reference in a new issue