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
233 stars 32 forks source link

Tier NaN from OnSLTwitchSubNoSync / OnSLTwitchSub /OnSLTwitchGiftSubNoSync / OnSLTwitchGiftSub #28

Closed Number6174 closed 2 years ago

Number6174 commented 3 years ago

Summary

The {tier} parameter of the events OnSLTwitchSubNoSync, OnSLTwitchSub, OnSLTwitchGiftSubNoSync, OnSLTwitchGiftSub all provided Tier NaN instead of the documented Prime, Tier 1, Tier 2, or Tier 3 options.

Included is documentation of this behavior in the case of a Prime resub,

Triggers

The relevant logging triggers used were:

OnSLTwitchGiftSub 
API GET "http://127.0.0.1:8001/write?filename=log_for_Numbers.txt&mode=a&log=true&data=OnSLTwitchGiftSub:[data]"

OnSLTwitchGiftSubNoSync
API GET "http://127.0.0.1:8001/write?filename=log_for_Numbers.txt&mode=a&log=true&data=OnSLTwitchGiftSubNoSync:[data]"

OnSLTwitchSub
API GET "http://127.0.0.1:8001/write?filename=log_for_Numbers.txt&mode=a&log=true&data=OnSLTwitchSub:[data]"

OnSLTwitchSubNoSync
API GET "http://127.0.0.1:8001/write?filename=log_for_Numbers.txt&mode=a&log=true&data=OnSLTwitchSubNoSync:[data]"

And

OnSLTwitchSubNoSync
API GET "http://127.0.0.1:8001/event?sub=self&name={user}&tier={tier}&months={months}&message={message}"

OnSLTwitchGiftSubNoSync
API GET "http://127.0.0.1:8001/event?sub=gift&gifter={gifter}&recipient={user}&tier={tier}&months={months}"

where at 127.0.0.1:8001 is a Python script I wrote that has both a logging endpoint (/write) and understanding of various Twitch events (/event).

This setup provides logging of both the data variable as well as all the other documented variables for the various StreamLabs subscription events. I also had similar logging setup for OnSLTwitchCommunityGiftSub and OnSLTwitchCommunityGiftSubNoSync, but those events did not fire despite community gift subs occurring. However I believe that is a separate issue.

Examples

Prime subscription

