@overlaysymphony/twitch 0.1.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.
Files changed (95) hide show
  1. package/README.md +9 -0
  2. package/package.json +40 -0
  3. package/src/authentication/authentication.ts +107 -0
  4. package/src/authentication/index.ts +1 -0
  5. package/src/chat/chat.ts +160 -0
  6. package/src/chat/index.ts +6 -0
  7. package/src/chat/interfaces/events.ts +269 -0
  8. package/src/chat/interfaces/index.ts +9 -0
  9. package/src/chat/parser.ts +265 -0
  10. package/src/eventsub/events/channel.ad_break.begin.ts +51 -0
  11. package/src/eventsub/events/channel.ban.ts +59 -0
  12. package/src/eventsub/events/channel.channel_points_custom_reward._.ts +29 -0
  13. package/src/eventsub/events/channel.channel_points_custom_reward.add.ts +75 -0
  14. package/src/eventsub/events/channel.channel_points_custom_reward.remove.ts +77 -0
  15. package/src/eventsub/events/channel.channel_points_custom_reward.update.ts +77 -0
  16. package/src/eventsub/events/channel.channel_points_custom_reward_redemption._.ts +10 -0
  17. package/src/eventsub/events/channel.channel_points_custom_reward_redemption.add.ts +59 -0
  18. package/src/eventsub/events/channel.channel_points_custom_reward_redemption.update.ts +59 -0
  19. package/src/eventsub/events/channel.charity_campaign.donate.ts +66 -0
  20. package/src/eventsub/events/channel.charity_campaign.progress.ts +67 -0
  21. package/src/eventsub/events/channel.charity_campaign.start.ts +69 -0
  22. package/src/eventsub/events/channel.charity_campaign.stop.ts +69 -0
  23. package/src/eventsub/events/channel.chat.clear.ts +42 -0
  24. package/src/eventsub/events/channel.chat.clear_user_messages.ts +48 -0
  25. package/src/eventsub/events/channel.chat.message_delete.ts +50 -0
  26. package/src/eventsub/events/channel.chat.notification.ts +50 -0
  27. package/src/eventsub/events/channel.cheer.ts +51 -0
  28. package/src/eventsub/events/channel.follow.ts +50 -0
  29. package/src/eventsub/events/channel.goal.begin.ts +51 -0
  30. package/src/eventsub/events/channel.goal.end.ts +55 -0
  31. package/src/eventsub/events/channel.goal.progress.ts +51 -0
  32. package/src/eventsub/events/channel.guest_star_guest.update.ts +66 -0
  33. package/src/eventsub/events/channel.guest_star_session.begin.ts +46 -0
  34. package/src/eventsub/events/channel.guest_star_session.end.ts +48 -0
  35. package/src/eventsub/events/channel.guest_star_settings.update.ts +50 -0
  36. package/src/eventsub/events/channel.hype_train._.ts +12 -0
  37. package/src/eventsub/events/channel.hype_train.begin.ts +57 -0
  38. package/src/eventsub/events/channel.hype_train.end.ts +55 -0
  39. package/src/eventsub/events/channel.hype_train.progress.ts +70 -0
  40. package/src/eventsub/events/channel.moderator.add.ts +45 -0
  41. package/src/eventsub/events/channel.moderator.remove.ts +45 -0
  42. package/src/eventsub/events/channel.poll._.ts +26 -0
  43. package/src/eventsub/events/channel.poll.begin.ts +55 -0
  44. package/src/eventsub/events/channel.poll.end.ts +57 -0
  45. package/src/eventsub/events/channel.poll.progress.ts +55 -0
  46. package/src/eventsub/events/channel.prediction._.ts +25 -0
  47. package/src/eventsub/events/channel.prediction.begin.ts +51 -0
  48. package/src/eventsub/events/channel.prediction.end.ts +55 -0
  49. package/src/eventsub/events/channel.prediction.lock.ts +51 -0
  50. package/src/eventsub/events/channel.prediction.progress.ts +51 -0
  51. package/src/eventsub/events/channel.raid.ts +49 -0
  52. package/src/eventsub/events/channel.shield_mode.begin.ts +50 -0
  53. package/src/eventsub/events/channel.shield_mode.end.ts +50 -0
  54. package/src/eventsub/events/channel.shoutout.create.ts +62 -0
  55. package/src/eventsub/events/channel.shoutout.receive.ts +52 -0
  56. package/src/eventsub/events/channel.subscribe.ts +49 -0
  57. package/src/eventsub/events/channel.subscription.end.ts +49 -0
  58. package/src/eventsub/events/channel.subscription.gift.ts +53 -0
  59. package/src/eventsub/events/channel.subscription.message.ts +67 -0
  60. package/src/eventsub/events/channel.unban.ts +51 -0
  61. package/src/eventsub/events/channel.update.ts +49 -0
  62. package/src/eventsub/events/index.ts +284 -0
  63. package/src/eventsub/events/stream.offline.ts +39 -0
  64. package/src/eventsub/events/stream.online.ts +45 -0
  65. package/src/eventsub/events/user.update.ts +45 -0
  66. package/src/eventsub/events-helpers.ts +29 -0
  67. package/src/eventsub/eventsub.ts +88 -0
  68. package/src/eventsub/index.ts +7 -0
  69. package/src/eventsub/messages.ts +34 -0
  70. package/src/helix/channel-points/custom-rewards.ts +63 -0
  71. package/src/helix/channel-points/index.ts +1 -0
  72. package/src/helix/helix.ts +89 -0
  73. package/src/helix/subscriptions/index.ts +1 -0
  74. package/src/helix/subscriptions/subscriptions.ts +122 -0
  75. package/src/helix/users/index.ts +1 -0
  76. package/src/helix/users/users.ts +42 -0
  77. package/src/helpers/alerts/alerts.ts +60 -0
  78. package/src/helpers/alerts/index.ts +2 -0
  79. package/src/helpers/charity/charity.ts +89 -0
  80. package/src/helpers/charity/index.ts +1 -0
  81. package/src/helpers/goal/goal.ts +38 -0
  82. package/src/helpers/goal/index.ts +1 -0
  83. package/src/helpers/hype-train/hype-train.ts +51 -0
  84. package/src/helpers/hype-train/index.ts +1 -0
  85. package/src/helpers/poll/index.ts +1 -0
  86. package/src/helpers/poll/poll.ts +63 -0
  87. package/src/helpers/prediction/index.ts +1 -0
  88. package/src/helpers/prediction/prediction.ts +66 -0
  89. package/src/helpers/redemption/index.ts +1 -0
  90. package/src/helpers/redemption/redemption.ts +42 -0
  91. package/src/helpers/status/index.ts +1 -0
  92. package/src/helpers/status/status.ts +61 -0
  93. package/src/setupTests.ts +0 -0
  94. package/src/ui/authentication.ts +230 -0
  95. package/src/ui/popup.ts +115 -0
