@overlaysymphony/twitch 0.2.2 → 0.3.0
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/package.json +6 -2
- package/src/authentication/authentication.ts +1 -1
- package/src/authentication/index.ts +1 -1
- package/src/chat/chat.ts +69 -134
- package/src/chat/helpers.ts +33 -24
- package/src/chat/index.ts +4 -6
- package/src/chat/pronouns.ts +141 -0
- package/src/eventsub/events/automod.message.hold-2.ts +81 -0
- package/src/eventsub/events/automod.message.update-2.ts +94 -0
- package/src/eventsub/events/automod.settings.update-1.ts +65 -0
- package/src/eventsub/events/automod.terms.update-1.ts +59 -0
- package/src/eventsub/events/channel.ad_break.begin-1.ts +50 -0
- package/src/eventsub/events/channel.ban-1.ts +58 -0
- package/src/eventsub/events/channel.bits.use-1.ts +112 -0
- package/src/eventsub/events/channel.channel_points_automatic_reward_redemption.add-2.ts +88 -0
- package/src/eventsub/events/channel.channel_points_custom_reward.add-1.ts +101 -0
- package/src/eventsub/events/channel.channel_points_custom_reward.remove-1.ts +103 -0
- package/src/eventsub/events/channel.channel_points_custom_reward.update-1.ts +103 -0
- package/src/eventsub/events/channel.channel_points_custom_reward_redemption.add-1.ts +65 -0
- package/src/eventsub/events/channel.channel_points_custom_reward_redemption.update-1.ts +65 -0
- package/src/eventsub/events/channel.charity_campaign.donate-1.ts +69 -0
- package/src/eventsub/events/channel.charity_campaign.progress-1.ts +74 -0
- package/src/eventsub/events/channel.charity_campaign.start-1.ts +76 -0
- package/src/eventsub/events/channel.charity_campaign.stop-1.ts +76 -0
- package/src/eventsub/events/channel.chat.clear-1.ts +41 -0
- package/src/eventsub/events/channel.chat.clear_user_messages-1.ts +47 -0
- package/src/eventsub/events/channel.chat.message-1.ts +160 -0
- package/src/eventsub/events/channel.chat.message_delete-1.ts +49 -0
- package/src/eventsub/events/channel.chat.notification-1.ts +317 -0
- package/src/eventsub/events/channel.chat.user_message_hold-1.ts +75 -0
- package/src/eventsub/events/channel.chat.user_message_update-1.ts +82 -0
- package/src/eventsub/events/channel.chat_settings.update-1.ts +83 -0
- package/src/eventsub/events/channel.cheer-1.ts +50 -0
- package/src/eventsub/events/channel.follow-2.ts +49 -0
- package/src/eventsub/events/channel.goal.begin-1.ts +80 -0
- package/src/eventsub/events/channel.goal.end-1.ts +80 -0
- package/src/eventsub/events/channel.goal.progress-1.ts +80 -0
- package/src/eventsub/events/channel.guest_star_guest.update-beta.ts +85 -0
- package/src/eventsub/events/channel.guest_star_session.begin-beta.ts +50 -0
- package/src/eventsub/events/channel.guest_star_session.end-beta.ts +58 -0
- package/src/eventsub/events/channel.guest_star_settings.update-beta.ts +62 -0
- package/src/eventsub/events/channel.hype_train.begin-2.ts +90 -0
- package/src/eventsub/events/channel.hype_train.end-2.ts +70 -0
- package/src/eventsub/events/channel.hype_train.progress-2.ts +90 -0
- package/src/eventsub/events/channel.moderate-2.ts +258 -0
- package/src/eventsub/events/channel.moderator.add-1.ts +44 -0
- package/src/eventsub/events/channel.moderator.remove-1.ts +44 -0
- package/src/eventsub/events/channel.poll.begin-1.ts +73 -0
- package/src/eventsub/events/channel.poll.end-1.ts +75 -0
- package/src/eventsub/events/channel.poll.progress-1.ts +73 -0
- package/src/eventsub/events/channel.prediction.begin-1.ts +72 -0
- package/src/eventsub/events/channel.prediction.end-1.ts +76 -0
- package/src/eventsub/events/channel.prediction.lock-1.ts +72 -0
- package/src/eventsub/events/channel.prediction.progress-1.ts +72 -0
- package/src/eventsub/events/channel.raid-1.ts +48 -0
- package/src/eventsub/events/channel.shared_chat.begin-1.ts +55 -0
- package/src/eventsub/events/channel.shared_chat.end-1.ts +46 -0
- package/src/eventsub/events/channel.shared_chat.update-1.ts +55 -0
- package/src/eventsub/events/channel.shield_mode.begin-1.ts +51 -0
- package/src/eventsub/events/channel.shield_mode.end-1.ts +51 -0
- package/src/eventsub/events/channel.shoutout.create-1.ts +61 -0
- package/src/eventsub/events/channel.shoutout.receive-1.ts +51 -0
- package/src/eventsub/events/channel.subscribe-1.ts +48 -0
- package/src/eventsub/events/channel.subscription.end-1.ts +48 -0
- package/src/eventsub/events/channel.subscription.gift-1.ts +52 -0
- package/src/eventsub/events/channel.subscription.message-1.ts +66 -0
- package/src/eventsub/events/channel.suspicious_user.message-1.ts +85 -0
- package/src/eventsub/events/channel.suspicious_user.update-1.ts +55 -0
- package/src/eventsub/events/channel.unban-1.ts +50 -0
- package/src/eventsub/events/channel.unban_request.create-1.ts +53 -0
- package/src/eventsub/events/channel.unban_request.resolve-1.ts +64 -0
- package/src/eventsub/events/channel.update-2.ts +48 -0
- package/src/eventsub/events/channel.vip.add-1.ts +44 -0
- package/src/eventsub/events/channel.vip.remove-1.ts +44 -0
- package/src/eventsub/events/channel.warning.acknowledge-1.ts +47 -0
- package/src/eventsub/events/channel.warning.send-1.ts +57 -0
- package/src/eventsub/events/index.ts +73 -284
- package/src/eventsub/events/stream.offline-1.ts +38 -0
- package/src/eventsub/events/stream.online-1.ts +44 -0
- package/src/eventsub/events/user.update-1.ts +48 -0
- package/src/eventsub/events/user.whisper.message-1.ts +51 -0
- package/src/eventsub/events-helpers.ts +52 -24
- package/src/eventsub/eventsub.ts +37 -74
- package/src/eventsub/index.ts +8 -6
- package/src/eventsub/messages.ts +16 -4
- package/src/helix/channel-points/custom-rewards.ts +120 -33
- package/src/helix/channel-points/index.ts +1 -1
- package/src/helix/channels/channels.ts +39 -0
- package/src/helix/channels/index.ts +1 -0
- package/src/helix/chat/emotes.ts +49 -0
- package/src/helix/chat/index.ts +3 -0
- package/src/helix/chat/send.ts +109 -0
- package/src/helix/chat/shared.ts +49 -0
- package/src/helix/helix.ts +6 -21
- package/src/helix/subscriptions/index.ts +1 -1
- package/src/helix/subscriptions/subscriptions.ts +46 -48
- package/src/helix/users/index.ts +1 -1
- package/src/helix/users/users.ts +22 -19
- package/src/helpers/alerts/alerts.ts +5 -5
- package/src/helpers/alerts/index.ts +2 -2
- package/src/helpers/charity/charity.ts +2 -2
- package/src/helpers/charity/index.ts +1 -1
- package/src/helpers/goal/goal.ts +2 -2
- package/src/helpers/goal/index.ts +1 -1
- package/src/helpers/hype-train/hype-train.ts +2 -2
- package/src/helpers/hype-train/index.ts +1 -1
- package/src/helpers/poll/index.ts +1 -1
- package/src/helpers/poll/poll.ts +3 -3
- package/src/helpers/prediction/index.ts +1 -1
- package/src/helpers/prediction/prediction.ts +3 -3
- package/src/helpers/redemption/index.ts +1 -1
- package/src/helpers/redemption/redemption.ts +2 -2
- package/src/helpers/status/index.ts +1 -1
- package/src/helpers/status/status.ts +2 -2
- package/src/ui/authentication.ts +1 -1
- package/src/ui/popup.ts +26 -3
- package/src/chat/interfaces/events.ts +0 -269
- package/src/chat/interfaces/index.ts +0 -9
- package/src/chat/parser.ts +0 -254
- package/src/eventsub/events/channel.ad_break.begin.ts +0 -51
- package/src/eventsub/events/channel.ban.ts +0 -59
- package/src/eventsub/events/channel.channel_points_custom_reward._.ts +0 -29
- package/src/eventsub/events/channel.channel_points_custom_reward.add.ts +0 -75
- package/src/eventsub/events/channel.channel_points_custom_reward.remove.ts +0 -77
- package/src/eventsub/events/channel.channel_points_custom_reward.update.ts +0 -77
- package/src/eventsub/events/channel.channel_points_custom_reward_redemption._.ts +0 -10
- package/src/eventsub/events/channel.channel_points_custom_reward_redemption.add.ts +0 -59
- package/src/eventsub/events/channel.channel_points_custom_reward_redemption.update.ts +0 -59
- package/src/eventsub/events/channel.charity_campaign.donate.ts +0 -66
- package/src/eventsub/events/channel.charity_campaign.progress.ts +0 -67
- package/src/eventsub/events/channel.charity_campaign.start.ts +0 -69
- package/src/eventsub/events/channel.charity_campaign.stop.ts +0 -69
- package/src/eventsub/events/channel.chat.clear.ts +0 -42
- package/src/eventsub/events/channel.chat.clear_user_messages.ts +0 -48
- package/src/eventsub/events/channel.chat.message_delete.ts +0 -50
- package/src/eventsub/events/channel.chat.notification.ts +0 -50
- package/src/eventsub/events/channel.cheer.ts +0 -51
- package/src/eventsub/events/channel.follow.ts +0 -50
- package/src/eventsub/events/channel.goal.begin.ts +0 -51
- package/src/eventsub/events/channel.goal.end.ts +0 -55
- package/src/eventsub/events/channel.goal.progress.ts +0 -51
- package/src/eventsub/events/channel.guest_star_guest.update.ts +0 -66
- package/src/eventsub/events/channel.guest_star_session.begin.ts +0 -46
- package/src/eventsub/events/channel.guest_star_session.end.ts +0 -48
- package/src/eventsub/events/channel.guest_star_settings.update.ts +0 -50
- package/src/eventsub/events/channel.hype_train._.ts +0 -12
- package/src/eventsub/events/channel.hype_train.begin.ts +0 -57
- package/src/eventsub/events/channel.hype_train.end.ts +0 -55
- package/src/eventsub/events/channel.hype_train.progress.ts +0 -70
- package/src/eventsub/events/channel.moderator.add.ts +0 -45
- package/src/eventsub/events/channel.moderator.remove.ts +0 -45
- package/src/eventsub/events/channel.poll._.ts +0 -26
- package/src/eventsub/events/channel.poll.begin.ts +0 -55
- package/src/eventsub/events/channel.poll.end.ts +0 -57
- package/src/eventsub/events/channel.poll.progress.ts +0 -55
- package/src/eventsub/events/channel.prediction._.ts +0 -25
- package/src/eventsub/events/channel.prediction.begin.ts +0 -51
- package/src/eventsub/events/channel.prediction.end.ts +0 -55
- package/src/eventsub/events/channel.prediction.lock.ts +0 -51
- package/src/eventsub/events/channel.prediction.progress.ts +0 -51
- package/src/eventsub/events/channel.raid.ts +0 -49
- package/src/eventsub/events/channel.shield_mode.begin.ts +0 -50
- package/src/eventsub/events/channel.shield_mode.end.ts +0 -50
- package/src/eventsub/events/channel.shoutout.create.ts +0 -62
- package/src/eventsub/events/channel.shoutout.receive.ts +0 -52
- package/src/eventsub/events/channel.subscribe.ts +0 -49
- package/src/eventsub/events/channel.subscription.end.ts +0 -49
- package/src/eventsub/events/channel.subscription.gift.ts +0 -53
- package/src/eventsub/events/channel.subscription.message.ts +0 -67
- package/src/eventsub/events/channel.unban.ts +0 -51
- package/src/eventsub/events/channel.update.ts +0 -49
- package/src/eventsub/events/stream.offline.ts +0 -39
- package/src/eventsub/events/stream.online.ts +0 -45
- package/src/eventsub/events/user.update.ts +0 -45
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./subscriptions.
|
|
1
|
+
export * from "./subscriptions.ts"
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { type Authentication } from "../../authentication/index.
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
buildSubscription,
|
|
6
|
-
} from "../../eventsub/events/index.js"
|
|
7
|
-
import { type BaseSubscription } from "../../eventsub/events-helpers.js"
|
|
8
|
-
import { helix } from "../helix.js"
|
|
1
|
+
import { type Authentication } from "../../authentication/index.ts"
|
|
2
|
+
import { type EventConfigs, type EventType } from "../../eventsub/index.ts"
|
|
3
|
+
|
|
4
|
+
import { helix } from "../helix.ts"
|
|
9
5
|
|
|
10
6
|
interface SubscriptionWebhookTransport {
|
|
11
7
|
method: "webhook"
|
|
@@ -22,15 +18,15 @@ type SubscriptionTransport =
|
|
|
22
18
|
| SubscriptionWebhookTransport
|
|
23
19
|
| SubscriptionWebsocketTransport
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
type:
|
|
27
|
-
version:
|
|
28
|
-
condition:
|
|
21
|
+
interface SubscriptionRequest<Type extends EventType> {
|
|
22
|
+
type: EventConfigs[Type]["Type"]
|
|
23
|
+
version: EventConfigs[Type]["Version"]
|
|
24
|
+
condition: EventConfigs[Type]["Condition"]
|
|
29
25
|
transport: SubscriptionTransport
|
|
30
26
|
}
|
|
31
27
|
|
|
32
|
-
|
|
33
|
-
Subscription & {
|
|
28
|
+
type ActiveSubscription<Type extends EventType> =
|
|
29
|
+
EventConfigs[Type]["Subscription"] & {
|
|
34
30
|
id: string
|
|
35
31
|
status:
|
|
36
32
|
| "enabled"
|
|
@@ -53,60 +49,62 @@ export type ActiveSubscription<Subscription extends BaseSubscription> =
|
|
|
53
49
|
transport: SubscriptionTransport
|
|
54
50
|
}
|
|
55
51
|
|
|
56
|
-
|
|
57
|
-
Type
|
|
58
|
-
|
|
59
|
-
>(
|
|
60
|
-
sessionId: string,
|
|
61
|
-
authentication: Authentication,
|
|
62
|
-
type: Type,
|
|
63
|
-
): Promise<ActiveSubscription<Subscription>> {
|
|
64
|
-
const subscription = buildSubscription(type, authentication.user.id)
|
|
52
|
+
type ActiveSubscriptionResponse<Type extends EventType> = {
|
|
53
|
+
data: Array<ActiveSubscription<Type>>
|
|
54
|
+
}
|
|
65
55
|
|
|
66
|
-
|
|
67
|
-
|
|
56
|
+
export async function createSubscription<Type extends EventType>(
|
|
57
|
+
authentication: Authentication,
|
|
58
|
+
transport: SubscriptionTransport,
|
|
59
|
+
subscription: EventConfigs[Type]["Subscription"],
|
|
60
|
+
): Promise<ActiveSubscription<Type>> {
|
|
61
|
+
const {
|
|
62
|
+
data: [activeSubscription],
|
|
63
|
+
} = await helix<
|
|
64
|
+
ActiveSubscriptionResponse<EventType>,
|
|
65
|
+
never,
|
|
66
|
+
SubscriptionRequest<EventType>
|
|
67
|
+
>(authentication, {
|
|
68
|
+
method: "POST",
|
|
68
69
|
path: "/eventsub/subscriptions",
|
|
69
70
|
body: {
|
|
70
71
|
...subscription,
|
|
71
|
-
transport
|
|
72
|
-
method: "websocket" as const,
|
|
73
|
-
session_id: sessionId,
|
|
74
|
-
},
|
|
72
|
+
transport,
|
|
75
73
|
},
|
|
76
74
|
})
|
|
77
75
|
|
|
78
76
|
return activeSubscription
|
|
79
77
|
}
|
|
80
78
|
|
|
81
|
-
export async function deleteSubscription(
|
|
82
|
-
authentication: Authentication,
|
|
83
|
-
id: string,
|
|
84
|
-
): Promise<void> {
|
|
85
|
-
await helix<never, never, { id: string }>(authentication, {
|
|
86
|
-
method: "delete",
|
|
87
|
-
path: "/eventsub/subscriptions",
|
|
88
|
-
params: {
|
|
89
|
-
id,
|
|
90
|
-
},
|
|
91
|
-
})
|
|
92
|
-
}
|
|
93
|
-
|
|
94
79
|
export async function getSubscriptions(
|
|
95
80
|
authentication: Authentication,
|
|
96
|
-
): Promise<Array<ActiveSubscription<
|
|
97
|
-
const subscriptions = await helix<
|
|
98
|
-
|
|
81
|
+
): Promise<Array<ActiveSubscription<EventType>>> {
|
|
82
|
+
const { data: subscriptions } = await helix<
|
|
83
|
+
ActiveSubscriptionResponse<EventType>,
|
|
99
84
|
never,
|
|
100
85
|
{
|
|
101
|
-
status?: ActiveSubscription<
|
|
102
|
-
type?:
|
|
86
|
+
status?: ActiveSubscription<EventType>["status"]
|
|
87
|
+
type?: EventType
|
|
103
88
|
user_id?: string
|
|
104
89
|
after?: string
|
|
105
90
|
}
|
|
106
91
|
>(authentication, {
|
|
107
|
-
method: "
|
|
92
|
+
method: "GET",
|
|
108
93
|
path: "/eventsub/subscriptions",
|
|
109
94
|
})
|
|
110
95
|
|
|
111
96
|
return subscriptions
|
|
112
97
|
}
|
|
98
|
+
|
|
99
|
+
export async function deleteSubscription(
|
|
100
|
+
authentication: Authentication,
|
|
101
|
+
id: string,
|
|
102
|
+
): Promise<void> {
|
|
103
|
+
await helix<never, { id: string }>(authentication, {
|
|
104
|
+
method: "DELETE",
|
|
105
|
+
path: "/eventsub/subscriptions",
|
|
106
|
+
params: {
|
|
107
|
+
id,
|
|
108
|
+
},
|
|
109
|
+
})
|
|
110
|
+
}
|
package/src/helix/users/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./users.
|
|
1
|
+
export * from "./users.ts"
|
package/src/helix/users/users.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Authentication } from "../../authentication/index.
|
|
2
|
-
import { helix } from "../helix.
|
|
1
|
+
import { type Authentication } from "../../authentication/index.ts"
|
|
2
|
+
import { helix } from "../helix.ts"
|
|
3
3
|
|
|
4
4
|
export interface TwitchUser {
|
|
5
5
|
id: string
|
|
@@ -13,8 +13,12 @@ export interface TwitchUser {
|
|
|
13
13
|
created_at: Date
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
interface UsersResponse {
|
|
17
|
+
data: Array<
|
|
18
|
+
Omit<TwitchUser, "created_at"> & {
|
|
19
|
+
created_at: string
|
|
20
|
+
}
|
|
21
|
+
>
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
export async function getUsers(
|
|
@@ -22,21 +26,20 @@ export async function getUsers(
|
|
|
22
26
|
id?: string | string[],
|
|
23
27
|
login?: string | string[],
|
|
24
28
|
): Promise<TwitchUser[]> {
|
|
25
|
-
const data = await helix<
|
|
26
|
-
|
|
27
|
-
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
const { data: users } = await helix<
|
|
30
|
+
UsersResponse,
|
|
31
|
+
{ id?: string | string[]; login?: string | string[] }
|
|
32
|
+
>(authentication, {
|
|
33
|
+
method: "GET",
|
|
34
|
+
path: "/users",
|
|
35
|
+
params: {
|
|
36
|
+
id,
|
|
37
|
+
login,
|
|
34
38
|
},
|
|
35
|
-
|
|
36
|
-
...data,
|
|
37
|
-
created_at: new Date(created_at),
|
|
38
|
-
}),
|
|
39
|
-
)
|
|
39
|
+
})
|
|
40
40
|
|
|
41
|
-
return
|
|
41
|
+
return users.map(({ created_at, ...user }) => ({
|
|
42
|
+
...user,
|
|
43
|
+
created_at: new Date(created_at),
|
|
44
|
+
}))
|
|
42
45
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import createQueue, { type Queue } from "@overlaysymphony/core/libs/queue"
|
|
2
2
|
|
|
3
|
-
import { type
|
|
4
|
-
import { type TwitchEventSub } from "../../eventsub/index.
|
|
3
|
+
import { type EventPayload } from "../../eventsub/events-helpers.ts"
|
|
4
|
+
import { type TwitchEventSub } from "../../eventsub/index.ts"
|
|
5
5
|
|
|
6
|
-
export type Alert =
|
|
6
|
+
export type Alert = EventPayload<
|
|
7
7
|
| "channel.cheer"
|
|
8
8
|
| "channel.follow"
|
|
9
9
|
| "channel.raid"
|
|
10
10
|
| "channel.subscribe"
|
|
11
11
|
| "channel.subscription.gift"
|
|
12
12
|
| "channel.subscription.message"
|
|
13
|
-
>
|
|
13
|
+
>
|
|
14
14
|
|
|
15
15
|
export const mapTypeToPriority = {
|
|
16
16
|
"channel.follow": 0,
|
|
@@ -25,7 +25,7 @@ export function onAlert(
|
|
|
25
25
|
eventsub: TwitchEventSub,
|
|
26
26
|
handleAlert: (alert: Alert) => void,
|
|
27
27
|
): void {
|
|
28
|
-
eventsub.
|
|
28
|
+
eventsub.on(
|
|
29
29
|
[
|
|
30
30
|
"channel.cheer",
|
|
31
31
|
"channel.follow",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from "./alerts.
|
|
2
|
-
export * from "./alerts.
|
|
1
|
+
export { default } from "./alerts.ts"
|
|
2
|
+
export * from "./alerts.ts"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TwitchEventSub } from "../../eventsub/index.
|
|
1
|
+
import { type TwitchEventSub } from "../../eventsub/index.ts"
|
|
2
2
|
|
|
3
3
|
export interface Charity {
|
|
4
4
|
name: string
|
|
@@ -42,7 +42,7 @@ export function onCharity(
|
|
|
42
42
|
targetAmount: 0,
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
eventsub.
|
|
45
|
+
eventsub.on(
|
|
46
46
|
[
|
|
47
47
|
"channel.charity_campaign.start",
|
|
48
48
|
"channel.charity_campaign.progress",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./charity.
|
|
1
|
+
export * from "./charity.ts"
|
package/src/helpers/goal/goal.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TwitchEventSub } from "../../eventsub/index.
|
|
1
|
+
import { type TwitchEventSub } from "../../eventsub/index.ts"
|
|
2
2
|
|
|
3
3
|
export interface Goal {
|
|
4
4
|
type: string
|
|
@@ -24,7 +24,7 @@ export function onGoal(
|
|
|
24
24
|
targetAmount: 0,
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
eventsub.
|
|
27
|
+
eventsub.on(
|
|
28
28
|
["channel.goal.begin", "channel.goal.progress", "channel.goal.end"],
|
|
29
29
|
(payload) => {
|
|
30
30
|
goal.type = payload.event.type
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./goal.
|
|
1
|
+
export * from "./goal.ts"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TwitchEventSub } from "../../eventsub/index.
|
|
1
|
+
import { type TwitchEventSub } from "../../eventsub/index.ts"
|
|
2
2
|
|
|
3
3
|
export interface HypeTrain {
|
|
4
4
|
level: number
|
|
@@ -27,7 +27,7 @@ export function onHypeTrain(
|
|
|
27
27
|
goal: 0,
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
eventsub.
|
|
30
|
+
eventsub.on(
|
|
31
31
|
[
|
|
32
32
|
"channel.hype_train.begin",
|
|
33
33
|
"channel.hype_train.progress",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./hype-train.
|
|
1
|
+
export * from "./hype-train.ts"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./poll.
|
|
1
|
+
export * from "./poll.ts"
|
package/src/helpers/poll/poll.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TwitchEventSub } from "../../eventsub/index.
|
|
1
|
+
import { type TwitchEventSub } from "../../eventsub/index.ts"
|
|
2
2
|
|
|
3
3
|
export interface Poll {
|
|
4
4
|
id: string
|
|
@@ -31,7 +31,7 @@ export function onPoll(
|
|
|
31
31
|
endsAt: undefined,
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
eventsub.
|
|
34
|
+
eventsub.on(
|
|
35
35
|
["channel.poll.begin", "channel.poll.progress", "channel.poll.end"],
|
|
36
36
|
(payload) => {
|
|
37
37
|
// Twitch sometimes sends duplicate end events.
|
|
@@ -66,7 +66,7 @@ export function onPoll(
|
|
|
66
66
|
payload.type === "channel.poll.begin" ||
|
|
67
67
|
payload.type === "channel.poll.progress"
|
|
68
68
|
) {
|
|
69
|
-
poll.endsAt = payload.event.ends_at
|
|
69
|
+
poll.endsAt = new Date(payload.event.ends_at)
|
|
70
70
|
} else {
|
|
71
71
|
poll.endsAt = undefined
|
|
72
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./prediction.
|
|
1
|
+
export * from "./prediction.ts"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TwitchEventSub } from "../../eventsub/index.
|
|
1
|
+
import { type TwitchEventSub } from "../../eventsub/index.ts"
|
|
2
2
|
|
|
3
3
|
export interface Prediction {
|
|
4
4
|
title: string
|
|
@@ -32,7 +32,7 @@ export function onPrediction(
|
|
|
32
32
|
locksAt: new Date(""),
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
eventsub.
|
|
35
|
+
eventsub.on(
|
|
36
36
|
[
|
|
37
37
|
"channel.prediction.begin",
|
|
38
38
|
"channel.prediction.progress",
|
|
@@ -55,7 +55,7 @@ export function onPrediction(
|
|
|
55
55
|
payload.type === "channel.prediction.begin" ||
|
|
56
56
|
payload.type === "channel.prediction.progress"
|
|
57
57
|
) {
|
|
58
|
-
prediction.locksAt = payload.event.locks_at
|
|
58
|
+
prediction.locksAt = new Date(payload.event.locks_at)
|
|
59
59
|
} else {
|
|
60
60
|
prediction.locksAt = undefined
|
|
61
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./redemption.
|
|
1
|
+
export * from "./redemption.ts"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TwitchEventSub } from "../../eventsub/index.
|
|
1
|
+
import { type TwitchEventSub } from "../../eventsub/index.ts"
|
|
2
2
|
|
|
3
3
|
export interface Redemption {
|
|
4
4
|
id: string
|
|
@@ -38,7 +38,7 @@ export function onRedemption(
|
|
|
38
38
|
? config[1]
|
|
39
39
|
: undefined
|
|
40
40
|
|
|
41
|
-
eventsub.
|
|
41
|
+
eventsub.on(
|
|
42
42
|
["channel.channel_points_custom_reward_redemption.add"],
|
|
43
43
|
(payload) => {
|
|
44
44
|
if (typeof id === "undefined" || payload.event.reward.id === id) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./status.
|
|
1
|
+
export * from "./status.ts"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TwitchEventSub } from "../../eventsub/index.
|
|
1
|
+
import { type TwitchEventSub } from "../../eventsub/index.ts"
|
|
2
2
|
|
|
3
3
|
export interface Status {
|
|
4
4
|
online: boolean
|
|
@@ -22,7 +22,7 @@ export function onStatus(
|
|
|
22
22
|
labels: [],
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
eventsub.
|
|
25
|
+
eventsub.on(
|
|
26
26
|
[
|
|
27
27
|
"channel.update",
|
|
28
28
|
"stream.online",
|
package/src/ui/authentication.ts
CHANGED
package/src/ui/popup.ts
CHANGED
|
@@ -3,11 +3,27 @@ import querystring from "@overlaysymphony/core/libs/querystring"
|
|
|
3
3
|
import {
|
|
4
4
|
type BareAuthentication,
|
|
5
5
|
validateAuthentication,
|
|
6
|
-
} from "../authentication/index.
|
|
6
|
+
} from "../authentication/index.ts"
|
|
7
|
+
|
|
8
|
+
const status = document.getElementById("status")
|
|
9
|
+
const statuses = {
|
|
10
|
+
error: "Something went wrong.",
|
|
11
|
+
initializing: "Initializing Twitch authentication.",
|
|
12
|
+
validating: "Validating Twitch authenticate.",
|
|
13
|
+
ready: "Twitch authentication validated. You may close this window.",
|
|
14
|
+
}
|
|
15
|
+
function updateStatus(key: keyof typeof statuses, message?: string) {
|
|
16
|
+
if (!status) return
|
|
17
|
+
|
|
18
|
+
status.innerText = statuses[key] + (message ? ` ${message}` : "")
|
|
19
|
+
}
|
|
7
20
|
|
|
8
21
|
const state = getState()
|
|
9
22
|
|
|
10
23
|
if (state.step === "initial") {
|
|
24
|
+
updateStatus("initializing")
|
|
25
|
+
setTimeout(() => updateStatus("error"), 500)
|
|
26
|
+
|
|
11
27
|
initiateAuthentication(
|
|
12
28
|
state.clientId,
|
|
13
29
|
`${window.location.origin}${window.location.pathname}`,
|
|
@@ -16,14 +32,21 @@ if (state.step === "initial") {
|
|
|
16
32
|
}
|
|
17
33
|
|
|
18
34
|
if (state.step === "token") {
|
|
35
|
+
updateStatus("validating")
|
|
36
|
+
|
|
19
37
|
const authentication = await authenticateResult(state.clientId, state)
|
|
20
38
|
const opener = window.opener as Window | undefined
|
|
21
39
|
opener?.postMessage({ type: "authentication", authentication }, "*")
|
|
40
|
+
|
|
41
|
+
updateStatus("ready")
|
|
22
42
|
window.close()
|
|
23
43
|
}
|
|
24
44
|
|
|
25
45
|
if (state.step === "error") {
|
|
26
|
-
|
|
46
|
+
updateStatus(
|
|
47
|
+
"error",
|
|
48
|
+
`${state.error}${state.description ? `: ${state.description}` : "."}`,
|
|
49
|
+
)
|
|
27
50
|
}
|
|
28
51
|
|
|
29
52
|
function getState():
|
|
@@ -62,7 +85,7 @@ function getState():
|
|
|
62
85
|
!scope ? "Missing scope." : "",
|
|
63
86
|
!clientId ? "Missing state." : "",
|
|
64
87
|
]
|
|
65
|
-
.filter(
|
|
88
|
+
.filter((value) => !!value)
|
|
66
89
|
.join(" "),
|
|
67
90
|
}
|
|
68
91
|
}
|