TwitchLib / TwitchLib.PubSub

PubSub component of TwitchLib.
38 stars 51 forks source link

Add OnRewardRedeemed, OnCustomRewardCreated, OnCustomRewardUpdated, OnLeaderboardSubs & OnLeaderboardBits event #41

Closed JayJay1989 closed 4 years ago

JayJay1989 commented 5 years ago

After some reverse engineering i added following functionality:

Note: Highlighted message are part of the irc messages.

swiftyspiffy commented 5 years ago

This looks great. Do you have sample payloads received from Twitch for these events? Thanks!

JayJay1989 commented 5 years ago

Sure, here you go: https://gist.github.com/JayJay1989/1730d1ede2e2c23809c6986af93e0c14

JayJay1989 commented 5 years ago

I added the payloads for the leaderboard events for giftsubs and bits also to the link above

swiftyspiffy commented 4 years ago

Looks good to me. Will leave open a few more days to allow others to review before merging. Thanks!

JayJay1989 commented 4 years ago

@swiftyspiffy the events doesn't get triggered for some reason. Maybe its something i do wrong in my test setup. Edit: you can ingore this, got it working

swiftyspiffy commented 4 years ago

So it is mergeable then?

JayJay1989 commented 4 years ago

Channelpoint reward redeemed should working: http://prntscr.com/qbsbml Leaderboard events should working now: http://prntscr.com/qbsp9s

Edit: its ready to go

wtfblub commented 4 years ago

Twitch added a official PubSub API for reward redeems yesterday: https://dev.twitch.tv/docs/pubsub Looks like only the topic name is different

JayJay1989 commented 4 years ago

Reason why i implemented 'community-points-channel-v1' and not 'channel-points-channel-v1'

community-points-channel-v1:

channel-points-channel-v1:

swiftyspiffy commented 4 years ago

Got confirmation this code has been running in a prod environment for several days.

jonrainier commented 4 years ago

Anyway you can provide your example of this working?

I've cloned the latest dev branch (https://github.com/TwitchLib/TwitchLib.PubSub/commit/1b4f59ef46245f31965bc3772c1ac5ee2c32b066) and I'm unable to get the events to fire.

Snippet of what isn't working:

PubSub = new TwitchPubSub(Logger);
PubSub.OnPubSubServiceConnected += RewardHelper.PubSub_OnPubSubServiceConnected;
PubSub.OnListenResponse += RewardHelper.PubSub_OnListenResponse;
PubSub.OnRewardRedeemed += RewardHelper.PubSub_OnRewardRedeemed;
PubSub.Connect();

PubSub_OnPubSubServiceConnected

Startup.PubSub.ListenToRewards("<channel id>");
Startup.PubSub.SendTopics("auth token with channel:read:redemptions set");

OnPubSubServiceConnected and OnPubSubServiceConnected both fire stating the topics were successfully subscribed to. I've tested it without the auth token and it fails to subscribe to the topic. I've set breakpoints where the message is received / parsed and that breakpoint was never hit.

JayJay1989 commented 4 years ago

Here you go: https://github.com/JayJay1989/TwitchLib.ExampleBot

jonrainier commented 4 years ago

Here you go: https://github.com/JayJay1989/TwitchLib.ExampleBotOp 26 jan. 2020 05:52 schreef Jonathan Rainier notifications@github.com:Anyway you can provide your example of this working? I've cloned the latest dev branch (1b4f59e) and I'm unable to get the events to fire. Snippet of what isn't working: PubSub = new TwitchPubSub(Logger); PubSub.OnPubSubServiceConnected += RewardHelper.PubSub_OnPubSubServiceConnected; PubSub.OnListenResponse += RewardHelper.PubSub_OnListenResponse; PubSub.OnRewardRedeemed += RewardHelper.PubSub_OnRewardRedeemed; PubSub.Connect(); PubSub_OnPubSubServiceConnected Startup.PubSub.ListenToRewards(""); Startup.PubSub.SendTopics("auth token with channel:read:redemptions set"); OnPubSubServiceConnected and OnPubSubServiceConnected both fire stating the topics were successfully subscribed to. I've tested it without the auth token and it fails to subscribe to the topic. I've set breakpoints where the message is received / parsed and that breakpoint was never hit. —You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or unsubscribe.

Thank you for the prompt reply! Mine appears to be working now after no changes to my logic, I ran both side by side for a couple of days and all events are now firing.