2021-08-15 07:01:19,823 - DEBUG - ParseResult(scheme='', netloc='', path='/write', params='', query='filename=log_for_Numbers.txt&mode=a&log=true&data=OnSLTwitchSubNoSync:{%22name%22:%22shadowc64%22,%22display_name%22:%22ShadowC64%22,%22months%22:%2236%22,%22message%22:null,%22emotes%22:null,%22sub_plan%22:%22Prime%22,%22sub_plan_name%22:%22\\\\sChannel\\\\sSubscription\\\\s(generikb):\\\\s$4.99\\\\sSub%22,%22sub_type%22:%22resub%22,%22gifter%22:null,%22subscriber_twitch_id%22:%2223194604%22,%22streak_months%22:%2236%22,%22_id%22:%22d629714ffa02219dc4023cf402221241%22,%22event_id%22:%22d629714ffa02219dc4023cf402221241%22}', fragment='')
2021-08-15 07:01:19,824 - DEBUG - 'log_for_Numbers.txt' was appended with '2021-08-15T07:01:19.823016 - OnSLTwitchSubNoSync:{"name":"shadowc64","display_name":"ShadowC64","months":"36","message":null,"emotes":null,"sub_plan":"Prime","sub_plan_name":"\\sChannel\\sSubscription\\s(generikb):\\s$4.99\\sSub","sub_type":"resub","gifter":null,"subscriber_twitch_id":"23194604","streak_months":"36","_id":"d629714ffa02219dc4023cf402221241","event_id":"d629714ffa02219dc4023cf402221241"}
'
2021-08-15 07:01:19,824 - DEBUG - ParseResult(scheme='', netloc='', path='/event', params='', query='sub=self&name=shadowc64&tier=Tier%20NaN&months=36&message=null', fragment='')
2021-08-15 07:01:19,824 - INFO - 'shadowc64' subbed Tier NaN for 36 months (180 points): null
2021-08-15 07:01:19,825 - DEBUG - Timer info is now {"stream-start": "2021-08-15T07:00:00", "stream-end": "2021-08-15T19:00:00", "current-end": "2021-08-15T07:03:00.000", "points-funded": 180, "points-to-fully-fund": 32400, "time-adjust": 0}
2021-08-15 07:01:20,642 - DEBUG - ParseResult(scheme='', netloc='', path='/write', params='', query='filename=log_for_Numbers.txt&mode=a&log=true&data=OnSLTwitchSub:{%22priority%22:10,%22_id%22:%227badaaf10afea8ce2b98645abf8635c55a497d1a%22,%22from%22:%22ShadowC64%22,%22from_display_name%22:%22ShadowC64%22,%22emotes%22:null,%22months%22:36,%22streak_months%22:%2236%22,%22message%22:%22%22,%22payload%22:{%22name%22:%22shadowc64%22,%22display_name%22:%22ShadowC64%22,%22months%22:%2236%22,%22message%22:null,%22emotes%22:null,%22sub_plan%22:%22Prime%22,%22sub_plan_name%22:%22\\\\sChannel\\\\sSubscription\\\\s(generikb):\\\\s$4.99\\\\sSub%22,%22sub_type%22:%22resub%22,%22gifter%22:null,%22subscriber_twitch_id%22:%2223194604%22,%22streak_months%22:%2236%22,%22_id%22:%22d629714ffa02219dc4023cf402221241%22,%22event_id%22:%22d629714ffa02219dc4023cf402221241%22},%22name%22:%22ShadowC64%22,%22display_name%22:%22ShadowC64%22,%22subPlan%22:%22Prime%22,%22sub_plan%22:%22Prime%22,%22subscriber_twitch_id%22:null,%22gifter%22:%22%22,%22gifter_display_name%22:null,%22count%22:1,%22repeat%22:false,%22isTest%22:false,%22createdAt%22:%222021-08-15%2000:01:19%22,%22createdAtTimestamp%22:1628985679820,%22platform%22:%22twitch_account%22,%22planName%22:%22%22,%22type%22:%22subscription%22,%22hash%22:%22subscription:shadowc64:%22,%22read%22:false,%22amount%22:null,%22membershipLevel%22:null,%22membershipLevelName%22:null,%22massSubGiftChildAlerts%22:[],%22isSubgiftExpanded%22:true,%22benefit_end_month%22:null}', fragment='')
2021-08-15 07:01:20,642 - DEBUG - 'log_for_Numbers.txt' was appended with '2021-08-15T07:01:20.642075 - OnSLTwitchSub:{"priority":10,"_id":"7badaaf10afea8ce2b98645abf8635c55a497d1a","from":"ShadowC64","from_display_name":"ShadowC64","emotes":null,"months":36,"streak_months":"36","message":"","payload":{"name":"shadowc64","display_name":"ShadowC64","months":"36","message":null,"emotes":null,"sub_plan":"Prime","sub_plan_name":"\\sChannel\\sSubscription\\s(generikb):\\s$4.99\\sSub","sub_type":"resub","gifter":null,"subscriber_twitch_id":"23194604","streak_months":"36","_id":"d629714ffa02219dc4023cf402221241","event_id":"d629714ffa02219dc4023cf402221241"},"name":"ShadowC64","display_name":"ShadowC64","subPlan":"Prime","sub_plan":"Prime","subscriber_twitch_id":null,"gifter":"","gifter_display_name":null,"count":1,"repeat":false,"isTest":false,"createdAt":"2021-08-15 00:01:19","createdAtTimestamp":1628985679820,"platform":"twitch_account","planName":"","type":"subscription","hash":"subscription:shadowc64:","read":false,"amount":null,"membershipLevel":null,"membershipLevelName":null,"massSubGiftChildAlerts":[],"isSubgiftExpanded":true,"benefit_end_month":null}
'

Tier 1 subscription

