Kruiser8 / Kruiz-Control

Kruiz Control enables a pseudo code approach to manage and automatically handle Twitch Channel Points, Twitch Chat, OBS or SLOBS, and StreamElements or Streamlabs alerts.
Other
231 stars 32 forks source link

Check OBS connection and reset #60

Closed Epyxx closed 1 year ago

Epyxx commented 1 year ago

Hey, is there a way to check the OBS connection status on command?

For example something like this:

OnCommand bm 0 !check
If OBSConnected = true
Chat Send "Connected to websocket"
Else
Chat Send "Not connected to websocket"

Or alternative output an connection error at OnInit event?

For Example:

OnInit
If OBSConnected = false
Chat Send "Websocket connection error"

Thanks!

Kruiser8 commented 1 year ago

Hey Epyx,

It's possible to check if it was connected on start up. It's not possible to check active connection status without making a call. OBS Version is probably the easiest one to run, however I think that throws an error and doesn't continue when there's an issue.

To check if it was connected on start up:

OnCommand mb 0 !check
Param Keyword _successful_ obs
if 2 {matched} == true
Chat Send "Websocket was connected"
Exit
Chat Send "Websocket connection error"
Epyxx commented 1 year ago

Thanks! i think this command should be enough for my case. But i copied your lines of code and tried it but i get no message at all. neiher "Websocket was connected" nor "Websocket connection error" :(

Kruiser8 commented 1 year ago

Huh, I tried it and it worked. However, I noticed a quirk with Param Keyword that you'll have to add a workaround for:

OnCommand mb 0 !check
Param Keyword _successful_ obs,
if 2 {matched} == true
Chat Send "Websocket was connected"
Exit
Param Keyword _successful_ obs
if 2 {matched} == true
Chat Send "Websocket was connected"
Exit
Chat Send "Websocket connection error"

OnCommand mb 0 !check
OBS Version
Chat Send "Version: {version}"

In the next update, I'll make it so OBS Version returns Disconnected in the event that it isn't connected. That should fit your use case. That will look like:

OnCommand mb 0 !check
OBS Version
If 2 {version} == "Disconnected"
Chat Send "Websocket connection error"
Exit
Chat Send "Websocket was connected"
Epyxx commented 1 year ago

It now works for me, thanks!

Oh yeah, a live check with obs version would be awesome!

Kruiser8 commented 1 year ago

This is added in the upcoming release.