Exemplo n.º 1
0
async def handle_join_new_server(crash=False):
    CFG.crashed = True  # Just in case
    process_name = "Automatic Relocation System"
    action = "Detected more optimal server. Relocating."
    if crash:
        process_name = "Automatic Crash Recovery"
        action = "Detected Roblox Crash. Recovering."
    log_process(process_name)
    log(action)
    kill_process(force=True)
    server_id = await force_get_best_server()
    await async_sleep(1)

    log_process(f"{process_name} - Joining Server")
    success = await join_target_server(server_id)
    if not success:
        return False
    output_log("change_server_status_text", "")

    log_process(f"{process_name} - Handling Spawn")
    if not await server_spawn():
        return False

    log_process("")
    log("Complete. Please use '!dev Error' if we're not in-game.")
    await async_sleep(5)
    CFG.crashed = False
    log_process("")
    log("")
Exemplo n.º 2
0
def test_loading_cookies_for_browser():
    import json

    from selenium import webdriver

    print(
        "If you completed test_get_cookies_for_browser, this should open a logged-in browser."
    )
    print(
        "Press enter to start, and press enter again to terminate the browser."
    )
    input()

    with open(CFG.browser_cookies_path, "r", encoding="utf-8") as f:
        cookies = json.load(f)

    options = webdriver.ChromeOptions()
    options.add_argument(f"--user-data-dir={CFG.browser_profile_path}")
    driver = webdriver.Chrome(options=options,
                              executable_path=CFG.browser_driver_path)
    driver.get(CFG.game_instances_url)

    for cookie in cookies:
        try:
            driver.add_cookie(cookie)
        except Exception:
            print(f"ERROR ADDING COOKIE: \n{cookie}\n")
    driver.refresh()
    script = """Roblox.GameLauncher.joinGameInstance(6238705697, "099cf062-e26f-4ace-b627-6ebfa2295270")"""
    driver.execute_script(script)
    input("\n\n\nPress Enter to close\n\n\n\n")
    driver.quit()

    kill_process(CFG.browser_driver_executable_name)
    kill_process(CFG.browser_executable_name)
Exemplo n.º 3
0
def test_get_cookies_for_browser():
    import json

    from selenium import webdriver

    print(
        "Login to your account in the brower that opens, come back to this screen, and press enter."
    )
    print("Press enter to start")
    input()

    driver = webdriver.Chrome(CFG.browser_driver_path)
    driver.get("https://www.roblox.com/games/6238705697/Become-Fumo")

    input("\n\n\nPress Enter to save cookies\n\n\n\n")

    with open(CFG.browser_cookies_path, "w", encoding="utf-8") as f:
        json.dump(driver.get_cookies(), f, ensure_ascii=False, indent=4)
    driver.quit()
    kill_process(CFG.browser_driver_executable_name)
    kill_process(CFG.browser_executable_name)

    print(
        f"\n\n\nCookies saved to {CFG.browser_cookies_path}, DO NOT SHARE THIS WITH ANYONE."
    )
    input("\nPress Enter to close.")
Exemplo n.º 4
0
async def open_roblox_with_selenium_browser(js_code: str) -> bool:
    log("Opening Roblox via Browser...")
    try:
        with open(CFG.browser_cookies_path, "r", encoding="utf-8") as f:
            cookies = json.load(f)
    except FileNotFoundError:
        print("COOKIES PATH NOT FOUND, INITIALIZE WITH TEST FIRST")
        log("")
        return False

    options = webdriver.ChromeOptions()
    options.add_argument(f"--user-data-dir={CFG.browser_profile_path}")
    driver = webdriver.Chrome(options=options,
                              executable_path=str(CFG.browser_driver_path))
    driver.get(CFG.game_instances_url)

    for cookie in cookies:
        try:
            driver.add_cookie(cookie)
        except Exception:
            print(f"ERROR ADDING COOKIE: \n{cookie}\n")

    driver.refresh()
    driver.execute_script(js_code)

    sleep_time = 0.25
    success = False
    log("Verifying Roblox has opened...")
    for _ in range(int(CFG.max_seconds_browser_launch / sleep_time)):
        crashed = await do_crash_check(do_notify=False)
        active = is_process_running(CFG.game_executable_name)
        if not crashed and active:
            success = True
            break
        await async_sleep(sleep_time)
    try:
        driver.quit()
        kill_process(CFG.browser_driver_executable_name)
        kill_process(CFG.browser_executable_name)
    except Exception:
        print(format_exc())

    if not success:
        log("Failed to launch game. Notifying Dev...")
        notify_admin("Failed to launch game")
        await async_sleep(5)
        log("")
        return False
    log("")
    return True