2021-08-15 07:02:36,953 - DEBUG - ParseResult(scheme='', netloc='', path='/write', params='', query='filename=log_for_Numbers.txt&mode=a&log=true&data=OnSLTwitchSubNoSync:{%22name%22:%22ryklou12%22,%22display_name%22:%22Ryklou12%22,%22months%22:%223%22,%22message%22:null,%22emotes%22:null,%22sub_plan%22:%221000%22,%22sub_plan_name%22:%22\\\\sChannel\\\\sSubscription\\\\s(generikb):\\\\s$4.99\\\\sSub%22,%22sub_type%22:%22resub%22,%22gifter%22:null,%22subscriber_twitch_id%22:%22554896695%22,%22streak_months%22:null,%22_id%22:%22bc2ca4988f8538f3083f39585ae0e0c3%22,%22event_id%22:%22bc2ca4988f8538f3083f39585ae0e0c3%22}', fragment='')
2021-08-15 07:02:36,953 - DEBUG - 'log_for_Numbers.txt' was appended with '2021-08-15T07:02:36.953888 - OnSLTwitchSubNoSync:{"name":"ryklou12","display_name":"Ryklou12","months":"3","message":null,"emotes":null,"sub_plan":"1000","sub_plan_name":"\\sChannel\\sSubscription\\s(generikb):\\s$4.99\\sSub","sub_type":"resub","gifter":null,"subscriber_twitch_id":"554896695","streak_months":null,"_id":"bc2ca4988f8538f3083f39585ae0e0c3","event_id":"bc2ca4988f8538f3083f39585ae0e0c3"}
'
2021-08-15 07:02:36,953 - DEBUG - ParseResult(scheme='', netloc='', path='/event', params='', query='sub=self&name=ryklou12&tier=Tier%20NaN&months=3&message=null', fragment='')
2021-08-15 07:02:36,954 - INFO - 'ryklou12' subbed Tier NaN for 3 months (180 points): null
2021-08-15 07:02:36,954 - DEBUG - Timer info is now {"stream-start": "2021-08-15T07:00:00", "stream-end": "2021-08-15T19:00:00", "current-end": "2021-08-15T10:09:00.000", "points-funded": 540, "points-to-fully-fund": 32400, "time-adjust": 10800}
2021-08-15 07:02:46,322 - DEBUG - ParseResult(scheme='', netloc='', path='/write', params='', query='filename=log_for_Numbers.txt&mode=a&log=true&data=OnSLTwitchSub:{%22priority%22:10,%22_id%22:%222345cdc3ae8bf70e8ea8794540e747022896bb38%22,%22from%22:%22Ryklou12%22,%22from_display_name%22:%22Ryklou12%22,%22emotes%22:null,%22months%22:3,%22streak_months%22:null,%22message%22:%22%22,%22payload%22:{%22name%22:%22ryklou12%22,%22display_name%22:%22Ryklou12%22,%22months%22:%223%22,%22message%22:null,%22emotes%22:null,%22sub_plan%22:%221000%22,%22sub_plan_name%22:%22\\\\sChannel\\\\sSubscription\\\\s(generikb):\\\\s$4.99\\\\sSub%22,%22sub_type%22:%22resub%22,%22gifter%22:null,%22subscriber_twitch_id%22:%22554896695%22,%22streak_months%22:null,%22_id%22:%22bc2ca4988f8538f3083f39585ae0e0c3%22,%22event_id%22:%22bc2ca4988f8538f3083f39585ae0e0c3%22},%22name%22:%22Ryklou12%22,%22display_name%22:%22Ryklou12%22,%22subPlan%22:%221000%22,%22sub_plan%22:%221000%22,%22subscriber_twitch_id%22:null,%22gifter%22:%22%22,%22gifter_display_name%22:null,%22count%22:1,%22repeat%22:false,%22isTest%22:false,%22createdAt%22:%222021-08-15%2000:02:36%22,%22createdAtTimestamp%22:1628985756948,%22platform%22:%22twitch_account%22,%22planName%22:%22%22,%22type%22:%22subscription%22,%22hash%22:%22subscription:ryklou12:%22,%22read%22:false,%22amount%22:null,%22membershipLevel%22:null,%22membershipLevelName%22:null,%22massSubGiftChildAlerts%22:[],%22isSubgiftExpanded%22:true,%22benefit_end_month%22:null}', fragment='')
2021-08-15 07:02:46,323 - DEBUG - 'log_for_Numbers.txt' was appended with '2021-08-15T07:02:46.322443 - OnSLTwitchSub:{"priority":10,"_id":"2345cdc3ae8bf70e8ea8794540e747022896bb38","from":"Ryklou12","from_display_name":"Ryklou12","emotes":null,"months":3,"streak_months":null,"message":"","payload":{"name":"ryklou12","display_name":"Ryklou12","months":"3","message":null,"emotes":null,"sub_plan":"1000","sub_plan_name":"\\sChannel\\sSubscription\\s(generikb):\\s$4.99\\sSub","sub_type":"resub","gifter":null,"subscriber_twitch_id":"554896695","streak_months":null,"_id":"bc2ca4988f8538f3083f39585ae0e0c3","event_id":"bc2ca4988f8538f3083f39585ae0e0c3"},"name":"Ryklou12","display_name":"Ryklou12","subPlan":"1000","sub_plan":"1000","subscriber_twitch_id":null,"gifter":"","gifter_display_name":null,"count":1,"repeat":false,"isTest":false,"createdAt":"2021-08-15 00:02:36","createdAtTimestamp":1628985756948,"platform":"twitch_account","planName":"","type":"subscription","hash":"subscription:ryklou12:","read":false,"amount":null,"membershipLevel":null,"membershipLevelName":null,"massSubGiftChildAlerts":[],"isSubgiftExpanded":true,"benefit_end_month":null}
'

