diff --git a/AutismBotIngame/python/ingamefollowct.py b/AutismBotIngame/python/ingamefollowct.py index fa345ab..a1e9ac8 100644 --- a/AutismBotIngame/python/ingamefollowct.py +++ b/AutismBotIngame/python/ingamefollowct.py @@ -14,7 +14,6 @@ import datetime import time import glob -call_bot_connect = True restart_time = datetime.datetime.now() + datetime.timedelta(hours=5) whoami = subprocess.getoutput(["whoami"]) @@ -49,14 +48,30 @@ def clean_up_files(): #due to steam child processes. #even with steam turned offline might there be chromium web browsers left over from steam who still hold processes open. #only kind of potential issues from this is steam cloud being out of sync, which is really fucking irrelevant. - subprocess.Popen(["rm -rf /tmp/steam*"], shell=True, stdout=subprocess.DEVNULL).communicate()[0] - subprocess.Popen(["rm -rf /tmp/dbus*"], shell=True, stdout=subprocess.DEVNULL).communicate()[0] - subprocess.Popen(["rm -rf /tmp/pressure*"], shell=True, stdout=subprocess.DEVNULL).communicate()[0] - subprocess.Popen(["rm -rf /tmp/tigervnc*"], shell=True, stdout=subprocess.DEVNULL).communicate()[0] - subprocess.Popen(["rm -rf /tmp/dumps*"], shell=True, stdout=subprocess.DEVNULL).communicate()[0] - subprocess.Popen(["rm -rf /dev/shm/u100*"], shell=True, stdout=subprocess.DEVNULL).communicate()[0] + subprocess.Popen(["rm -rf /tmp/steam*"], shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).communicate()[0] + subprocess.Popen(["rm -rf /tmp/dbus*"], shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).communicate()[0] + subprocess.Popen(["rm -rf /tmp/pressure*"], shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).communicate()[0] + subprocess.Popen(["rm -rf /tmp/tigervnc*"], shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).communicate()[0] + subprocess.Popen(["rm -rf /tmp/dumps*"], shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).communicate()[0] + subprocess.Popen(["rm -rf /dev/shm/u100*"], shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).communicate()[0] #users should only have permissions to delete their own files probably + #check if any bz2 files left over. + for f in glob.glob(f"/home/{whoami}/.steam/steam/steamapps/common/Counter-Strike Source/cstrike/download/**/*.bz2", recursive=True): + file_size = None + while True: + time.sleep(10) + stdout, stderr = subprocess.Popen(["ls", "-l", f], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() + if stderr: break #finished downloading, bz2 file is removed. + if stdout: + cur_file_size = stdout.decode().split("autismbots")[1].strip().split(" ")[0] + if file_size == cur_file_size: + #delete the bz2 file if its not progressing downloading + subprocess.Popen(["rm", f], stdout=subprocess.DEVNULL).communicate()[0] + break + file_size = cur_file_size + + def exit_handler(): print('reached exithandler') writeCfgInput('') @@ -167,9 +182,6 @@ def delete_lock_file(): subprocess.Popen(["rm -f /tmp/source_engine*.lock"], shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).communicate()[0] def my_file_created_function(event_path): - global call_bot_connect - call_bot_connect = False - #print(f"New file created: {event_path}") if not event_path.lower().endswith(".bsp.bz2"): return @@ -197,11 +209,10 @@ def my_file_created_function(event_path): if file_size == cur_file_size: print("Aborting connection. file download is stuck.") writeCfgInput("disconnect;") + subprocess.Popen(["rm", event_path], stdout=subprocess.DEVNULL).communicate()[0] break file_size = cur_file_size - call_bot_connect = True - class NewFileHandler(FileSystemEventHandler): def on_created(self, event): my_file_created_function(event.src_path) @@ -287,7 +298,6 @@ if __name__ == '__main__': elif "autismo connected to ze" == data: print('Bot connected to ze!') cpulimit_pid_of_game() - call_bot_connect = True is_bot_connected_to_ze2 = False overwrite_file_access() elif "not connected to ze2" == data: @@ -295,7 +305,6 @@ if __name__ == '__main__': elif "autismo connected to ze2" == data: print('Bot connected to ze2!') cpulimit_pid_of_game() - call_bot_connect = True is_bot_connected_to_ze2 = True overwrite_file_access() elif "connect to ze" == data or ("connect to ze2" == data and not is_bot_connected_to_ze2): @@ -306,13 +315,10 @@ if __name__ == '__main__': print('exiting after running the game for several hours.') sys.exit(1) else: - if call_bot_connect: - #stop cpu limitting, its bottlenecking the connection to the server. - kill_owned_process("pidof cpulimit") - - print('data: ', data) - call_bot_connect = False - bot_connect(data) + #stop cpu limitting, its bottlenecking the connection to the server. + kill_owned_process("pidof cpulimit") + #print('data: ', data) + bot_connect(data) elif "clientmessage:" in data: messager_name = data.split("clientmessage:", 1)[1].split(f" {data_ports['magic_secret']}")[0] databyte_send_message = messager_name + data.split(f"{data_ports['magic_secret']}")[1] diff --git a/AutismBotIngame/scripting/autism_bot_info.sp b/AutismBotIngame/scripting/autism_bot_info.sp index eafb1fd..f7286a1 100755 --- a/AutismBotIngame/scripting/autism_bot_info.sp +++ b/AutismBotIngame/scripting/autism_bot_info.sp @@ -103,7 +103,7 @@ public void OnPluginStart() connect_socket(); chat_cooldown = false; - g_hTimer_bot_connect = CreateTimer(15.0, bot_check_connect, _, TIMER_REPEAT); + g_hTimer_bot_connect = CreateTimer(30.0, bot_check_connect, _, TIMER_REPEAT); g_hTimer_pressing = CreateTimer(0.30, recursive_pressing, _, TIMER_REPEAT); } @@ -554,8 +554,6 @@ public Action bot_check_connect(Handle timer, any data) return Plugin_Continue; } - - public Action recursive_pressing(Handle timer, any data) { bool found_valid_ct = false;