From cbc87ca3c854fddc6eefb789d50a848327a4dd07 Mon Sep 17 00:00:00 2001 From: 0ceanSlim Date: Mon, 4 Mar 2024 14:27:58 -0500 Subject: [PATCH] obs-test --- obs_action.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/obs_action.py b/obs_action.py index cc99f45..e115793 100644 --- a/obs_action.py +++ b/obs_action.py @@ -50,20 +50,22 @@ async def handle_follow_list(follow_list_event, your_pubkey, obs): scene_name = "Escape From Tarkov" # Replace with the name of your scene await toggle_source_group(obs, scene_name, source_group_name) -# Modify the toggle_source_group function to accept the scene name async def toggle_source_group(obs, scene_name, source_group_name): - # Enable the source group in the specified scene - obs_response_enable = obs.call(requests.SetSceneItemProperties(item=source_group_name, scene=scene_name, visible=True)) - print(f"Enable Response: {obs_response_enable}") + # Get the list of scene items in the specified scene + scene_items = obs.call(requests.GetSceneItemList(sceneName=scene_name)) - # Wait for a certain interval (e.g., 5 seconds) - await asyncio.sleep(5) + # Find the source group item in the list + source_group_item = next((item for item in scene_items.getSceneItems() if item["name"] == source_group_name), None) - # Disable the source group in the specified scene - obs_response_disable = obs.call(requests.SetSceneItemProperties(item=source_group_name, scene=scene_name, visible=False)) - print(f"Disable Response: {obs_response_disable}") - - print(f"Toggled source group '{source_group_name}' in scene '{scene_name}'.") + if source_group_item: + # Enable or disable the visibility of the source group item + obs_response = obs.call( + requests.SetSceneItemProperties(item=source_group_item["name"], scene=scene_name, visible=not source_group_item["visible"]) + ) + print(f"Toggle Response: {obs_response}") + print(f"Toggled source group '{source_group_name}' in scene '{scene_name}'.") + else: + print(f"Source group '{source_group_name}' not found in scene '{scene_name}'.") if __name__ == "__main__": config_path = 'config.json'