Tier 1 Gift

2021-08-15 07:02:32,594 - DEBUG - ParseResult(scheme='', netloc='', path='/write', params='', query='filename=log_for_Numbers.txt&mode=a&log=true&data=OnSLTwitchGiftSubNoSync:{%22name%22:%22bga_insanity%22,%22display_name%22:%22BGA_Insanity%22,%22months%22:%222%22,%22message%22:null,%22emotes%22:null,%22sub_plan%22:%221000%22,%22sub_plan_name%22:%22\\\\sChannel\\\\sSubscription\\\\s(generikb):\\\\s$4.99\\\\sSub%22,%22sub_type%22:%22subgift%22,%22gifter%22:%22ryklou12%22,%22gifter_display_name%22:%22Ryklou12%22,%22streak_months%22:null,%22gifter_twitch_id%22:%22554896695%22,%22subscriber_twitch_id%22:%2239601375%22,%22_id%22:%2270e87252f35d29e07532d6bebb1a5698%22,%22event_id%22:%2270e87252f35d29e07532d6bebb1a5698%22}', fragment='')
2021-08-15 07:02:32,595 - DEBUG - 'log_for_Numbers.txt' was appended with '2021-08-15T07:02:32.595882 - OnSLTwitchGiftSubNoSync:{"name":"bga_insanity","display_name":"BGA_Insanity","months":"2","message":null,"emotes":null,"sub_plan":"1000","sub_plan_name":"\\sChannel\\sSubscription\\s(generikb):\\s$4.99\\sSub","sub_type":"subgift","gifter":"ryklou12","gifter_display_name":"Ryklou12","streak_months":null,"gifter_twitch_id":"554896695","subscriber_twitch_id":"39601375","_id":"70e87252f35d29e07532d6bebb1a5698","event_id":"70e87252f35d29e07532d6bebb1a5698"}
'
2021-08-15 07:02:32,595 - DEBUG - ParseResult(scheme='', netloc='', path='/event', params='', query='sub=gift&gifter=Ryklou12&recipient=bga_insanity&tier=Tier%20NaN&months=2', fragment='')
2021-08-15 07:02:32,595 - INFO - 'Ryklou12' gifted Tier NaN to 'bga_insanity' who now has 2 months (180 points)
2021-08-15 07:02:32,595 - DEBUG - Timer info is now {"stream-start": "2021-08-15T07:00:00", "stream-end": "2021-08-15T19:00:00", "current-end": "2021-08-15T10:06:00.000", "points-funded": 360, "points-to-fully-fund": 32400, "time-adjust": 10800}
2021-08-15 07:02:33,320 - DEBUG - ParseResult(scheme='', netloc='', path='/write', params='', query='filename=log_for_Numbers.txt&mode=a&log=true&data=OnSLTwitchGiftSub:{%22priority%22:10,%22_id%22:%22cc9ade34077f700c97ff0ed46fcf05ea232f8939%22,%22from%22:%22BGA_Insanity%22,%22from_display_name%22:%22BGA_Insanity%22,%22emotes%22:null,%22months%22:2,%22streak_months%22:null,%22message%22:%22%22,%22payload%22:{%22name%22:%22bga_insanity%22,%22display_name%22:%22BGA_Insanity%22,%22months%22:%222%22,%22message%22:null,%22emotes%22:null,%22sub_plan%22:%221000%22,%22sub_plan_name%22:%22\\\\sChannel\\\\sSubscription\\\\s(generikb):\\\\s$4.99\\\\sSub%22,%22sub_type%22:%22subgift%22,%22gifter%22:%22ryklou12%22,%22gifter_display_name%22:%22Ryklou12%22,%22streak_months%22:null,%22gifter_twitch_id%22:%22554896695%22,%22subscriber_twitch_id%22:%2239601375%22,%22_id%22:%2270e87252f35d29e07532d6bebb1a5698%22,%22event_id%22:%2270e87252f35d29e07532d6bebb1a5698%22},%22name%22:%22BGA_Insanity%22,%22display_name%22:%22BGA_Insanity%22,%22subPlan%22:%221000%22,%22sub_plan%22:%221000%22,%22subscriber_twitch_id%22:null,%22gifter%22:%22ryklou12%22,%22gifter_display_name%22:%22Ryklou12%22,%22count%22:1,%22repeat%22:false,%22isTest%22:false,%22createdAt%22:%222021-08-15%2000:02:32%22,%22createdAtTimestamp%22:1628985752590,%22platform%22:%22twitch_account%22,%22planName%22:%22%22,%22type%22:%22subscription%22,%22hash%22:%22subscription:bga_insanity:%22,%22read%22:false,%22amount%22:null,%22membershipLevel%22:null,%22membershipLevelName%22:null,%22massSubGiftChildAlerts%22:[],%22isSubgiftExpanded%22:true,%22benefit_end_month%22:null}', fragment='')
2021-08-15 07:02:33,321 - DEBUG - 'log_for_Numbers.txt' was appended with '2021-08-15T07:02:33.320014 - OnSLTwitchGiftSub:{"priority":10,"_id":"cc9ade34077f700c97ff0ed46fcf05ea232f8939","from":"BGA_Insanity","from_display_name":"BGA_Insanity","emotes":null,"months":2,"streak_months":null,"message":"","payload":{"name":"bga_insanity","display_name":"BGA_Insanity","months":"2","message":null,"emotes":null,"sub_plan":"1000","sub_plan_name":"\\sChannel\\sSubscription\\s(generikb):\\s$4.99\\sSub","sub_type":"subgift","gifter":"ryklou12","gifter_display_name":"Ryklou12","streak_months":null,"gifter_twitch_id":"554896695","subscriber_twitch_id":"39601375","_id":"70e87252f35d29e07532d6bebb1a5698","event_id":"70e87252f35d29e07532d6bebb1a5698"},"name":"BGA_Insanity","display_name":"BGA_Insanity","subPlan":"1000","sub_plan":"1000","subscriber_twitch_id":null,"gifter":"ryklou12","gifter_display_name":"Ryklou12","count":1,"repeat":false,"isTest":false,"createdAt":"2021-08-15 00:02:32","createdAtTimestamp":1628985752590,"platform":"twitch_account","planName":"","type":"subscription","hash":"subscription:bga_insanity:","read":false,"amount":null,"membershipLevel":null,"membershipLevelName":null,"massSubGiftChildAlerts":[],"isSubgiftExpanded":true,"benefit_end_month":null}
'

