@overlaysymphony/twitch 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +15 -17
- package/src/authentication/authentication.ts +110 -54
- package/src/chat/chat.ts +9 -8
- package/src/chat/helpers.ts +36 -0
- package/src/chat/index.ts +1 -0
- package/src/chat/interfaces/events.ts +29 -29
- package/src/chat/interfaces/index.ts +1 -1
- package/src/chat/parser.ts +9 -20
- package/src/eventsub/events/channel.ad_break.begin.ts +1 -1
- package/src/eventsub/events/channel.ban.ts +1 -1
- package/src/eventsub/events/channel.channel_points_custom_reward.add.ts +2 -2
- package/src/eventsub/events/channel.channel_points_custom_reward.remove.ts +2 -2
- package/src/eventsub/events/channel.channel_points_custom_reward.update.ts +2 -2
- package/src/eventsub/events/channel.channel_points_custom_reward_redemption.add.ts +2 -2
- package/src/eventsub/events/channel.channel_points_custom_reward_redemption.update.ts +2 -2
- package/src/eventsub/events/channel.charity_campaign.donate.ts +1 -1
- package/src/eventsub/events/channel.charity_campaign.progress.ts +1 -1
- package/src/eventsub/events/channel.charity_campaign.start.ts +1 -1
- package/src/eventsub/events/channel.charity_campaign.stop.ts +1 -1
- package/src/eventsub/events/channel.chat.clear.ts +1 -1
- package/src/eventsub/events/channel.chat.clear_user_messages.ts +1 -1
- package/src/eventsub/events/channel.chat.message_delete.ts +1 -1
- package/src/eventsub/events/channel.chat.notification.ts +1 -1
- package/src/eventsub/events/channel.cheer.ts +1 -1
- package/src/eventsub/events/channel.follow.ts +1 -1
- package/src/eventsub/events/channel.goal.begin.ts +1 -1
- package/src/eventsub/events/channel.goal.end.ts +1 -1
- package/src/eventsub/events/channel.goal.progress.ts +1 -1
- package/src/eventsub/events/channel.guest_star_guest.update.ts +1 -1
- package/src/eventsub/events/channel.guest_star_session.begin.ts +1 -1
- package/src/eventsub/events/channel.guest_star_session.end.ts +1 -1
- package/src/eventsub/events/channel.guest_star_settings.update.ts +1 -1
- package/src/eventsub/events/channel.hype_train.begin.ts +2 -2
- package/src/eventsub/events/channel.hype_train.end.ts +2 -2
- package/src/eventsub/events/channel.hype_train.progress.ts +2 -2
- package/src/eventsub/events/channel.moderator.add.ts +1 -1
- package/src/eventsub/events/channel.moderator.remove.ts +1 -1
- package/src/eventsub/events/channel.poll.begin.ts +2 -2
- package/src/eventsub/events/channel.poll.end.ts +2 -2
- package/src/eventsub/events/channel.poll.progress.ts +2 -2
- package/src/eventsub/events/channel.prediction.begin.ts +2 -2
- package/src/eventsub/events/channel.prediction.end.ts +2 -2
- package/src/eventsub/events/channel.prediction.lock.ts +2 -2
- package/src/eventsub/events/channel.prediction.progress.ts +2 -2
- package/src/eventsub/events/channel.raid.ts +1 -1
- package/src/eventsub/events/channel.shield_mode.begin.ts +1 -1
- package/src/eventsub/events/channel.shield_mode.end.ts +1 -1
- package/src/eventsub/events/channel.shoutout.create.ts +1 -1
- package/src/eventsub/events/channel.shoutout.receive.ts +1 -1
- package/src/eventsub/events/channel.subscribe.ts +1 -1
- package/src/eventsub/events/channel.subscription.end.ts +1 -1
- package/src/eventsub/events/channel.subscription.gift.ts +1 -1
- package/src/eventsub/events/channel.subscription.message.ts +1 -1
- package/src/eventsub/events/channel.unban.ts +1 -1
- package/src/eventsub/events/channel.update.ts +1 -1
- package/src/eventsub/events/index.ts +51 -51
- package/src/eventsub/events/stream.offline.ts +1 -1
- package/src/eventsub/events/stream.online.ts +1 -1
- package/src/eventsub/events/user.update.ts +1 -1
- package/src/eventsub/events-helpers.ts +2 -2
- package/src/eventsub/eventsub.ts +9 -10
- package/src/eventsub/messages.ts +1 -1
- package/src/helix/channel-points/custom-rewards.ts +2 -3
- package/src/helix/helix.ts +1 -1
- package/src/helix/subscriptions/subscriptions.ts +9 -19
- package/src/helix/users/users.ts +1 -1
- package/src/helpers/alerts/alerts.ts +3 -3
- package/src/helpers/charity/charity.ts +1 -1
- package/src/helpers/goal/goal.ts +1 -1
- package/src/helpers/hype-train/hype-train.ts +1 -1
- package/src/helpers/poll/poll.ts +17 -3
- package/src/helpers/prediction/prediction.ts +1 -1
- package/src/helpers/redemption/redemption.ts +21 -2
- package/src/helpers/status/status.ts +1 -1
- package/src/ui/authentication.ts +29 -86
- package/src/ui/popup.ts +46 -7
- package/src/ui/vite-env.d.ts +1 -0
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { NotificationMessage } from "../events-helpers.js"
|
|
1
|
+
import { type NotificationMessage } from "../events-helpers.js"
|
|
2
2
|
|
|
3
|
-
import { ChannelAdBreakBeginEvent, ChannelAdBreakBeginSubscription, makeChannelAdBreakBeginSubscription } from "./channel.ad_break.begin.js"
|
|
4
|
-
import { ChannelBanEvent, ChannelBanSubscription, makeChannelBanSubscription } from "./channel.ban.js"
|
|
5
|
-
import { ChannelPointsCustomRewardAddEvent, ChannelPointsCustomRewardAddSubscription, makeChannelPointsCustomRewardAddSubscription } from "./channel.channel_points_custom_reward.add.js"
|
|
6
|
-
import { ChannelPointsCustomRewardRemoveEvent, ChannelPointsCustomRewardRemoveSubscription, makeChannelPointsCustomRewardRemoveSubscription } from "./channel.channel_points_custom_reward.remove.js"
|
|
7
|
-
import { ChannelPointsCustomRewardUpdateEvent, ChannelPointsCustomRewardUpdateSubscription, makeChannelPointsCustomRewardUpdateSubscription } from "./channel.channel_points_custom_reward.update.js"
|
|
8
|
-
import { ChannelPointsCustomRewardRedemptionAddEvent, ChannelPointsCustomRewardRedemptionAddSubscription, makeChannelPointsCustomRewardRedemptionAddSubscription } from "./channel.channel_points_custom_reward_redemption.add.js"
|
|
9
|
-
import { ChannelPointsCustomRewardRedemptionUpdateEvent, ChannelPointsCustomRewardRedemptionUpdateSubscription, makeChannelPointsCustomRewardRedemptionUpdateSubscription } from "./channel.channel_points_custom_reward_redemption.update.js"
|
|
10
|
-
import { CharityDonationEvent, CharityDonationSubscription, makeCharityDonationSubscription } from "./channel.charity_campaign.donate.js"
|
|
11
|
-
import { CharityCampaignProgressEvent, CharityCampaignProgressSubscription, makeCharityCampaignProgressSubscription } from "./channel.charity_campaign.progress.js"
|
|
12
|
-
import { CharityCampaignStartEvent, CharityCampaignStartSubscription, makeCharityCampaignStartSubscription } from "./channel.charity_campaign.start.js"
|
|
13
|
-
import { CharityCampaignStopEvent, CharityCampaignStopSubscription, makeCharityCampaignStopSubscription } from "./channel.charity_campaign.stop.js"
|
|
14
|
-
import { ChannelChatClearEvent, ChannelChatClearSubscription, makeChannelChatClearSubscription } from "./channel.chat.clear.js"
|
|
15
|
-
import { ChannelChatClearUserMessagesEvent, ChannelChatClearUserMessagesSubscription, makeChannelChatClearUserMessagesSubscription } from "./channel.chat.clear_user_messages.js"
|
|
16
|
-
import { ChannelChatMessageDeleteEvent, ChannelChatMessageDeleteSubscription, makeChannelChatMessageDeleteSubscription } from "./channel.chat.message_delete.js"
|
|
17
|
-
import { ChannelChatNotificationEvent, ChannelChatNotificationSubscription, makeChannelChatNotificationSubscription } from "./channel.chat.notification.js"
|
|
18
|
-
import { ChannelCheerEvent, ChannelCheerSubscription, makeChannelCheerSubscription } from "./channel.cheer.js"
|
|
19
|
-
import { ChannelFollowEvent, ChannelFollowSubscription, makeChannelFollowSubscription } from "./channel.follow.js"
|
|
20
|
-
import { GoalBeginEvent, GoalBeginSubscription, makeGoalBeginSubscription } from "./channel.goal.begin.js"
|
|
21
|
-
import { GoalEndEvent, GoalEndSubscription, makeGoalEndSubscription } from "./channel.goal.end.js"
|
|
22
|
-
import { GoalProgressEvent, GoalProgressSubscription, makeGoalProgressSubscription } from "./channel.goal.progress.js"
|
|
23
|
-
import { ChannelGuestStarGuestUpdateEvent, ChannelGuestStarGuestUpdateSubscription, makeChannelGuestStarGuestUpdateSubscription } from "./channel.guest_star_guest.update.js"
|
|
24
|
-
import { ChannelGuestStarSessionBeginEvent, ChannelGuestStarSessionBeginSubscription, makeChannelGuestStarSessionBeginSubscription } from "./channel.guest_star_session.begin.js"
|
|
25
|
-
import { ChannelGuestStarSessionEndEvent, ChannelGuestStarSessionEndSubscription, makeChannelGuestStarSessionEndSubscription } from "./channel.guest_star_session.end.js"
|
|
26
|
-
import { ChannelGuestStarSettingsUpdateEvent, ChannelGuestStarSettingsUpdateSubscription, makeChannelGuestStarSettingsUpdateSubscription } from "./channel.guest_star_settings.update.js"
|
|
27
|
-
import { HypeTrainBeginEvent, HypeTrainBeginSubscription, makeHypeTrainBeginSubscription } from "./channel.hype_train.begin.js"
|
|
28
|
-
import { HypeTrainEndEvent, HypeTrainEndSubscription, makeHypeTrainEndSubscription } from "./channel.hype_train.end.js"
|
|
29
|
-
import { HypeTrainProgressEvent, HypeTrainProgressSubscription, makeHypeTrainProgressSubscription } from "./channel.hype_train.progress.js"
|
|
30
|
-
import { ChannelModeratorAddEvent, ChannelModeratorAddSubscription, makeChannelModeratorAddSubscription } from "./channel.moderator.add.js"
|
|
31
|
-
import { ChannelModeratorRemoveEvent, ChannelModeratorRemoveSubscription, makeChannelModeratorRemoveSubscription } from "./channel.moderator.remove.js"
|
|
32
|
-
import { ChannelPollBeginEvent, ChannelPollBeginSubscription, makeChannelPollBeginSubscription } from "./channel.poll.begin.js"
|
|
33
|
-
import { ChannelPollEndEvent, ChannelPollEndSubscription, makeChannelPollEndSubscription } from "./channel.poll.end.js"
|
|
34
|
-
import { ChannelPollProgressEvent, ChannelPollProgressSubscription, makeChannelPollProgressSubscription } from "./channel.poll.progress.js"
|
|
35
|
-
import { ChannelPredictionBeginEvent, ChannelPredictionBeginSubscription, makeChannelPredictionBeginSubscription } from "./channel.prediction.begin.js"
|
|
36
|
-
import { ChannelPredictionEndEvent, ChannelPredictionEndSubscription, makeChannelPredictionEndSubscription } from "./channel.prediction.end.js"
|
|
37
|
-
import { ChannelPredictionLockEvent, ChannelPredictionLockSubscription, makeChannelPredictionLockSubscription } from "./channel.prediction.lock.js"
|
|
38
|
-
import { ChannelPredictionProgressEvent, ChannelPredictionProgressSubscription, makeChannelPredictionProgressSubscription } from "./channel.prediction.progress.js"
|
|
39
|
-
import { ChannelRaidEvent, ChannelRaidSubscription, makeChannelRaidSubscription } from "./channel.raid.js"
|
|
40
|
-
import { ShieldModeBeginEvent, ShieldModeBeginSubscription, makeShieldModeBeginSubscription } from "./channel.shield_mode.begin.js"
|
|
41
|
-
import { ShieldModeEndEvent, ShieldModeEndSubscription, makeShieldModeEndSubscription } from "./channel.shield_mode.end.js"
|
|
42
|
-
import { ShoutoutCreateEvent, ShoutoutCreateSubscription, makeShoutoutCreateSubscription } from "./channel.shoutout.create.js"
|
|
43
|
-
import { ShoutoutReceiveEvent, ShoutoutReceiveSubscription, makeShoutoutReceiveSubscription } from "./channel.shoutout.receive.js"
|
|
44
|
-
import { ChannelSubscribeEvent, ChannelSubscribeSubscription, makeChannelSubscribeSubscription } from "./channel.subscribe.js"
|
|
45
|
-
import { ChannelSubscriptionEndEvent, ChannelSubscriptionEndSubscription, makeChannelSubscriptionEndSubscription } from "./channel.subscription.end.js"
|
|
46
|
-
import { ChannelSubscriptionGiftEvent, ChannelSubscriptionGiftSubscription, makeChannelSubscriptionGiftSubscription } from "./channel.subscription.gift.js"
|
|
47
|
-
import { ChannelSubscriptionMessageEvent, ChannelSubscriptionMessageSubscription, makeChannelSubscriptionMessageSubscription } from "./channel.subscription.message.js"
|
|
48
|
-
import { ChannelUnbanEvent, ChannelUnbanSubscription, makeChannelUnbanSubscription } from "./channel.unban.js"
|
|
49
|
-
import { ChannelUpdateEvent, ChannelUpdateSubscription, makeChannelUpdateSubscription } from "./channel.update.js"
|
|
50
|
-
import { StreamOfflineEvent, StreamOfflineSubscription, makeStreamOfflineSubscription } from "./stream.offline.js"
|
|
51
|
-
import { StreamOnlineEvent, StreamOnlineSubscription, makeStreamOnlineSubscription } from "./stream.online.js"
|
|
52
|
-
import { UserUpdateEvent, UserUpdateSubscription, makeUserUpdateSubscription } from "./user.update.js"
|
|
3
|
+
import { type ChannelAdBreakBeginEvent, type ChannelAdBreakBeginSubscription, makeChannelAdBreakBeginSubscription } from "./channel.ad_break.begin.js"
|
|
4
|
+
import { type ChannelBanEvent, type ChannelBanSubscription, makeChannelBanSubscription } from "./channel.ban.js"
|
|
5
|
+
import { type ChannelPointsCustomRewardAddEvent, type ChannelPointsCustomRewardAddSubscription, makeChannelPointsCustomRewardAddSubscription } from "./channel.channel_points_custom_reward.add.js"
|
|
6
|
+
import { type ChannelPointsCustomRewardRemoveEvent, type ChannelPointsCustomRewardRemoveSubscription, makeChannelPointsCustomRewardRemoveSubscription } from "./channel.channel_points_custom_reward.remove.js"
|
|
7
|
+
import { type ChannelPointsCustomRewardUpdateEvent, type ChannelPointsCustomRewardUpdateSubscription, makeChannelPointsCustomRewardUpdateSubscription } from "./channel.channel_points_custom_reward.update.js"
|
|
8
|
+
import { type ChannelPointsCustomRewardRedemptionAddEvent, type ChannelPointsCustomRewardRedemptionAddSubscription, makeChannelPointsCustomRewardRedemptionAddSubscription } from "./channel.channel_points_custom_reward_redemption.add.js"
|
|
9
|
+
import { type ChannelPointsCustomRewardRedemptionUpdateEvent, type ChannelPointsCustomRewardRedemptionUpdateSubscription, makeChannelPointsCustomRewardRedemptionUpdateSubscription } from "./channel.channel_points_custom_reward_redemption.update.js"
|
|
10
|
+
import { type CharityDonationEvent, type CharityDonationSubscription, makeCharityDonationSubscription } from "./channel.charity_campaign.donate.js"
|
|
11
|
+
import { type CharityCampaignProgressEvent, type CharityCampaignProgressSubscription, makeCharityCampaignProgressSubscription } from "./channel.charity_campaign.progress.js"
|
|
12
|
+
import { type CharityCampaignStartEvent, type CharityCampaignStartSubscription, makeCharityCampaignStartSubscription } from "./channel.charity_campaign.start.js"
|
|
13
|
+
import { type CharityCampaignStopEvent, type CharityCampaignStopSubscription, makeCharityCampaignStopSubscription } from "./channel.charity_campaign.stop.js"
|
|
14
|
+
import { type ChannelChatClearEvent, type ChannelChatClearSubscription, makeChannelChatClearSubscription } from "./channel.chat.clear.js"
|
|
15
|
+
import { type ChannelChatClearUserMessagesEvent, type ChannelChatClearUserMessagesSubscription, makeChannelChatClearUserMessagesSubscription } from "./channel.chat.clear_user_messages.js"
|
|
16
|
+
import { type ChannelChatMessageDeleteEvent, type ChannelChatMessageDeleteSubscription, makeChannelChatMessageDeleteSubscription } from "./channel.chat.message_delete.js"
|
|
17
|
+
import { type ChannelChatNotificationEvent, type ChannelChatNotificationSubscription, makeChannelChatNotificationSubscription } from "./channel.chat.notification.js"
|
|
18
|
+
import { type ChannelCheerEvent, type ChannelCheerSubscription, makeChannelCheerSubscription } from "./channel.cheer.js"
|
|
19
|
+
import { type ChannelFollowEvent, type ChannelFollowSubscription, makeChannelFollowSubscription } from "./channel.follow.js"
|
|
20
|
+
import { type GoalBeginEvent, type GoalBeginSubscription, makeGoalBeginSubscription } from "./channel.goal.begin.js"
|
|
21
|
+
import { type GoalEndEvent, type GoalEndSubscription, makeGoalEndSubscription } from "./channel.goal.end.js"
|
|
22
|
+
import { type GoalProgressEvent, type GoalProgressSubscription, makeGoalProgressSubscription } from "./channel.goal.progress.js"
|
|
23
|
+
import { type ChannelGuestStarGuestUpdateEvent, type ChannelGuestStarGuestUpdateSubscription, makeChannelGuestStarGuestUpdateSubscription } from "./channel.guest_star_guest.update.js"
|
|
24
|
+
import { type ChannelGuestStarSessionBeginEvent, type ChannelGuestStarSessionBeginSubscription, makeChannelGuestStarSessionBeginSubscription } from "./channel.guest_star_session.begin.js"
|
|
25
|
+
import { type ChannelGuestStarSessionEndEvent, type ChannelGuestStarSessionEndSubscription, makeChannelGuestStarSessionEndSubscription } from "./channel.guest_star_session.end.js"
|
|
26
|
+
import { type ChannelGuestStarSettingsUpdateEvent, type ChannelGuestStarSettingsUpdateSubscription, makeChannelGuestStarSettingsUpdateSubscription } from "./channel.guest_star_settings.update.js"
|
|
27
|
+
import { type HypeTrainBeginEvent, type HypeTrainBeginSubscription, makeHypeTrainBeginSubscription } from "./channel.hype_train.begin.js"
|
|
28
|
+
import { type HypeTrainEndEvent, type HypeTrainEndSubscription, makeHypeTrainEndSubscription } from "./channel.hype_train.end.js"
|
|
29
|
+
import { type HypeTrainProgressEvent, type HypeTrainProgressSubscription, makeHypeTrainProgressSubscription } from "./channel.hype_train.progress.js"
|
|
30
|
+
import { type ChannelModeratorAddEvent, type ChannelModeratorAddSubscription, makeChannelModeratorAddSubscription } from "./channel.moderator.add.js"
|
|
31
|
+
import { type ChannelModeratorRemoveEvent, type ChannelModeratorRemoveSubscription, makeChannelModeratorRemoveSubscription } from "./channel.moderator.remove.js"
|
|
32
|
+
import { type ChannelPollBeginEvent, type ChannelPollBeginSubscription, makeChannelPollBeginSubscription } from "./channel.poll.begin.js"
|
|
33
|
+
import { type ChannelPollEndEvent, type ChannelPollEndSubscription, makeChannelPollEndSubscription } from "./channel.poll.end.js"
|
|
34
|
+
import { type ChannelPollProgressEvent, type ChannelPollProgressSubscription, makeChannelPollProgressSubscription } from "./channel.poll.progress.js"
|
|
35
|
+
import { type ChannelPredictionBeginEvent, type ChannelPredictionBeginSubscription, makeChannelPredictionBeginSubscription } from "./channel.prediction.begin.js"
|
|
36
|
+
import { type ChannelPredictionEndEvent, type ChannelPredictionEndSubscription, makeChannelPredictionEndSubscription } from "./channel.prediction.end.js"
|
|
37
|
+
import { type ChannelPredictionLockEvent, type ChannelPredictionLockSubscription, makeChannelPredictionLockSubscription } from "./channel.prediction.lock.js"
|
|
38
|
+
import { type ChannelPredictionProgressEvent, type ChannelPredictionProgressSubscription, makeChannelPredictionProgressSubscription } from "./channel.prediction.progress.js"
|
|
39
|
+
import { type ChannelRaidEvent, type ChannelRaidSubscription, makeChannelRaidSubscription } from "./channel.raid.js"
|
|
40
|
+
import { type ShieldModeBeginEvent, type ShieldModeBeginSubscription, makeShieldModeBeginSubscription } from "./channel.shield_mode.begin.js"
|
|
41
|
+
import { type ShieldModeEndEvent, type ShieldModeEndSubscription, makeShieldModeEndSubscription } from "./channel.shield_mode.end.js"
|
|
42
|
+
import { type ShoutoutCreateEvent, type ShoutoutCreateSubscription, makeShoutoutCreateSubscription } from "./channel.shoutout.create.js"
|
|
43
|
+
import { type ShoutoutReceiveEvent, type ShoutoutReceiveSubscription, makeShoutoutReceiveSubscription } from "./channel.shoutout.receive.js"
|
|
44
|
+
import { type ChannelSubscribeEvent, type ChannelSubscribeSubscription, makeChannelSubscribeSubscription } from "./channel.subscribe.js"
|
|
45
|
+
import { type ChannelSubscriptionEndEvent, type ChannelSubscriptionEndSubscription, makeChannelSubscriptionEndSubscription } from "./channel.subscription.end.js"
|
|
46
|
+
import { type ChannelSubscriptionGiftEvent, type ChannelSubscriptionGiftSubscription, makeChannelSubscriptionGiftSubscription } from "./channel.subscription.gift.js"
|
|
47
|
+
import { type ChannelSubscriptionMessageEvent, type ChannelSubscriptionMessageSubscription, makeChannelSubscriptionMessageSubscription } from "./channel.subscription.message.js"
|
|
48
|
+
import { type ChannelUnbanEvent, type ChannelUnbanSubscription, makeChannelUnbanSubscription } from "./channel.unban.js"
|
|
49
|
+
import { type ChannelUpdateEvent, type ChannelUpdateSubscription, makeChannelUpdateSubscription } from "./channel.update.js"
|
|
50
|
+
import { type StreamOfflineEvent, type StreamOfflineSubscription, makeStreamOfflineSubscription } from "./stream.offline.js"
|
|
51
|
+
import { type StreamOnlineEvent, type StreamOnlineSubscription, makeStreamOnlineSubscription } from "./stream.online.js"
|
|
52
|
+
import { type UserUpdateEvent, type UserUpdateSubscription, makeUserUpdateSubscription } from "./user.update.js"
|
|
53
53
|
|
|
54
54
|
export * from "./channel.ad_break.begin.js"
|
|
55
55
|
export * from "./channel.ban.js"
|
package/src/eventsub/eventsub.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import createDefer from "@overlaysymphony/core/libs/defer"
|
|
2
2
|
import createPubSub from "@overlaysymphony/core/libs/pubsub"
|
|
3
3
|
|
|
4
|
-
import { Authentication } from "../authentication/index.js"
|
|
4
|
+
import { type Authentication } from "../authentication/index.js"
|
|
5
5
|
import { createSubscription } from "../helix/subscriptions/index.js"
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
-
TwitchNotificationMessage,
|
|
9
|
-
TwitchSubscriptionType,
|
|
8
|
+
type TwitchNotificationMessage,
|
|
9
|
+
type TwitchSubscriptionType,
|
|
10
10
|
} from "./events/index.js"
|
|
11
|
-
import { TwitchMessage } from "./messages.js"
|
|
11
|
+
import { type TwitchMessage } from "./messages.js"
|
|
12
12
|
|
|
13
13
|
type EventSubListener = (
|
|
14
14
|
callback: (event: TwitchNotificationMessage["payload"]) => void,
|
|
@@ -35,8 +35,8 @@ export async function createEventSub(
|
|
|
35
35
|
const pubsub = createPubSub<TwitchNotificationMessage["payload"]>()
|
|
36
36
|
const socket = new WebSocket("wss://eventsub.wss.twitch.tv/ws")
|
|
37
37
|
|
|
38
|
-
socket.addEventListener("message",
|
|
39
|
-
const data = JSON.parse(rawData) as TwitchMessage
|
|
38
|
+
socket.addEventListener("message", ({ data: rawData }) => {
|
|
39
|
+
const data = JSON.parse(rawData as string) as TwitchMessage
|
|
40
40
|
data.type = data.metadata.message_type
|
|
41
41
|
|
|
42
42
|
if (data.type === "session_welcome") {
|
|
@@ -58,7 +58,6 @@ export async function createEventSub(
|
|
|
58
58
|
|
|
59
59
|
const listen: EventSubListener = (callback) => {
|
|
60
60
|
return pubsub.subscribe((event) => {
|
|
61
|
-
// @ts-ignore
|
|
62
61
|
callback(event)
|
|
63
62
|
})
|
|
64
63
|
}
|
|
@@ -67,14 +66,14 @@ export async function createEventSub(
|
|
|
67
66
|
for (const type of types) {
|
|
68
67
|
if (!subscriptions[type]) {
|
|
69
68
|
subscriptions[type] = true
|
|
70
|
-
createSubscription(sessionId, authentication, type)
|
|
69
|
+
void createSubscription(sessionId, authentication, type)
|
|
71
70
|
}
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
return pubsub.subscribe((event) => {
|
|
75
|
-
// @ts-
|
|
74
|
+
// @ts-expect-error: generic events are complicated
|
|
76
75
|
if (types.includes(event.type)) {
|
|
77
|
-
// @ts-
|
|
76
|
+
// @ts-expect-error: generic events are complicated
|
|
78
77
|
callback(event)
|
|
79
78
|
}
|
|
80
79
|
})
|
package/src/eventsub/messages.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Authentication } from "../../authentication/index.js"
|
|
1
|
+
import { type Authentication } from "../../authentication/index.js"
|
|
2
2
|
import { helix } from "../helix.js"
|
|
3
3
|
|
|
4
4
|
interface CustomReward {
|
|
@@ -49,8 +49,7 @@ export async function getCustomRewards(
|
|
|
49
49
|
never,
|
|
50
50
|
{
|
|
51
51
|
broadcaster_id: string
|
|
52
|
-
}
|
|
53
|
-
never
|
|
52
|
+
}
|
|
54
53
|
>(authentication, {
|
|
55
54
|
method: "get",
|
|
56
55
|
path: "/channel_points/custom_rewards",
|
package/src/helix/helix.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Authentication } from "../../authentication/index.js"
|
|
1
|
+
import { type Authentication } from "../../authentication/index.js"
|
|
2
2
|
import {
|
|
3
|
-
TwitchSubscription,
|
|
4
|
-
TwitchSubscriptionType,
|
|
3
|
+
type TwitchSubscription,
|
|
4
|
+
type TwitchSubscriptionType,
|
|
5
5
|
buildSubscription,
|
|
6
6
|
} from "../../eventsub/events/index.js"
|
|
7
|
-
import { BaseSubscription } from "../../eventsub/events-helpers.js"
|
|
7
|
+
import { type BaseSubscription } from "../../eventsub/events-helpers.js"
|
|
8
8
|
import { helix } from "../helix.js"
|
|
9
9
|
|
|
10
10
|
interface SubscriptionWebhookTransport {
|
|
@@ -22,7 +22,7 @@ type SubscriptionTransport =
|
|
|
22
22
|
| SubscriptionWebhookTransport
|
|
23
23
|
| SubscriptionWebsocketTransport
|
|
24
24
|
|
|
25
|
-
export
|
|
25
|
+
export interface SubscriptionRequest<Subscription extends BaseSubscription> {
|
|
26
26
|
type: Subscription["type"]
|
|
27
27
|
version: Subscription["version"]
|
|
28
28
|
condition: Subscription["condition"]
|
|
@@ -61,20 +61,11 @@ export async function createSubscription<
|
|
|
61
61
|
authentication: Authentication,
|
|
62
62
|
type: Type,
|
|
63
63
|
): Promise<ActiveSubscription<Subscription>> {
|
|
64
|
-
const subscription = buildSubscription(
|
|
65
|
-
type,
|
|
66
|
-
authentication.user.id,
|
|
67
|
-
) as Subscription
|
|
64
|
+
const subscription = buildSubscription(type, authentication.user.id)
|
|
68
65
|
|
|
69
|
-
const [activeSubscription] = await helix
|
|
70
|
-
ActiveSubscription<Subscription>,
|
|
71
|
-
never,
|
|
72
|
-
never,
|
|
73
|
-
SubscriptionRequest<Subscription>
|
|
74
|
-
>(authentication, {
|
|
66
|
+
const [activeSubscription] = await helix(authentication, {
|
|
75
67
|
method: "post",
|
|
76
68
|
path: "/eventsub/subscriptions",
|
|
77
|
-
// @ts-ignore
|
|
78
69
|
body: {
|
|
79
70
|
...subscription,
|
|
80
71
|
transport: {
|
|
@@ -91,7 +82,7 @@ export async function deleteSubscription(
|
|
|
91
82
|
authentication: Authentication,
|
|
92
83
|
id: string,
|
|
93
84
|
): Promise<void> {
|
|
94
|
-
await helix<never, never, { id: string }
|
|
85
|
+
await helix<never, never, { id: string }>(authentication, {
|
|
95
86
|
method: "delete",
|
|
96
87
|
path: "/eventsub/subscriptions",
|
|
97
88
|
params: {
|
|
@@ -111,8 +102,7 @@ export async function getSubscriptions(
|
|
|
111
102
|
type?: TwitchSubscriptionType
|
|
112
103
|
user_id?: string
|
|
113
104
|
after?: string
|
|
114
|
-
}
|
|
115
|
-
never
|
|
105
|
+
}
|
|
116
106
|
>(authentication, {
|
|
117
107
|
method: "get",
|
|
118
108
|
path: "/eventsub/subscriptions",
|
package/src/helix/users/users.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import createQueue, { Queue } from "@overlaysymphony/core/libs/queue"
|
|
1
|
+
import createQueue, { type Queue } from "@overlaysymphony/core/libs/queue"
|
|
2
2
|
|
|
3
|
-
import { TwitchNotificationMessage } from "../../eventsub/events/index.js"
|
|
4
|
-
import { TwitchEventSub } from "../../eventsub/index.js"
|
|
3
|
+
import { type TwitchNotificationMessage } from "../../eventsub/events/index.js"
|
|
4
|
+
import { type TwitchEventSub } from "../../eventsub/index.js"
|
|
5
5
|
|
|
6
6
|
export type Alert = TwitchNotificationMessage<
|
|
7
7
|
| "channel.cheer"
|
package/src/helpers/goal/goal.ts
CHANGED
package/src/helpers/poll/poll.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { TwitchEventSub } from "../../eventsub/index.js"
|
|
1
|
+
import { type TwitchEventSub } from "../../eventsub/index.js"
|
|
2
2
|
|
|
3
3
|
export interface Poll {
|
|
4
|
+
id: string
|
|
4
5
|
title: string
|
|
5
6
|
choices: Array<{
|
|
6
7
|
id: string
|
|
@@ -10,7 +11,7 @@ export interface Poll {
|
|
|
10
11
|
votesChannelPoints: number
|
|
11
12
|
votesNormal: number
|
|
12
13
|
}>
|
|
13
|
-
endsAt
|
|
14
|
+
endsAt?: Date
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
const mapTypeToTrigger = {
|
|
@@ -24,14 +25,25 @@ export function onPoll(
|
|
|
24
25
|
handlePoll: (poll: Poll, trigger: "begin" | "progress" | "end") => void,
|
|
25
26
|
): void {
|
|
26
27
|
const poll: Poll = {
|
|
28
|
+
id: "",
|
|
27
29
|
title: "",
|
|
28
30
|
choices: [],
|
|
29
|
-
endsAt:
|
|
31
|
+
endsAt: undefined,
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
eventsub.subscribe(
|
|
33
35
|
["channel.poll.begin", "channel.poll.progress", "channel.poll.end"],
|
|
34
36
|
(payload) => {
|
|
37
|
+
// Twitch sometimes sends duplicate end events.
|
|
38
|
+
if (payload.type === "channel.poll.end") {
|
|
39
|
+
// Skip if its already ended
|
|
40
|
+
if (typeof poll.endsAt === "undefined") return
|
|
41
|
+
|
|
42
|
+
// Skip if its for the wrong poll.
|
|
43
|
+
if (payload.event.id !== poll.id) return
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
poll.id = payload.event.id
|
|
35
47
|
poll.title = payload.event.title
|
|
36
48
|
poll.choices = payload.event.choices.map(
|
|
37
49
|
({
|
|
@@ -55,6 +67,8 @@ export function onPoll(
|
|
|
55
67
|
payload.type === "channel.poll.progress"
|
|
56
68
|
) {
|
|
57
69
|
poll.endsAt = payload.event.ends_at
|
|
70
|
+
} else {
|
|
71
|
+
poll.endsAt = undefined
|
|
58
72
|
}
|
|
59
73
|
|
|
60
74
|
handlePoll(poll, mapTypeToTrigger[payload.type])
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TwitchEventSub } from "../../eventsub/index.js"
|
|
1
|
+
import { type TwitchEventSub } from "../../eventsub/index.js"
|
|
2
2
|
|
|
3
3
|
export interface Redemption {
|
|
4
4
|
id: string
|
|
@@ -14,16 +14,35 @@ export interface Redemption {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
export function onRedemption(
|
|
18
|
+
eventsub: TwitchEventSub,
|
|
19
|
+
handleRedemption: (redemption: Redemption) => void,
|
|
20
|
+
): void
|
|
17
21
|
export function onRedemption(
|
|
18
22
|
eventsub: TwitchEventSub,
|
|
19
23
|
id: string,
|
|
20
24
|
handleRedemption: (redemption: Redemption) => void,
|
|
25
|
+
): void
|
|
26
|
+
|
|
27
|
+
export function onRedemption(
|
|
28
|
+
eventsub: TwitchEventSub,
|
|
29
|
+
...config:
|
|
30
|
+
| [string, (redemption: Redemption) => void]
|
|
31
|
+
| [(redemption: Redemption) => void]
|
|
21
32
|
): void {
|
|
33
|
+
const id = typeof config[0] === "string" ? config[0] : undefined
|
|
34
|
+
const handleRedemption =
|
|
35
|
+
typeof config[0] === "function"
|
|
36
|
+
? config[0]
|
|
37
|
+
: typeof config[1] === "function"
|
|
38
|
+
? config[1]
|
|
39
|
+
: undefined
|
|
40
|
+
|
|
22
41
|
eventsub.subscribe(
|
|
23
42
|
["channel.channel_points_custom_reward_redemption.add"],
|
|
24
43
|
(payload) => {
|
|
25
44
|
if (payload.event.reward.id === id) {
|
|
26
|
-
handleRedemption({
|
|
45
|
+
handleRedemption?.({
|
|
27
46
|
id: payload.event.id,
|
|
28
47
|
userId: payload.event.user_id,
|
|
29
48
|
userLogin: payload.event.user_login,
|