Exemplo n.º 5
0
    async def test():
        total_diffs = []
        print(
            "This will use log in to the least popular server in an attempt to get your token.\n"
            "If someone else joins before you do, it will be impossible to tell, so the program will retry.\n"
            "It's recommended to run this 2 or 3 times to make sure we deduced the right token."
        )
        input("Press enter to begin.")

        while True:
            server_before_join = await get_best_server(get_worst=True)
            print(server_before_join)
            print(f"[DEBUG] BEFORE:\n{server_before_join['playerTokens']}\n")
            await join_target_server(server_before_join["id"])
            game_loaded = await check_if_game_loaded()
            if not game_loaded:
                raise Exception("Could not load into game!")
            await async_sleep(1)
            server_after_join = await get_best_server(get_worst=True)

            if server_after_join["id"] != server_before_join["id"]:
                print("Ideal servers became different, retrying...")
                total_diffs = []
            else:
                print(f"[DEBUG] AFTER:\n{server_after_join['playerTokens']}\n")
                current_diffs = []
                for id in server_after_join["playerTokens"]:
                    if id not in server_before_join["playerTokens"]:
                        current_diffs.append(id)

                for id in total_diffs:
                    if id not in current_diffs:
                        total_diffs.remove(id)
                    else:
                        current_diffs.remove(id)

                total_diffs = current_diffs

            kill_process(force=True)
            print(f"[DEBUG] Diffs: {total_diffs}")
            if len(total_diffs) == 1:
                break
            wait_time = 20
            print(
                f"[DEBUG] Waiting {wait_time}s to avoid ratelimit/inaccuracy..."
            )
            await async_sleep(wait_time)

        print(f'\n\n\n\n\nYOUR ID IS: "{total_diffs[0]}"')
Exemplo n.º 6
0
async def mute_toggle(set_mute: Union[bool, None] = None):
    log_process("In-game Mute")
    desired_mute_state = not CFG.audio_muted
    if set_mute is not None:  # If specified, force to state
        desired_mute_state = set_mute
    desired_volume = 0 if desired_mute_state else 100
    log_msg = "Muting" if desired_mute_state else "Un-muting"
    log(log_msg)
    sc_exe_path = str(CFG.resources_path / CFG.sound_control_executable_name)
    os.system(  # nosec
        f'{sc_exe_path} /SetVolume "{CFG.game_executable_name}" {desired_volume}'
    )

    # Kill the process no matter what, race condition for this is two songs playing (bad)
    kill_process(executable=CFG.vlc_executable_name, force=True)

    if desired_mute_state:  # Start playing music
        copyfile(
            CFG.resources_path / OBS.muted_icon_name,
            OBS.output_folder / OBS.muted_icon_name,
        )
        vlc_exe_path = str(CFG.vlc_path / CFG.vlc_executable_name)
        music_folder = str(CFG.resources_path / "soundtracks" / "overworld")
        Popen(
            f'"{vlc_exe_path}" --playlist-autostart --loop --playlist-tree {music_folder}'
        )
        output_log("muted_status", "In-game audio muted!\nRun !mute to unmute")
        sleep(5)  # Give it time to load VLC
    else:  # Stop playing music
        try:
            if os.path.exists(OBS.output_folder / OBS.muted_icon_name):
                os.remove(OBS.output_folder / OBS.muted_icon_name)
        except OSError:
            log("Error, could not remove icon!\nNotifying admin...")
            async_sleep(2)
            notify_admin("Mute icon could not be removed")
            log(log_msg)
        output_log("muted_status", "")
    CFG.audio_muted = desired_mute_state

    await check_active()
    log_process("")
    log("")