Пример #1
0
async def yay(value):
    enable = bool(int(value))
    global yay_active

    source_name = Sources.yay_source
    scene_name = Sources.yay_scene

    if enable:
        if not yay_active:
            # Don't let it run again while already active
            yay_active = True

            # Turn on the Yay source
            obs_client.call(requests.SetSceneItemRender(True, source_name, scene_name))

            # Let it play
            await asyncio.sleep(5)

            # Turn it back off
            obs_client.call(requests.SetSceneItemRender(False, source_name, scene_name))

            # Reset the toggle - Has no effect on the bot, but shows correctly in the server
            mqtt_client.publish("stream/yay-toggle", "0")

            # Sleep for 45 seconds to prevent continuious abuse
            await asyncio.sleep(45)

            yay_active = False
Пример #2
0
 def set_webcam(self, name):
     webcam_scene = self.webcam_scene()
     self.ws.call(
         requests.SetSceneItemRender(name, True, webcam_scene["name"]))
     for cam in self.webcams():
         if cam["name"] != name:
             self.ws.call(
                 requests.SetSceneItemRender(cam["name"], False,
                                             webcam_scene["name"]))
Пример #3
0
 def toggle_source(self, scene, source):
     state = self.ws.call(
         requests.GetSceneItemProperties(item=source,
                                         scene_name=scene)).getVisible()
     print(state)
     self.ws.call(
         requests.SetSceneItemRender(source=source, render=(not state)))
Пример #4
0
async def follow(follower):
    source = "NewFollowScene"
    text_box = "Follower"
    scene = "Common"
    step = 40

    # Turn the source off, just in case it was left on.
    obs_client.call(requests.SetSceneItemRender(False, source, scene_name=scene))

    # Set the follower text
    obs_client.call(requests.SetTextFreetype2Properties(text_box, text=follower))

    await slide_in_from_right(source, scene, step, -1)

    # Turn the source back off
    obs_client.call(requests.SetSceneItemRender(False, source, scene_name=scene))
Пример #5
0
async def slide_in_from_right(source: str, scene: str, step: int, height: int):
    """Slides a OBS Source in from the right side of the display

    Args:
        source (str): Source Name
        scene (str): Scene Name
        step (int): How many steps per iteration to move in
        height (int): Height from the top down, -1 will set it at the bottom.
    """

    # Grab screen output values
    screen_properties = obs_client.call(requests.GetVideoInfo()).datain

    # Values of the source
    item_properties = obs_client.call(requests.GetSceneItemProperties(source, scene_name=scene)).datain

    # Set Starting position to bottom if -1
    if height == -1:
        height = int(screen_properties["baseHeight"] - item_properties["height"]) - 10

    # Send the height, and set off right side of screen
    obs_client.call(
        requests.SetSceneItemPosition(
            source,
            height,
            screen_properties["baseWidth"] + 1,
        )
    )

    # Save how far in to slide
    slide_in_to_x = int(screen_properties["baseWidth"] - item_properties["width"])

    # Turn on the scene
    obs_client.call(requests.SetSceneItemRender(True, source, scene_name=scene))

    # Slide In
    r_from = int(screen_properties["baseWidth"])
    for x in range(r_from, slide_in_to_x, step * -1):
        obs_client.call(requests.SetSceneItemPosition(source, height, x, scene_name=scene))

    # Move to width of item
    obs_client.call(
        requests.SetSceneItemPosition(
            source,
            height,
            slide_in_to_x,
        )
    )

    # Hold the position for a beat
    await asyncio.sleep(2)

    # Slide back out
    for x in range(
        slide_in_to_x,
        int(screen_properties["baseWidth"]) + 2,
        step * 2,
    ):
        obs_client.call(requests.SetSceneItemPosition(source, height, x, scene_name=scene))
Пример #6
0
async def treatbot_cam(value):
    enabled = bool(int(value))
    global treatbot_active

    source_name = Sources.treatbot_cam_source
    scene_name = Sources.treatbot_cam_scene

    obs_client.call(requests.SetSceneItemRender(enabled, source_name, scene_name))

    if enabled:
        treatbot_active = True
        await asyncio.sleep(Settings.treatbot_timeout)
        if treatbot_active:
            print("Hrm.... the treatbot didn't disable the OBS display. Disabling it...")
            obs_client.call(requests.SetSceneItemRender(False, source_name, scene_name))
    else:
        treatbot_active = False
Пример #7
0
def treatbot_cam(payload):
    enabled = bool(int(payload))
    obs_client.call(requests.SetSceneItemRender("TreatBot", enabled, "Common"))