Closed Destroy666x closed 1 year ago
I implemented support for the Twitch event subscription system and a first version of the Twitch condition type in the linked PR. It seems to be working as far as I can tell, although I have only performed very limited testing.
A build will be available here in a few minutes (hopefully): https://github.com/WarmUpTill/SceneSwitcher/actions/runs/6443774636?pr=892
Let me know what you think / if you think anything is missing!
Great! I'll test it today. Something feels off at the first sight, though. I think it may have compiled without Twitch @WarmUpTill
Yep, pretty much: https://github.com/WarmUpTill/SceneSwitcher/actions/runs/6443774636/job/17496088377?pr=892#step:8:544 The CI can't detect OpenSSL 3
Arg ... I reverted the version 3 requirement and started a new build. Hope that one will work better: https://github.com/WarmUpTill/SceneSwitcher/actions/runs/6444401177/job/17497354618
First thoughts - no idea which ones use polling and which events without looking at source code. Some timer setting would be nice for the polling ones to not poll too frequently. Or perhaps even separating the polling and event ones into separate conditions as they're quite different mechanically. Looks to be quite often as of now.
Also got a crash (or endless hang rather) when I selected "Started a watchparty". No crash log, not much in logs either: 2023-10-08 03-18-59.txt Then I crashed again when selecting "Went live". Both worked fine when selected later again.
Noticed some glitching OBS windows appearing when switching to macros with multiple Twitch actions.
These limitations apply, right? https://dev.twitch.tv/docs/eventsub/manage-subscriptions/#subscription-limits If so, would be nice to include the costs of each specific subscription and the total allowed cost somewhere, to avoid user confusion. Unless the initial number is big, no idea, the documentation states some 10
at the bottom, it's not documented too well and specific.
Otherwise - looks nice! I'll test the stability and output (which seems to be always empty with the polling "is live" condition) live with some macros tomorrow.
Ok, result worked with "channel info update" one after one more quick test:
It's not too readable in that box though :P Can't access everything even, as the scroll bar is fake. Could perhaps turn it into TextEdit with expanding height or something?
And last note for today - the note above about separating both is more important than I thought as some of conditions could be easily made using both mechanics. For example "TItle matches" - IIRC it uses polling now, but it'd be IMO more efficient as event, so that the checks are only done when the title changes.
These limitations apply, right? https://dev.twitch.tv/docs/eventsub/manage-subscriptions/#subscription-limits If so, would be nice to include the costs of each specific subscription and the total allowed cost somewhere, to avoid user confusion. Unless the initial number is big, no idea, the documentation states some 10 at the bottom, it's not documented too well and specific.
I hoped that we can skip that part because we are using OAuth tokens:
There is no cost for subscriptions that require a user to authorize your application (e.g., channel.subscribe).
There is a cost for subscriptions that require you to specify a user but does not require that user to authorize your application (e.g., stream.online, channel.update). However, there is no cost if that user has authorized your application (i.e., you have an OAuth scope for that user).
Although that last point is not quite clear to me. I will probably have to do some testing if that assumption is true.
It's not too readable in that box though :P Can't access everything even, as the scroll bar is fake. Could perhaps turn it into TextEdit with expanding height or something?
That is intended for the Variable action type. Don't want to have it resize all the time (especially vertically) as that would make editing segments below it very annoying. The full value can be viewed in the variable's settings dialog. (Probably have to add a dedicated variable tab at some point.)
And last note for today - the note above about separating both is more important than I thought as some of conditions could be easily made using both mechanics. For example "TItle matches" - IIRC it uses polling now, but it'd be IMO more efficient as event, so that the checks are only done when the title changes.
Yeah, the polling APIs are quite slow indeed. I thought about adding some caching (subscription id -> value) as well but not really sure how to best make that configurable to the user in a non-confusing way.
Also got a crash (or endless hang rather) when I selected "Started a watchparty". No crash log, not much in logs either
I think I saw that as well, but was unable to reproduce it. If you find a way to, please let me know! :)
Noticed some glitching OBS windows appearing when switching to macros with multiple Twitch actions.
I think that those are the search dialogs of the category selections being created on the stack and being visible by default. But will have to investigate it further.
I hoped that we can skip that part because we are using OAuth tokens
I see, not quite clear for me either. Will have to test with more subscriptions indeed then.
Don't want to have it resize all the time (especially vertically) as that would make editing segments below it very annoying. The full value can be viewed in the variable's settings dialog. (Probably have to add a dedicated variable tab at some point.)
Variable tab would be nice some day, but no other temporary workaround? If not resizable text box then a slightly bigger scrollable one could perhaps work. Checking properties each time you want to see how a single field is not great even for debugging. And it's hard to select and copy the text inside, too. For some reason it deselects the text after Ctrl + A. It works well with TextEdit/LineEdit normally, just this one is broken (perhaps because of the exceeding length).
I think I saw that as well, but was unable to reproduce it.
Nothing too specific to reproduce. I basically just switched between conditions in the dropdown. The 2nd time it happened I did nothing else except that and it happened after few switches. So all fields were blank. Now it doesn't happen when theyy're filled, so could be related to that?
BTW, now I also noticed that the event can stop working sometimes (with nothing in logs). I tested the same as before and nothing was going into variable, until I restarted OBS. What I did before that was mainly switching conditions back and forth to test the above. After OBS restart it restarted working.
And it's hard to select and copy the text inside, too. For some reason it deselects the text after Ctrl + A. It works well with TextEdit/LineEdit normally, just this one is broken (perhaps because of the exceeding length).
The selection is lost every time the content of the text filed is updated, even if the text is not changed. I will adjust that.
Nothing too specific to reproduce. I basically just switched between conditions in the dropdown. The 2nd time it happened I did nothing else except that and it happened after few switches. So all fields were blank. Now it doesn't happen when theyy're filled, so could be related to that?
Hm, guess I will have to play around and hope to catch it.
UPDATE:
I think I was able to reproduce it and able to track it down to a simple SendGetRequest()
call taking almost 20s.
I guess the Twitch API is throttling the API calls, which results in the "freeze".
So some caching for the polling functions is certainly a must.
BTW, now I also noticed that the event can stop working sometimes (with nothing in logs). I tested the same as before and nothing was going into variable, until I restarted OBS. What I did before that was mainly switching conditions back and forth to test the above. After OBS restart it restarted working.
Yeah, I noticed that as well. For some reason the connection seems to be lost at some point and the reconnection just fails. (Can be seen with verbose logs enabled)
Might just be that I didn't implement the reconnect mechanism correctly.
I now added the option to cache results with 24c33f7. Cached results will be used for 10 seconds before they are refreshed. It is applied to the polling condition types.
The channel selections are now also caching the user IDs returned by the API calls.
It also resolved the "freeze" and event subscriptions stopping randomly. I think this was just a side effect of the Twitch API cutting the connection due to rate limiting of the API calls. But I would appreciate if you could test this on your end as well, just to be sure the issue is really gone :)
Noticed some glitching OBS windows appearing when switching to macros with multiple Twitch actions.
Should be fixed with https://github.com/WarmUpTill/SceneSwitcher/pull/892/commits/bd444267abd03a96b45766c7cc3c031445eee6e8.
I now also implemented additional events (follow, subscribe, cheer) with 079fb8a. They seem to work when using the twitch websocket mock server.
A build with these changes will be available here in a few minutes: https://github.com/WarmUpTill/SceneSwitcher/actions/runs/6487150272
Nice, I'll stream today evening to check.
One thing I noticed for now is that the value of the variable current value box wasn't getting filled for me at all.
The channel selections are now also caching the user IDs returned by the API calls.
BTW, not entirely sure what you mean by "channel selections" 😕 Are they used somewhere currently? I haven't seen any special channel handling so far. The box in the condition is just a textbox for me if it's supposed to be something else (I've also seen some code that would suggest it should).
Also: https://github.com/WarmUpTill/SceneSwitcher/blob/079fb8a432621e66d4a5cefd2043259155d3d6d8/src/macro-external/twitch/macro-condition-twitch.cpp#L198 - perhaps it'd be good to stick to just outputting the whole data everywhere. As someone might want the user ID there instead.
One thing I noticed for now is that the value of the variable current value box wasn't getting filled for me at all.
That is intentional. The variable value should always contain the current state of the condition, which, if no matching event is received, is simply the empty string.
The value of a previous interval lingering was a bug in the previous version.
BTW, not entirely sure what you mean by "channel selections" 😕 Are they used somewhere currently? I haven't seen any special channel handling so far. The box in the condition is just a textbox for me if it's supposed to be something else (I've also seen some code that would suggest it should).
From the UI side they look just like a text box. In the backend they translate the input to user_ids usable by the Twitch API.
Perhaps it'd be good to stick to just outputting the whole data everywhere. As someone might want the user ID there instead.
Agreed.
The variable value should always contain the current state of the condition, which, if no matching event is received, is simply the empty string.
Hmm, ok, makes sense in terms of logic. Although it's not the best for testing. Perhaps what's missing is some kind of Popup
action or whatever that would display the value in a selectable way. File saving + autorefreshing editor is the closest, I think? I'll work on it + some more eventsub conditions on the weekend.
Ok, was live for over an hour with it and it seems stable, noticed no issues.
So my final opinions:
Thanks a lot for your tests! I will merge the changes now.
The dropdown spam should be rather easy to handle e.g. by adding a second dropdown menu which first let's you select a general category like "subscriptions" to filter out the non-subscription related entries. I also already added the option to filter by typing the the dropdrop menu header.
I guess the crash might already be fixed with https://github.com/WarmUpTill/SceneSwitcher/pull/892/commits/4cf7b9d94dd19e98ec73f5a27539bcc823f1e481.
Is your feature request related to a problem? Please describe. There are bunch of Twitch actions now, but no conditions. Some of the most useful ones I can think of:
Describe the solution you'd like EventSub (https://dev.twitch.tv/docs/eventsub/eventsub-reference/) could be used to receive data from Twitch. And conditions would just work similarly to current ones.
After the basis is created (which is definitely outside of my C++ capabilities as of now :P) I could ofc help with adding some of the more useful events/conditions whenever I find some free time.
Describe alternatives you've considered There are alternatives in form of bots that can read some of such events and then e.g. send something to OBS websocket AFAIK, but would be awesome if OBS had an almost direct support.
Additional context -