@@ -0,0 +1,62 @@
1
+ import { BaseSubscription } from "../events-helpers.js"
2
+
3
+ type ShoutoutCreateType = "channel.shoutout.create"
4
+ type ShoutoutCreateVersion = "1"
5
+
6
+ /** The parameters under which an event fires when The broadcaster sends a Shoutout. */
7
+ export interface ShoutoutCreateCondition {
8
+ /** The user ID of the broadcaster. */
9
+ broadcaster_user_id: string
10
+ /** The user ID of the moderator or broadcaster. */
11
+ moderator_user_id: string
12
+ }
13
+
14
+ /** The event information when The broadcaster sends a Shoutout. */
15
+ export interface ShoutoutCreateEvent {
16
+ /** The user ID of the broadcaster. */
17
+ broadcaster_user_id: string
18
+ /** The user login of the broadcaster. */
19
+ broadcaster_user_login: string
20
+ /** The user name of the broadcaster. */
21
+ broadcaster_user_name: string
22
+ /** The user ID of the broadcaster that received the shoutout. */
23
+ to_broadcaster_user_id: string
24
+ /** The user login of the broadcaster. */
25
+ to_broadcaster_user_login: string
26
+ /** The user name of the broadcaster. */
27
+ to_broadcaster_user_name: string
28
+ /** The user ID of the moderator that sent the shoutout. If the broadcaster sent the shoutout, this ID is the same as the ID in broadcaster_user_id. */
29
+ moderator_user_id: string
30
+ /** The user login of the moderator. */
31
+ moderator_user_login: string
32
+ /** The user name of the moderator. */
33
+ moderator_user_name: string
34
+ /** Integer. The number of users that were watching the broadcaster's stream at the time of the shoutout. */
35
+ viewer_count: number
36
+ /** The time the moderator sent the shoutout. */
37
+ started_at: Date
38
+ /** The time the broadcaster may send a shoutout to a different broadcaster. */
39
+ cooldown_ends_at: Date
40
+ /** The time the broadcaster may send another shoutout to the broadcaster in to_broadcaster_user_id. */
41
+ target_cooldown_ends_at: Date
42
+ }
43
+
44
+ /** The event notification received when The broadcaster sends a Shoutout. */
45
+ export type ShoutoutCreateSubscription = BaseSubscription<
46
+ ShoutoutCreateType,
47
+ ShoutoutCreateVersion,
48
+ ShoutoutCreateCondition
49
+ >
50
+
51
+ export function makeShoutoutCreateSubscription(
52
+ userId: string,
53
+ ): ShoutoutCreateSubscription {
54
+ return {
55
+ type: "channel.shoutout.create",
56
+ version: "1",
57
+ condition: {
58
+ broadcaster_user_id: userId,
59
+ moderator_user_id: userId,
60
+ },
61
+ }
62
+ }
@@ -0,0 +1,52 @@
1
+ import { BaseSubscription } from "../events-helpers.js"
2
+
3
+ type ShoutoutReceiveType = "channel.shoutout.receive"
4
+ type ShoutoutReceiveVersion = "1"
5
+
6
+ /** The parameters under which an event fires when The broadcaster receives a Shoutout. */
7
+ export interface ShoutoutReceiveCondition {
8
+ /** The user ID of the broadcaster. */
9
+ broadcaster_user_id: string
10
+ /** The user ID of the moderator or broadcaster. */
11
+ moderator_user_id: string
12
+ }
13
+
14
+ /** The event information when The broadcaster receives a Shoutout. */
15
+ export interface ShoutoutReceiveEvent {
16
+ /** The user ID of the broadcaster. */
17
+ broadcaster_user_id: string
18
+ /** The user login of the broadcaster. */
19
+ broadcaster_user_login: string
20
+ /** The user name of the broadcaster. */
21
+ broadcaster_user_name: string
22
+ /** The user ID of the broadcaster that sent the shoutout. */
23
+ from_broadcaster_user_id: string
24
+ /** The user login of the broadcaster. */
25
+ from_broadcaster_user_login: string
26
+ /** The user name of the broadcaster. */
27
+ from_broadcaster_user_name: string
28
+ /** Integer. The number of users that were watching the from-broadcaster's stream at the time of the shoutout. */
29
+ viewer_count: number
30
+ /** The time the moderator sent the shoutout. */
31
+ started_at: Date
32
+ }
33
+
34
+ /** The event notification received when The broadcaster receives a Shoutout. */
35
+ export type ShoutoutReceiveSubscription = BaseSubscription<
36
+ ShoutoutReceiveType,
37
+ ShoutoutReceiveVersion,
38
+ ShoutoutReceiveCondition
39
+ >
40
+
41
+ export function makeShoutoutReceiveSubscription(
42
+ userId: string,
43
+ ): ShoutoutReceiveSubscription {
44
+ return {
45
+ type: "channel.shoutout.receive",
46
+ version: "1",
47
+ condition: {
48
+ broadcaster_user_id: userId,
49
+ moderator_user_id: userId,
50
+ },
51
+ }
52
+ }
@@ -0,0 +1,49 @@
1
+ import { BaseSubscription } from "../events-helpers.js"
2
+
3
+ type ChannelSubscribeType = "channel.subscribe"
4
+ type ChannelSubscribeVersion = "1"
5
+
6
+ /** The parameters under which an event fires when A user subscribes. This does not include resubscribes. */
7
+ export interface ChannelSubscribeCondition {
8
+ /** The user ID of the broadcaster. */
9
+ broadcaster_user_id: string
10
+ }
11
+
12
+ /** The event information when A user subscribes. This does not include resubscribes. */
13
+ export interface ChannelSubscribeEvent {
14
+ /** The user ID of the user who subscribed. */
15
+ user_id: string
16
+ /** The user login of the user who subscribed. */
17
+ user_login: string
18
+ /** The user name of the user who subscribed. */
19
+ user_name: string
20
+ /** The user ID of the broadcaster. */
21
+ broadcaster_user_id: string
22
+ /** The user login of the broadcaster. */
23
+ broadcaster_user_login: string
24
+ /** The user name of the broadcaster. */
25
+ broadcaster_user_name: string
26
+ /** The tier of the subscription. Valid values are 1000, 2000, and 3000. */
27
+ tier: string
28
+ /** Whether the subscription is a gift. */
29
+ is_gift: boolean
30
+ }
31
+
32
+ /** The event notification received when A user subscribes. This does not include resubscribes. */
33
+ export type ChannelSubscribeSubscription = BaseSubscription<
34
+ ChannelSubscribeType,
35
+ ChannelSubscribeVersion,
36
+ ChannelSubscribeCondition
37
+ >
38
+
39
+ export function makeChannelSubscribeSubscription(
40
+ userId: string,
41
+ ): ChannelSubscribeSubscription {
42
+ return {
43
+ type: "channel.subscribe",
44
+ version: "1",
45
+ condition: {
46
+ broadcaster_user_id: userId,
47
+ },
48
+ }
49
+ }
@@ -0,0 +1,49 @@
1
+ import { BaseSubscription } from "../events-helpers.js"
2
+
3
+ type ChannelSubscriptionEndType = "channel.subscription.end"
4
+ type ChannelSubscriptionEndVersion = "1"
5
+
6
+ /** The parameters under which an event fires when A subscription ends. */
7
+ export interface ChannelSubscriptionEndCondition {
8
+ /** The user ID of the broadcaster. */
9
+ broadcaster_user_id: string
10
+ }
11
+
12
+ /** The event information when A subscription ends. */
13
+ export interface ChannelSubscriptionEndEvent {
14
+ /** The user ID of the user whose subscription ended. */
15
+ user_id: string
16
+ /** The user login of the user whose subscription ended. */
17
+ user_login: string
18
+ /** The user name of the user whose subscription ended. */
19
+ user_name: string
20
+ /** The user ID of the broadcaster. */
21
+ broadcaster_user_id: string
22
+ /** The user login of the broadcaster. */
23
+ broadcaster_user_login: string
24
+ /** The user name of the broadcaster. */
25
+ broadcaster_user_name: string
26
+ /** The tier of the subscription that ended. Valid values are 1000, 2000, and 3000. */
27
+ tier: string
28
+ /** Whether the subscription was a gift. */
29
+ is_gift: boolean
30
+ }
31
+
32
+ /** The event notification received when A subscription ends. */
33
+ export type ChannelSubscriptionEndSubscription = BaseSubscription<
34
+ ChannelSubscriptionEndType,
35
+ ChannelSubscriptionEndVersion,
36
+ ChannelSubscriptionEndCondition
37
+ >
38
+
39
+ export function makeChannelSubscriptionEndSubscription(
40
+ userId: string,
41
+ ): ChannelSubscriptionEndSubscription {
42
+ return {
43
+ type: "channel.subscription.end",
44
+ version: "1",
45
+ condition: {
46
+ broadcaster_user_id: userId,
47
+ },
48
+ }
49
+ }
@@ -0,0 +1,53 @@
1
+ import { BaseSubscription } from "../events-helpers.js"
2
+
3
+ type ChannelSubscriptionGiftType = "channel.subscription.gift"
4
+ type ChannelSubscriptionGiftVersion = "1"
5
+
6
+ /** The parameters under which an event fires when A user gives a gift subscription to one or more users. */
7
+ export interface ChannelSubscriptionGiftCondition {
8
+ /** The user ID of the broadcaster. */
9
+ broadcaster_user_id: string
10
+ }
11
+
12
+ /** The event information when A user gives a gift subscription to one or more users. */
13
+ export interface ChannelSubscriptionGiftEvent {
14
+ /** The user ID of the user who sent the subscription gift. Set to null if it was an anonymous subscription gift. */
15
+ user_id: string
16
+ /** The user login of the user who sent the gift. Set to null if it was an anonymous subscription gift. */
17
+ user_login: string
18
+ /** The user name of the user who sent the gift. Set to null if it was an anonymous subscription gift. */
19
+ user_name: string
20
+ /** The user ID of the broadcaster. */
21
+ broadcaster_user_id: string
22
+ /** The user login of the broadcaster. */
23
+ broadcaster_user_login: string
24
+ /** The user name of the broadcaster. */
25
+ broadcaster_user_name: string
26
+ /** Integer. The number of subscriptions in the subscription gift. */
27
+ total: number
28
+ /** The tier of the subscriptions in the subscription gift. */
29
+ tier: string
30
+ /** Integer. The number of subscriptions gifted by this user in the channel. This value is null for anonymous gifts or if the gifter has opted out of sharing this information. */
31
+ cumulative_total: number
32
+ /** Whether the subscription gift was anonymous. */
33
+ is_anonymous: boolean
34
+ }
35
+
36
+ /** The event notification received when A user gives a gift subscription to one or more users. */
37
+ export type ChannelSubscriptionGiftSubscription = BaseSubscription<
38
+ ChannelSubscriptionGiftType,
39
+ ChannelSubscriptionGiftVersion,
40
+ ChannelSubscriptionGiftCondition
41
+ >
42
+
43
+ export function makeChannelSubscriptionGiftSubscription(
44
+ userId: string,
45
+ ): ChannelSubscriptionGiftSubscription {
46
+ return {
47
+ type: "channel.subscription.gift",
48
+ version: "1",
49
+ condition: {
50
+ broadcaster_user_id: userId,
51
+ },
52
+ }
53
+ }
@@ -0,0 +1,67 @@
1
+ import { BaseSubscription } from "../events-helpers.js"
2
+
3
+ type ChannelSubscriptionMessageType = "channel.subscription.message"
4
+ type ChannelSubscriptionMessageVersion = "1"
5
+
6
+ /** The parameters under which an event fires when A user sends a resubscription chat message. */
7
+ export interface ChannelSubscriptionMessageCondition {
8
+ /** The user ID of the broadcaster. */
9
+ broadcaster_user_id: string
10
+ }
11
+
12
+ /** The event information when A user sends a resubscription chat message. */
13
+ export interface ChannelSubscriptionMessageEvent {
14
+ /** The user ID of the user who sent a resubscription chat message. */
15
+ user_id: string
16
+ /** The user login of the user who sent a resubscription chat message. */
17
+ user_login: string
18
+ /** The user name of the user who a resubscription chat message. */
19
+ user_name: string
20
+ /** The user ID of the broadcaster. */
21
+ broadcaster_user_id: string
22
+ /** The user login of the broadcaster. */
23
+ broadcaster_user_login: string
24
+ /** The user name of the broadcaster. */
25
+ broadcaster_user_name: string
26
+ /** The tier of the user's subscription. */
27
+ tier: string
28
+ /** An object that contains the resubscription message and emote information needed to recreate the message. */
29
+ message: {
30
+ /** The text of the resubscription chat message. */
31
+ text: string
32
+ /** An array that includes the emote ID and start and end positions for where the emote appears in the text. */
33
+ emotes: Array<{
34
+ /** Integer. The index of where the Emote starts in the text. */
35
+ begin: number
36
+ /** Integer. The index of where the Emote ends in the text. */
37
+ end: number
38
+ /** The emote ID. */
39
+ id: string
40
+ }>
41
+ }
42
+ /** Integer. The total number of months the user is subscribed to the channel. */
43
+ cumulative_months: number
44
+ /** Integer. The number of consecutive months the user's current subscription is active. This value is null if the user has opted out of sharing this information. */
45
+ streak_months: number
46
+ /** Integer. The month duration of the subscription. */
47
+ duration_months: number
48
+ }
49
+
50
+ /** The event notification received when A user sends a resubscription chat message. */
51
+ export type ChannelSubscriptionMessageSubscription = BaseSubscription<
52
+ ChannelSubscriptionMessageType,
53
+ ChannelSubscriptionMessageVersion,
54
+ ChannelSubscriptionMessageCondition
55
+ >
56
+
57
+ export function makeChannelSubscriptionMessageSubscription(
58
+ userId: string,
59
+ ): ChannelSubscriptionMessageSubscription {
60
+ return {
61
+ type: "channel.subscription.message",
62
+ version: "1",
63
+ condition: {
64
+ broadcaster_user_id: userId,
65
+ },
66
+ }
67
+ }
@@ -0,0 +1,51 @@
1
+ import { BaseSubscription } from "../events-helpers.js"
2
+
3
+ type ChannelUnbanType = "channel.unban"
4
+ type ChannelUnbanVersion = "1"
5
+
6
+ /** The parameters under which an event fires when A moderator unbans a user. */
7
+ export interface ChannelUnbanCondition {
8
+ /** The user ID of the broadcaster. */
9
+ broadcaster_user_id: string
10
+ }
11
+
12
+ /** The event information when A moderator unbans a user. */
13
+ export interface ChannelUnbanEvent {
14
+ /** The user ID of the user who was unbanned. */
15
+ user_id: string
16
+ /** The user login of the user who was unbanned. */
17
+ user_login: string
18
+ /** The user name of the user who was unbanned. */
19
+ user_name: string
20
+ /** The user ID of the broadcaster. */
21
+ broadcaster_user_id: string
22
+ /** The user login of the broadcaster. */
23
+ broadcaster_user_login: string
24
+ /** The user name of the broadcaster. */
25
+ broadcaster_user_name: string
26
+ /** The user ID of the issuer of the unban. */
27
+ moderator_user_id: string
28
+ /** The user login of the issuer of the unban. */
29
+ moderator_user_login: string
30
+ /** The user name of the issuer of the unban. */
31
+ moderator_user_name: string
32
+ }
33
+
34
+ /** The event notification received when A moderator unbans a user. */
35
+ export type ChannelUnbanSubscription = BaseSubscription<
36
+ ChannelUnbanType,
37
+ ChannelUnbanVersion,
38
+ ChannelUnbanCondition
39
+ >
40
+
41
+ export function makeChannelUnbanSubscription(
42
+ userId: string,
43
+ ): ChannelUnbanSubscription {
44
+ return {
45
+ type: "channel.unban",
46
+ version: "1",
47
+ condition: {
48
+ broadcaster_user_id: userId,
49
+ },
50
+ }
51
+ }
@@ -0,0 +1,49 @@
1
+ import { BaseSubscription } from "../events-helpers.js"
2
+
3
+ type ChannelUpdateType = "channel.update"
4
+ type ChannelUpdateVersion = "2"
5
+
6
+ /** The parameters under which an event fires when The broadcaster updates their channel properties. e.g., category, title, content classification labels, broadcast, or language. */
7
+ export interface ChannelUpdateCondition {
8
+ /** The user ID of the broadcaster. */
9
+ broadcaster_user_id: string
10
+ }
11
+
12
+ /** The event information when The broadcaster updates their channel properties. e.g., category, title, content classification labels, broadcast, or language. */
13
+ export interface ChannelUpdateEvent {
14
+ /** The user ID of the broadcaster. */
15
+ broadcaster_user_id: string
16
+ /** The user login of the broadcaster. */
17
+ broadcaster_user_login: string
18
+ /** The user name of the broadcaster. */
19
+ broadcaster_user_name: string
20
+ /** The channel's stream title. */
21
+ title: string
22
+ /** The channel's broadcast language. */
23
+ language: string
24
+ /** The channel's category ID. */
25
+ category_id: string
26
+ /** The category name. */
27
+ category_name: string
28
+ /** Array of content classification label IDs currently applied on the Channel. */
29
+ content_classification_labels: string[]
30
+ }
31
+
32
+ /** The event notification received when The broadcaster updates their channel properties. e.g., category, title, content classification labels, broadcast, or language. */
33
+ export type ChannelUpdateSubscription = BaseSubscription<
34
+ ChannelUpdateType,
35
+ ChannelUpdateVersion,
36
+ ChannelUpdateCondition
37
+ >
38
+
39
+ export function makeChannelUpdateSubscription(
40
+ userId: string,
41
+ ): ChannelUpdateSubscription {
42
+ return {
43
+ type: "channel.update",
44
+ version: "2",
45
+ condition: {
46
+ broadcaster_user_id: userId,
47
+ },
48
+ }
49
+ }