Summary

Clearly the data contains the correct sub_plan information and it is getting converted into the wrong value.

At first glance, it appears the problem in js/streamlabs/streamlabsHandler.js is that it refers to message.subPlan in several cases when it probably should be message.sub_plan. However I could be missing something with this analysis.

Unfortunately I did not capute any occurences where sub_plan was 2000 or 3000. Nor did I capture any events of types OnSLTwitchCommunityGiftSub or OnSLTwitchCommunityGiftSubNoSync, even though community gift subs occurred.

In addition to the obvious problem of Tier NaN, in the case of a gift sub there is an inconsistency. Note that gifter_display_name was used for the gifter, but name was used for the recipient.

Kruiser8 commented 3 years ago

Thanks for the report, @Number6174. I don't understand your last comment.

Note that gifter_display_name was used for the gifter, but name was used for the recipient.

I don't see the problem there.

Number6174 commented 3 years ago

It is an issue of consistency. Twitch refers to user names in two ways. In their docs they refer to this as a login and a display_name. The difference is a login will be all lower case, and I believe substantially ASCII (but I'm not sure if that is documented). Whereas display_name will preserve capitalization, and potentially be Unicode (think like Chinese characters for example).

It is used inconsistently in that for the gifter the display_name is used, but for the recipient the login is used.

Kruiser8 commented 3 years ago

Good point. I'll switch it to display_name. It'll be the third time I've had to change the SL alert data endpoints. At this point, it's just a pain.

Kruiser8 commented 3 years ago

Updated the name and sub plan parsing to be more flexible and check multiple values https://github.com/Kruiser8/Kruiz-Control/commit/a717572bcdbe588a811c88da23b3d96208f2c379