2024-07-03 22:03:48 +05:30
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
# BB_plus_watch_temp_files.py
|
|
|
|
#
|
|
|
|
# Watch for any new files created by Baldi's Basics Plus
|
|
|
|
#
|
|
|
|
# The video game Baldi's Basics Plus is created by Basically Games
|
|
|
|
#
|
|
|
|
# Author: Intel A80486DX2-66
|
|
|
|
# License: Unlicense
|
|
|
|
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
from os import environ, listdir, makedirs
|
|
|
|
from os.path import exists, join as path_join
|
|
|
|
from subprocess import Popen
|
|
|
|
from tempfile import gettempdir
|
|
|
|
from time import sleep
|
|
|
|
from sys import exit
|
|
|
|
|
|
|
|
if exists(".env"):
|
|
|
|
load_dotenv()
|
|
|
|
|
2024-07-03 22:20:58 +05:30
|
|
|
EXEC_KEY = "BALDI_PLUS_EXECUTABLE_PATH"
|
|
|
|
EXEC_PATH = environ.get(EXEC_KEY, None)
|
2024-07-03 22:03:48 +05:30
|
|
|
|
|
|
|
PATH_TO_WATCH = path_join(gettempdir(),
|
|
|
|
"Basically Games", "Baldi's Basics Plus")
|
|
|
|
|
|
|
|
def respectful_makedirs(path: str) -> None:
|
|
|
|
if not exists(path):
|
|
|
|
makedirs(path)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if EXEC_PATH is None:
|
2024-07-03 22:20:58 +05:30
|
|
|
print( "Please create a .env file in the current directory with key "
|
|
|
|
f"{EXEC_KEY}, containing path to the executable of your copy of "
|
|
|
|
"the video game Baldi's Basics Plus, or set such an "
|
2024-07-03 22:23:03 +05:30
|
|
|
"environmental variable.")
|
2024-07-03 22:03:48 +05:30
|
|
|
exit(1)
|
|
|
|
|
|
|
|
print("Path to watch:", PATH_TO_WATCH)
|
|
|
|
respectful_makedirs(PATH_TO_WATCH)
|
|
|
|
|
|
|
|
print("Starting the game", flush=True)
|
|
|
|
handle = Popen([EXEC_PATH])
|
|
|
|
|
|
|
|
print("Watching directory")
|
|
|
|
files = set(listdir(PATH_TO_WATCH))
|
|
|
|
while handle.poll() is None:
|
|
|
|
sleep(1)
|
|
|
|
new_files = set(listdir(PATH_TO_WATCH)) - files
|
|
|
|
if new_files:
|
|
|
|
for f in new_files:
|
|
|
|
print("[+]", f)
|
|
|
|
files |= new_files
|