diff --git a/CHATTER/login_client.py b/CHATTER/login_client.py index f9289c9..dcc9164 100644 --- a/CHATTER/login_client.py +++ b/CHATTER/login_client.py @@ -11,7 +11,7 @@ script_dir = Path(__file__).parent def login_logic(): while True: print("LOGIN CLIENT") - print("[1] Login [2] Sign in") + print("[1] Login [2] Sign up") login_choice = input(" > ") if login_choice == "1": @@ -30,12 +30,28 @@ def login_logic(): # Get current time (request identifier) timestamp_ms = int(time.time() * 1000) - - # Create a request - with open(script_dir / "requests" / f"{timestamp_ms}.txt", "w") as request: - request.write(f"LOGIN:{login_username}:{login_password}") - # TODO WAIT FOR SUCCESS/UNSUCCESS MESSAGE + # 1. Define your paths clearly + req_folder = script_dir / "requests" + tmp_path = req_folder / f"{timestamp_ms}.tmp" + final_path = req_folder / f"{timestamp_ms}.txt" + + for i in range(3): + try: + # 2. Write to the temporary file + with open(tmp_path, "w") as request: + request.write(f"LOGIN:{login_username}:{login_password}") + + # 3. Rename it to .txt (After the 'with' block finishes) + tmp_path.rename(final_path) + print("Request sent! Please wait...") + while True: + # Waiting logic + break + break + except Exception as e: + print(f"Error in attempt {i+1}: {e}") + if login_choice == "2": while True: @@ -65,9 +81,22 @@ def login_logic(): # Get current time (request identifier) timestamp_ms = int(time.time() * 1000) + + req_folder = script_dir / "requests" + tmp_path = req_folder / f"{timestamp_ms}.tmp" + final_path = req_folder / f"{timestamp_ms}.txt" - with open(script_dir / "requests" / f"{timestamp_ms}.txt", "w") as request: - request.write(f"CREATEUSER:{signup_username}:{signup_password}") + for i in range(3): + try: + with open(tmp_path, "w") as request: + request.write(f"CREATEUSER:{signup_username}:{signup_password}") + + # RENAME FILE!!! + tmp_path.rename(final_path) + print("Account creation request sent!") + break + except Exception as e: + print(f"Error in attempt {i+1}: {e}") # TODO WAIT FOR SUCCESS/UNSUCCESS MESSAGE diff --git a/CHATTER/requests/1775660763462.txt b/CHATTER/requests/1775660763462.txt new file mode 100644 index 0000000..e0875de --- /dev/null +++ b/CHATTER/requests/1775660763462.txt @@ -0,0 +1 @@ +CREATEUSER:JeffreyEpstein:TheIslandIsMine \ No newline at end of file diff --git a/CHATTER/server.py b/CHATTER/server.py index 7d733b4..bbff6c2 100644 --- a/CHATTER/server.py +++ b/CHATTER/server.py @@ -4,6 +4,10 @@ from pathlib import Path # Setup paths base_path = Path(__file__).parent req_path = base_path / "requests" +user_path = base_path / "users" +chat_path = base_path / "single_chats" + + req_path.mkdir(exist_ok=True) print("Server online. Monitoring requests...") @@ -25,7 +29,8 @@ while True: # FAILSAFE 2: Check if the file is empty or missing colons if not content or ":" not in content: - print(f"Malformed request in {file_path.name}. Deleting.") + print(f"Invalid or empty data in {file_path.name}, Deleting.") + # make failed request file file_path.unlink() continue @@ -35,16 +40,33 @@ while True: # FAILSAFE 3: Check if we have enough parts (Command:User:Pass) if len(parts) < 3: - print(f"Incomplete data in {file_path.name}. Deleting.") + print(f"Incomplete data in {file_path.name}, Deleting.") + # TODO Make failed request file file_path.unlink() continue command, user, data = parts + if not command.isalnum() or not user.isalnum() or not data.isalnum(): + print(f"Invalid parameters in {file_path.name}, Deleting.") + # TODO Make failed request file + continue print(f"Processing {command} for {user}...") - # --- YOUR LOGIC GOES HERE --- - # if command == "LOGIN": ... - # if command == "CREATEUSER": ... + if command == "LOGIN": + # TODO + #1. check if user exists as a folder + #2. hash password and check against user hash.txt if exist + #3. Make success request file + #4. Fail file as try/except + pass + if command == "CREATEUSER": + # TODO + #1. Make a new folder with the name + #2. Hash password and store in hash.txt + #3. Init basic files + #4. Make success request file + #5. Fail file as try/except + pass # 4. Clean up: Delete the request after successful processing file_path.unlink() diff --git a/CHATTER/single chats/placeholder.txt b/CHATTER/single_chats/placeholder.txt similarity index 100% rename from CHATTER/single chats/placeholder.txt rename to CHATTER/single_chats/placeholder.txt diff --git a/CHATTER/users/Helen/placeholder.txt b/CHATTER/users/Helen/placeholder.txt index e69de29..3cdb6a5 100644 --- a/CHATTER/users/Helen/placeholder.txt +++ b/CHATTER/users/Helen/placeholder.txt @@ -0,0 +1 @@ +My love don't leave me... but you did. \ No newline at end of file