@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.
- package/README.md +9 -0
- package/package.json +40 -0
- package/src/authentication/authentication.ts +107 -0
- package/src/authentication/index.ts +1 -0
- package/src/chat/chat.ts +160 -0
- package/src/chat/index.ts +6 -0
- package/src/chat/interfaces/events.ts +269 -0
- package/src/chat/interfaces/index.ts +9 -0
- package/src/chat/parser.ts +265 -0
- package/src/eventsub/events/channel.ad_break.begin.ts +51 -0
- package/src/eventsub/events/channel.ban.ts +59 -0
- package/src/eventsub/events/channel.channel_points_custom_reward._.ts +29 -0
- package/src/eventsub/events/channel.channel_points_custom_reward.add.ts +75 -0
- package/src/eventsub/events/channel.channel_points_custom_reward.remove.ts +77 -0
- package/src/eventsub/events/channel.channel_points_custom_reward.update.ts +77 -0
- package/src/eventsub/events/channel.channel_points_custom_reward_redemption._.ts +10 -0
- package/src/eventsub/events/channel.channel_points_custom_reward_redemption.add.ts +59 -0
- package/src/eventsub/events/channel.channel_points_custom_reward_redemption.update.ts +59 -0
- package/src/eventsub/events/channel.charity_campaign.donate.ts +66 -0
- package/src/eventsub/events/channel.charity_campaign.progress.ts +67 -0
- package/src/eventsub/events/channel.charity_campaign.start.ts +69 -0
- package/src/eventsub/events/channel.charity_campaign.stop.ts +69 -0
- package/src/eventsub/events/channel.chat.clear.ts +42 -0
- package/src/eventsub/events/channel.chat.clear_user_messages.ts +48 -0
- package/src/eventsub/events/channel.chat.message_delete.ts +50 -0
- package/src/eventsub/events/channel.chat.notification.ts +50 -0
- package/src/eventsub/events/channel.cheer.ts +51 -0
- package/src/eventsub/events/channel.follow.ts +50 -0
- package/src/eventsub/events/channel.goal.begin.ts +51 -0
- package/src/eventsub/events/channel.goal.end.ts +55 -0
- package/src/eventsub/events/channel.goal.progress.ts +51 -0
- package/src/eventsub/events/channel.guest_star_guest.update.ts +66 -0
- package/src/eventsub/events/channel.guest_star_session.begin.ts +46 -0
- package/src/eventsub/events/channel.guest_star_session.end.ts +48 -0
- package/src/eventsub/events/channel.guest_star_settings.update.ts +50 -0
- package/src/eventsub/events/channel.hype_train._.ts +12 -0
- package/src/eventsub/events/channel.hype_train.begin.ts +57 -0
- package/src/eventsub/events/channel.hype_train.end.ts +55 -0
- package/src/eventsub/events/channel.hype_train.progress.ts +70 -0
- package/src/eventsub/events/channel.moderator.add.ts +45 -0
- package/src/eventsub/events/channel.moderator.remove.ts +45 -0
- package/src/eventsub/events/channel.poll._.ts +26 -0
- package/src/eventsub/events/channel.poll.begin.ts +55 -0
- package/src/eventsub/events/channel.poll.end.ts +57 -0
- package/src/eventsub/events/channel.poll.progress.ts +55 -0
- package/src/eventsub/events/channel.prediction._.ts +25 -0
- package/src/eventsub/events/channel.prediction.begin.ts +51 -0
- package/src/eventsub/events/channel.prediction.end.ts +55 -0
- package/src/eventsub/events/channel.prediction.lock.ts +51 -0
- package/src/eventsub/events/channel.prediction.progress.ts +51 -0
- package/src/eventsub/events/channel.raid.ts +49 -0
- package/src/eventsub/events/channel.shield_mode.begin.ts +50 -0
- package/src/eventsub/events/channel.shield_mode.end.ts +50 -0
- package/src/eventsub/events/channel.shoutout.create.ts +62 -0
- package/src/eventsub/events/channel.shoutout.receive.ts +52 -0
- package/src/eventsub/events/channel.subscribe.ts +49 -0
- package/src/eventsub/events/channel.subscription.end.ts +49 -0
- package/src/eventsub/events/channel.subscription.gift.ts +53 -0
- package/src/eventsub/events/channel.subscription.message.ts +67 -0
- package/src/eventsub/events/channel.unban.ts +51 -0
- package/src/eventsub/events/channel.update.ts +49 -0
- package/src/eventsub/events/index.ts +284 -0
- package/src/eventsub/events/stream.offline.ts +39 -0
- package/src/eventsub/events/stream.online.ts +45 -0
- package/src/eventsub/events/user.update.ts +45 -0
- package/src/eventsub/events-helpers.ts +29 -0
- package/src/eventsub/eventsub.ts +88 -0
- package/src/eventsub/index.ts +7 -0
- package/src/eventsub/messages.ts +34 -0
- package/src/helix/channel-points/custom-rewards.ts +63 -0
- package/src/helix/channel-points/index.ts +1 -0
- package/src/helix/helix.ts +89 -0
- package/src/helix/subscriptions/index.ts +1 -0
- package/src/helix/subscriptions/subscriptions.ts +122 -0
- package/src/helix/users/index.ts +1 -0
- package/src/helix/users/users.ts +42 -0
- package/src/helpers/alerts/alerts.ts +60 -0
- package/src/helpers/alerts/index.ts +2 -0
- package/src/helpers/charity/charity.ts +89 -0
- package/src/helpers/charity/index.ts +1 -0
- package/src/helpers/goal/goal.ts +38 -0
- package/src/helpers/goal/index.ts +1 -0
- package/src/helpers/hype-train/hype-train.ts +51 -0
- package/src/helpers/hype-train/index.ts +1 -0
- package/src/helpers/poll/index.ts +1 -0
- package/src/helpers/poll/poll.ts +63 -0
- package/src/helpers/prediction/index.ts +1 -0
- package/src/helpers/prediction/prediction.ts +66 -0
- package/src/helpers/redemption/index.ts +1 -0
- package/src/helpers/redemption/redemption.ts +42 -0
- package/src/helpers/status/index.ts +1 -0
- package/src/helpers/status/status.ts +61 -0
- package/src/setupTests.ts +0 -0
- package/src/ui/authentication.ts +230 -0
- package/src/ui/popup.ts +115 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { ChatEvent, ChatEventSource } from "./interfaces/index.js"
|
|
2
|
+
|
|
3
|
+
// Parses an IRC message and returns a JSON object with the message's
|
|
4
|
+
// component parts (tags, source (nick and host), command, parameters).
|
|
5
|
+
// from https://dev.twitch.tv/docs/irc/example-parser/
|
|
6
|
+
|
|
7
|
+
export default function parseEvent(input: string): ChatEvent | undefined {
|
|
8
|
+
let tags: Record<string, unknown> | undefined = undefined
|
|
9
|
+
let source: ChatEventSource | undefined = undefined
|
|
10
|
+
|
|
11
|
+
let idx = 0
|
|
12
|
+
|
|
13
|
+
// tags
|
|
14
|
+
if (input[idx] === "@") {
|
|
15
|
+
const endIdx = input.indexOf(" ", idx)
|
|
16
|
+
tags = parseTags(input.slice(idx + 1, endIdx))
|
|
17
|
+
idx = endIdx + 1
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// source
|
|
21
|
+
if (input[idx] === ":") {
|
|
22
|
+
const endIdx = input.indexOf(" ", idx)
|
|
23
|
+
source = parseSource(input.slice(idx + 1, endIdx))
|
|
24
|
+
idx = endIdx + 1
|
|
25
|
+
|
|
26
|
+
if (source.user && tags?.["display-name"]) {
|
|
27
|
+
source.user = tags["display-name"] as string
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// core
|
|
32
|
+
try {
|
|
33
|
+
const hasParameters = input.indexOf(":", idx) > -1
|
|
34
|
+
if (hasParameters) {
|
|
35
|
+
const endIdx = input.indexOf(":", idx)
|
|
36
|
+
|
|
37
|
+
const message = parseCore(
|
|
38
|
+
input.slice(idx, endIdx - 1),
|
|
39
|
+
input.slice(endIdx + 1),
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
...message,
|
|
44
|
+
source,
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
tags,
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
const message = parseCore(input.slice(idx, input.length), "")
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
...message,
|
|
53
|
+
source,
|
|
54
|
+
// @ts-ignore
|
|
55
|
+
tags,
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
} catch (e) {
|
|
59
|
+
return undefined
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function parseSource(input: string): ChatEventSource {
|
|
64
|
+
const parts = input.split("!")
|
|
65
|
+
|
|
66
|
+
if (parts.length === 1) {
|
|
67
|
+
return {
|
|
68
|
+
host: parts[0],
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
host: parts[1],
|
|
74
|
+
user: parts[0],
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function parseTags(input: string): Record<string, unknown> {
|
|
79
|
+
const tags: Record<string, unknown> = {}
|
|
80
|
+
|
|
81
|
+
const parsedTags = input.split(";")
|
|
82
|
+
for (const tag of parsedTags) {
|
|
83
|
+
const [dashKey, value] = tag.split("=")
|
|
84
|
+
const key = toCamelCase(dashKey)
|
|
85
|
+
|
|
86
|
+
if (!value) {
|
|
87
|
+
tags[key] = undefined
|
|
88
|
+
continue
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (key === "badges" || key === "badgeInfo") {
|
|
92
|
+
const dict: Record<string, number> = {}
|
|
93
|
+
|
|
94
|
+
const badges = value.split(",")
|
|
95
|
+
for (const badge of badges) {
|
|
96
|
+
const parts = badge.split("/")
|
|
97
|
+
dict[parts[0]] = parseInt(parts[1])
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
tags[key] = dict
|
|
101
|
+
continue
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (key === "emotes") {
|
|
105
|
+
const dict: Record<string, Array<[string, string]>> = {}
|
|
106
|
+
|
|
107
|
+
const emotes = value.split("/")
|
|
108
|
+
for (const emote of emotes) {
|
|
109
|
+
const [id, rawPositions] = emote.split(":")
|
|
110
|
+
dict[id] = []
|
|
111
|
+
|
|
112
|
+
const positions = rawPositions.split(",")
|
|
113
|
+
for (const position of positions) {
|
|
114
|
+
const positionParts = position.split("-")
|
|
115
|
+
dict[id].push([positionParts[0], positionParts[1]])
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
tags[key] = dict
|
|
120
|
+
continue
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (key === "emoteSets") {
|
|
124
|
+
tags[key] = value.split(",")
|
|
125
|
+
continue
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (
|
|
129
|
+
key === "banDuration" ||
|
|
130
|
+
key === "pinnedChatPaidAmount" ||
|
|
131
|
+
key === "pinnedChatPaidExponent" ||
|
|
132
|
+
key === "slow" ||
|
|
133
|
+
false
|
|
134
|
+
) {
|
|
135
|
+
tags[key] = parseInt(value)
|
|
136
|
+
continue
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (
|
|
140
|
+
key === "firstMsg" ||
|
|
141
|
+
key === "mod" ||
|
|
142
|
+
key === "vip" ||
|
|
143
|
+
key === "subscriber" ||
|
|
144
|
+
key === "turbo" ||
|
|
145
|
+
key === "emoteOnly" ||
|
|
146
|
+
key === "followersOnly" ||
|
|
147
|
+
key === "subsOnly" ||
|
|
148
|
+
key === "pinnedChatPaidIsSystemMessage" ||
|
|
149
|
+
false
|
|
150
|
+
) {
|
|
151
|
+
tags[key] = !!parseInt(value)
|
|
152
|
+
continue
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
tags[key] = value
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return tags
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function parseCore(inputEvent: string, parameters: string): ChatEvent {
|
|
162
|
+
const [type, ...parts] = inputEvent.split(" ")
|
|
163
|
+
|
|
164
|
+
switch (type) {
|
|
165
|
+
case "PING":
|
|
166
|
+
// @ts-ignore
|
|
167
|
+
return {
|
|
168
|
+
type,
|
|
169
|
+
message: parameters,
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
case "001":
|
|
173
|
+
// @ts-ignore
|
|
174
|
+
return {
|
|
175
|
+
type,
|
|
176
|
+
channel: parts[0],
|
|
177
|
+
message: parameters,
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
case "CAP":
|
|
181
|
+
// @ts-ignore
|
|
182
|
+
return {
|
|
183
|
+
type,
|
|
184
|
+
enabled: parts[1] === "ACK",
|
|
185
|
+
nickname: parts[0],
|
|
186
|
+
capabilities: parameters.split(" "),
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
case "JOIN":
|
|
190
|
+
case "PART":
|
|
191
|
+
// @ts-ignore
|
|
192
|
+
return {
|
|
193
|
+
type,
|
|
194
|
+
channel: parts[0],
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
case "GLOBALUSERSTATE":
|
|
198
|
+
case "RECONNECT":
|
|
199
|
+
// @ts-ignore
|
|
200
|
+
return {
|
|
201
|
+
type,
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
case "CLEARCHAT":
|
|
205
|
+
case "HOSTTARGET":
|
|
206
|
+
case "NOTICE":
|
|
207
|
+
case "ROOMSTATE":
|
|
208
|
+
case "USERSTATE":
|
|
209
|
+
// @ts-ignore
|
|
210
|
+
return {
|
|
211
|
+
type,
|
|
212
|
+
channel: parts[0],
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
case "CLEARMSG":
|
|
216
|
+
case "USERNOTICE":
|
|
217
|
+
// @ts-ignore
|
|
218
|
+
return {
|
|
219
|
+
type,
|
|
220
|
+
channel: parts[0],
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
case "PRIVMSG":
|
|
224
|
+
case "WHISPER":
|
|
225
|
+
if (parameters[0] === "!") {
|
|
226
|
+
const index = parameters.indexOf(" ")
|
|
227
|
+
|
|
228
|
+
// @ts-ignore
|
|
229
|
+
return {
|
|
230
|
+
type: `${type}-COMMAND`,
|
|
231
|
+
channel: parts[0],
|
|
232
|
+
command: parameters.slice(1, index > -1 ? index : undefined),
|
|
233
|
+
parameters: index > -1 ? parameters.slice(index + 1) : undefined,
|
|
234
|
+
}
|
|
235
|
+
} else {
|
|
236
|
+
// @ts-ignore
|
|
237
|
+
return {
|
|
238
|
+
type,
|
|
239
|
+
channel: parts[0],
|
|
240
|
+
message: parameters,
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Ignoring all other numeric messages.
|
|
245
|
+
case "002":
|
|
246
|
+
case "003":
|
|
247
|
+
case "004":
|
|
248
|
+
case "353": // Tells you who else is in the chat room you're joining.
|
|
249
|
+
case "366":
|
|
250
|
+
case "372":
|
|
251
|
+
case "375":
|
|
252
|
+
case "376":
|
|
253
|
+
throw new Error(`Ignored message: ${type}`)
|
|
254
|
+
|
|
255
|
+
case "421":
|
|
256
|
+
throw new Error(`Unsupported message: ${type}`)
|
|
257
|
+
|
|
258
|
+
default:
|
|
259
|
+
throw new Error(`Unknown message: ${type}`)
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function toCamelCase(dashedCase: string): string {
|
|
264
|
+
return dashedCase.replace(/[-:]([a-z])/g, (_, b) => `${b.toUpperCase()}`)
|
|
265
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { BaseSubscription } from "../events-helpers.js"
|
|
2
|
+
|
|
3
|
+
type ChannelAdBreakBeginType = "channel.ad_break.begin"
|
|
4
|
+
type ChannelAdBreakBeginVersion = "beta"
|
|
5
|
+
|
|
6
|
+
/** The parameters under which an event fires when A midroll commercial break starts running. */
|
|
7
|
+
export interface ChannelAdBreakBeginCondition {
|
|
8
|
+
/** The user ID of the broadcaster. */
|
|
9
|
+
broadcaster_id: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** The event information when A midroll commercial break starts running. */
|
|
13
|
+
export interface ChannelAdBreakBeginEvent {
|
|
14
|
+
/** Integer. Length in seconds of the mid-roll ad break requested. */
|
|
15
|
+
length_seconds: number
|
|
16
|
+
/** The time the ad break began. Note that there is potential delay between this event, when the streamer requested the ad break, and when the viewers will see ads. */
|
|
17
|
+
timestamp: Date
|
|
18
|
+
/** Indicates if the ad was automatically scheduled via Ads Manager. */
|
|
19
|
+
is_automatic: boolean
|
|
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 user who requested the ad. For automatic ads, this will be the ID of the broadcaster. */
|
|
27
|
+
requester_user_id: string
|
|
28
|
+
/** The user name of the user who requested the ad. */
|
|
29
|
+
requester_user_name: string
|
|
30
|
+
/** The user login of the user who requested the ad. */
|
|
31
|
+
requester_user_login: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The event notification received when A midroll commercial break starts running. */
|
|
35
|
+
export type ChannelAdBreakBeginSubscription = BaseSubscription<
|
|
36
|
+
ChannelAdBreakBeginType,
|
|
37
|
+
ChannelAdBreakBeginVersion,
|
|
38
|
+
ChannelAdBreakBeginCondition
|
|
39
|
+
>
|
|
40
|
+
|
|
41
|
+
export function makeChannelAdBreakBeginSubscription(
|
|
42
|
+
userId: string,
|
|
43
|
+
): ChannelAdBreakBeginSubscription {
|
|
44
|
+
return {
|
|
45
|
+
type: "channel.ad_break.begin",
|
|
46
|
+
version: "beta",
|
|
47
|
+
condition: {
|
|
48
|
+
broadcaster_id: userId,
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { BaseSubscription } from "../events-helpers.js"
|
|
2
|
+
|
|
3
|
+
type ChannelBanType = "channel.ban"
|
|
4
|
+
type ChannelBanVersion = "1"
|
|
5
|
+
|
|
6
|
+
/** The parameters under which an event fires when A moderator bans a user. */
|
|
7
|
+
export interface ChannelBanCondition {
|
|
8
|
+
/** The user ID of the broadcaster. */
|
|
9
|
+
broadcaster_user_id: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** The event information when A moderator bans a user. */
|
|
13
|
+
export interface ChannelBanEvent {
|
|
14
|
+
/** The user ID of the user who was banned. */
|
|
15
|
+
user_id: string
|
|
16
|
+
/** The user login of the user who was banned. */
|
|
17
|
+
user_login: string
|
|
18
|
+
/** The user name of the user who was banned. */
|
|
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 ban. */
|
|
27
|
+
moderator_user_id: string
|
|
28
|
+
/** The user login of the issuer of the ban. */
|
|
29
|
+
moderator_user_login: string
|
|
30
|
+
/** The user name of the issuer of the ban. */
|
|
31
|
+
moderator_user_name: string
|
|
32
|
+
/** The reason behind the ban. */
|
|
33
|
+
reason: string
|
|
34
|
+
/** The time the user was banned or put in a timeout. */
|
|
35
|
+
banned_at: Date
|
|
36
|
+
/** The time the timeout ends. Is null if the user was banned instead of put in a timeout. */
|
|
37
|
+
ends_at: Date
|
|
38
|
+
/** Indicates whether the ban is permanent (true) or a timeout (false). If true, ends_at will be null. */
|
|
39
|
+
is_permanent: boolean
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The event notification received when A moderator bans a user. */
|
|
43
|
+
export type ChannelBanSubscription = BaseSubscription<
|
|
44
|
+
ChannelBanType,
|
|
45
|
+
ChannelBanVersion,
|
|
46
|
+
ChannelBanCondition
|
|
47
|
+
>
|
|
48
|
+
|
|
49
|
+
export function makeChannelBanSubscription(
|
|
50
|
+
userId: string,
|
|
51
|
+
): ChannelBanSubscription {
|
|
52
|
+
return {
|
|
53
|
+
type: "channel.ban",
|
|
54
|
+
version: "1",
|
|
55
|
+
condition: {
|
|
56
|
+
broadcaster_user_id: userId,
|
|
57
|
+
},
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface ChannelPointsCustomRewardGlobalCooldown {
|
|
2
|
+
/** Is the setting enabled. */
|
|
3
|
+
is_enabled: boolean
|
|
4
|
+
/** Integer. The cooldown in seconds. */
|
|
5
|
+
seconds: number
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ChannelPointsCustomRewardMaxPerStream {
|
|
9
|
+
/** Is the setting enabled. */
|
|
10
|
+
is_enabled: boolean
|
|
11
|
+
/** Integer. The max per stream limit. */
|
|
12
|
+
value: number
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ChannelPointsCustomRewardMaxPerUserPerStream {
|
|
16
|
+
/** Is the setting enabled. */
|
|
17
|
+
is_enabled: boolean
|
|
18
|
+
/** Integer. The max per user per stream limit. */
|
|
19
|
+
value: number
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ChannelPointsCustomRewardImage {
|
|
23
|
+
/** URL for the image at 1x size. */
|
|
24
|
+
url_1x: string
|
|
25
|
+
/** URL for the image at 2x size. */
|
|
26
|
+
url_2x: string
|
|
27
|
+
/** URL for the image at 3x size. */
|
|
28
|
+
url_4x: string
|
|
29
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { BaseSubscription } from "../events-helpers.js"
|
|
2
|
+
|
|
3
|
+
import { ChannelPointsCustomRewardGlobalCooldown, ChannelPointsCustomRewardImage, ChannelPointsCustomRewardMaxPerStream, ChannelPointsCustomRewardMaxPerUserPerStream } from "./channel.channel_points_custom_reward._.js"
|
|
4
|
+
|
|
5
|
+
type ChannelPointsCustomRewardAddType = "channel.channel_points_custom_reward.add"
|
|
6
|
+
type ChannelPointsCustomRewardAddVersion = "1"
|
|
7
|
+
|
|
8
|
+
/** The parameters under which an event fires when The broadcaster creates a custom channel points reward. */
|
|
9
|
+
export interface ChannelPointsCustomRewardAddCondition {
|
|
10
|
+
/** The user ID of the broadcaster. */
|
|
11
|
+
broadcaster_user_id: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** The event information when The broadcaster creates a custom channel points reward. */
|
|
15
|
+
export interface ChannelPointsCustomRewardAddEvent {
|
|
16
|
+
/** The reward identifier. */
|
|
17
|
+
id: string
|
|
18
|
+
/** The user ID of the broadcaster. */
|
|
19
|
+
broadcaster_user_id: string
|
|
20
|
+
/** The user login of the broadcaster. */
|
|
21
|
+
broadcaster_user_login: string
|
|
22
|
+
/** The user name of the broadcaster. */
|
|
23
|
+
broadcaster_user_name: string
|
|
24
|
+
/** Is the reward currently enabled. If false, the reward won't show up to viewers. */
|
|
25
|
+
is_enabled: boolean
|
|
26
|
+
/** Is the reward currently paused. If true, viewers can't redeem. */
|
|
27
|
+
is_paused: boolean
|
|
28
|
+
/** Is the reward currently in stock. If false, viewers can't redeem. */
|
|
29
|
+
is_in_stock: boolean
|
|
30
|
+
/** The reward title. */
|
|
31
|
+
title: string
|
|
32
|
+
/** Integer. The reward cost. */
|
|
33
|
+
cost: number
|
|
34
|
+
/** The reward description. */
|
|
35
|
+
prompt: string
|
|
36
|
+
/** Does the viewer need to enter information when redeeming the reward. */
|
|
37
|
+
is_user_input_required: boolean
|
|
38
|
+
/** Should redemptions be set to fulfilled status immediately when redeemed and skip the request queue instead of the normal unfulfilled status. */
|
|
39
|
+
should_redemptions_skip_request_queue: boolean
|
|
40
|
+
/** Whether a maximum per stream is enabled and what the maximum is. */
|
|
41
|
+
max_per_stream: ChannelPointsCustomRewardMaxPerStream
|
|
42
|
+
/** Whether a maximum per user per stream is enabled and what the maximum is. */
|
|
43
|
+
max_per_user_per_stream: ChannelPointsCustomRewardMaxPerUserPerStream
|
|
44
|
+
/** Custom background color for the reward. Format: Hex with # prefix. Example: #FA1ED2. */
|
|
45
|
+
background_color: string
|
|
46
|
+
/** Set of custom images of 1x, 2x and 4x sizes for the reward. Can be null if no images have been uploaded. */
|
|
47
|
+
image: ChannelPointsCustomRewardImage
|
|
48
|
+
/** Set of default images of 1x, 2x and 4x sizes for the reward. */
|
|
49
|
+
default_image: ChannelPointsCustomRewardImage
|
|
50
|
+
/** Whether a cooldown is enabled and what the cooldown is in seconds. */
|
|
51
|
+
global_cooldown: ChannelPointsCustomRewardGlobalCooldown
|
|
52
|
+
/** The time the cooldown expires. null if the reward isn't on cooldown. */
|
|
53
|
+
cooldown_expires_at: Date
|
|
54
|
+
/** Integer. The number of redemptions redeemed during the current live stream. Counts against the max_per_stream limit. null if the broadcasters stream isn't live or max_per_stream isn't enabled. */
|
|
55
|
+
redemptions_redeemed_current_stream: number
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The event notification received when The broadcaster creates a custom channel points reward. */
|
|
59
|
+
export type ChannelPointsCustomRewardAddSubscription = BaseSubscription<
|
|
60
|
+
ChannelPointsCustomRewardAddType,
|
|
61
|
+
ChannelPointsCustomRewardAddVersion,
|
|
62
|
+
ChannelPointsCustomRewardAddCondition
|
|
63
|
+
>
|
|
64
|
+
|
|
65
|
+
export function makeChannelPointsCustomRewardAddSubscription(
|
|
66
|
+
userId: string,
|
|
67
|
+
): ChannelPointsCustomRewardAddSubscription {
|
|
68
|
+
return {
|
|
69
|
+
type: "channel.channel_points_custom_reward.add",
|
|
70
|
+
version: "1",
|
|
71
|
+
condition: {
|
|
72
|
+
broadcaster_user_id: userId,
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { BaseSubscription } from "../events-helpers.js"
|
|
2
|
+
|
|
3
|
+
import { ChannelPointsCustomRewardGlobalCooldown, ChannelPointsCustomRewardImage, ChannelPointsCustomRewardMaxPerStream, ChannelPointsCustomRewardMaxPerUserPerStream } from "./channel.channel_points_custom_reward._.js"
|
|
4
|
+
|
|
5
|
+
type ChannelPointsCustomRewardRemoveType = "channel.channel_points_custom_reward.remove"
|
|
6
|
+
type ChannelPointsCustomRewardRemoveVersion = "1"
|
|
7
|
+
|
|
8
|
+
/** The parameters under which an event fires when The broadcaster removes a custom channel points reward. */
|
|
9
|
+
export interface ChannelPointsCustomRewardRemoveCondition {
|
|
10
|
+
/** The user ID of the broadcaster. */
|
|
11
|
+
broadcaster_user_id: string
|
|
12
|
+
/** Optional. Specify a reward ID to only receive notifications for a specific reward. */
|
|
13
|
+
reward_id?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The event information when The broadcaster removes a custom channel points reward. */
|
|
17
|
+
export interface ChannelPointsCustomRewardRemoveEvent {
|
|
18
|
+
/** The reward identifier. */
|
|
19
|
+
id: 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
|
+
/** Is the reward currently enabled. If false, the reward won't show up to viewers. */
|
|
27
|
+
is_enabled: boolean
|
|
28
|
+
/** Is the reward currently paused. If true, viewers can't redeem. */
|
|
29
|
+
is_paused: boolean
|
|
30
|
+
/** Is the reward currently in stock. If false, viewers can't redeem. */
|
|
31
|
+
is_in_stock: boolean
|
|
32
|
+
/** The reward title. */
|
|
33
|
+
title: string
|
|
34
|
+
/** Integer. The reward cost. */
|
|
35
|
+
cost: number
|
|
36
|
+
/** The reward description. */
|
|
37
|
+
prompt: string
|
|
38
|
+
/** Does the viewer need to enter information when redeeming the reward. */
|
|
39
|
+
is_user_input_required: boolean
|
|
40
|
+
/** Should redemptions be set to fulfilled status immediately when redeemed and skip the request queue instead of the normal unfulfilled status. */
|
|
41
|
+
should_redemptions_skip_request_queue: boolean
|
|
42
|
+
/** Whether a maximum per stream is enabled and what the maximum is. */
|
|
43
|
+
max_per_stream: ChannelPointsCustomRewardMaxPerStream
|
|
44
|
+
/** Whether a maximum per user per stream is enabled and what the maximum is. */
|
|
45
|
+
max_per_user_per_stream: ChannelPointsCustomRewardMaxPerUserPerStream
|
|
46
|
+
/** Custom background color for the reward. Format: Hex with # prefix. Example: #FA1ED2. */
|
|
47
|
+
background_color: string
|
|
48
|
+
/** Set of custom images of 1x, 2x and 4x sizes for the reward. Can be null if no images have been uploaded. */
|
|
49
|
+
image: ChannelPointsCustomRewardImage
|
|
50
|
+
/** Set of default images of 1x, 2x and 4x sizes for the reward. */
|
|
51
|
+
default_image: ChannelPointsCustomRewardImage
|
|
52
|
+
/** Whether a cooldown is enabled and what the cooldown is in seconds. */
|
|
53
|
+
global_cooldown: ChannelPointsCustomRewardGlobalCooldown
|
|
54
|
+
/** The time the cooldown expires. null if the reward isn't on cooldown. */
|
|
55
|
+
cooldown_expires_at: Date
|
|
56
|
+
/** Integer. The number of redemptions redeemed during the current live stream. Counts against the max_per_stream limit. null if the broadcasters stream isn't live or max_per_stream isn't enabled. */
|
|
57
|
+
redemptions_redeemed_current_stream: number
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The event notification received when The broadcaster removes a custom channel points reward. */
|
|
61
|
+
export type ChannelPointsCustomRewardRemoveSubscription = BaseSubscription<
|
|
62
|
+
ChannelPointsCustomRewardRemoveType,
|
|
63
|
+
ChannelPointsCustomRewardRemoveVersion,
|
|
64
|
+
ChannelPointsCustomRewardRemoveCondition
|
|
65
|
+
>
|
|
66
|
+
|
|
67
|
+
export function makeChannelPointsCustomRewardRemoveSubscription(
|
|
68
|
+
userId: string,
|
|
69
|
+
): ChannelPointsCustomRewardRemoveSubscription {
|
|
70
|
+
return {
|
|
71
|
+
type: "channel.channel_points_custom_reward.remove",
|
|
72
|
+
version: "1",
|
|
73
|
+
condition: {
|
|
74
|
+
broadcaster_user_id: userId,
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { BaseSubscription } from "../events-helpers.js"
|
|
2
|
+
|
|
3
|
+
import { ChannelPointsCustomRewardGlobalCooldown, ChannelPointsCustomRewardImage, ChannelPointsCustomRewardMaxPerStream, ChannelPointsCustomRewardMaxPerUserPerStream } from "./channel.channel_points_custom_reward._.js"
|
|
4
|
+
|
|
5
|
+
type ChannelPointsCustomRewardUpdateType = "channel.channel_points_custom_reward.update"
|
|
6
|
+
type ChannelPointsCustomRewardUpdateVersion = "1"
|
|
7
|
+
|
|
8
|
+
/** The parameters under which an event fires when The broadcaster updates a custom channel points reward. */
|
|
9
|
+
export interface ChannelPointsCustomRewardUpdateCondition {
|
|
10
|
+
/** The user ID of the broadcaster. */
|
|
11
|
+
broadcaster_user_id: string
|
|
12
|
+
/** Optional. Specify a reward ID to only receive notifications for a specific reward. */
|
|
13
|
+
reward_id?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The event information when The broadcaster updates a custom channel points reward. */
|
|
17
|
+
export interface ChannelPointsCustomRewardUpdateEvent {
|
|
18
|
+
/** The reward identifier. */
|
|
19
|
+
id: 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
|
+
/** Is the reward currently enabled. If false, the reward won't show up to viewers. */
|
|
27
|
+
is_enabled: boolean
|
|
28
|
+
/** Is the reward currently paused. If true, viewers can't redeem. */
|
|
29
|
+
is_paused: boolean
|
|
30
|
+
/** Is the reward currently in stock. If false, viewers can't redeem. */
|
|
31
|
+
is_in_stock: boolean
|
|
32
|
+
/** The reward title. */
|
|
33
|
+
title: string
|
|
34
|
+
/** Integer. The reward cost. */
|
|
35
|
+
cost: number
|
|
36
|
+
/** The reward description. */
|
|
37
|
+
prompt: string
|
|
38
|
+
/** Does the viewer need to enter information when redeeming the reward. */
|
|
39
|
+
is_user_input_required: boolean
|
|
40
|
+
/** Should redemptions be set to fulfilled status immediately when redeemed and skip the request queue instead of the normal unfulfilled status. */
|
|
41
|
+
should_redemptions_skip_request_queue: boolean
|
|
42
|
+
/** Whether a maximum per stream is enabled and what the maximum is. */
|
|
43
|
+
max_per_stream: ChannelPointsCustomRewardMaxPerStream
|
|
44
|
+
/** Whether a maximum per user per stream is enabled and what the maximum is. */
|
|
45
|
+
max_per_user_per_stream: ChannelPointsCustomRewardMaxPerUserPerStream
|
|
46
|
+
/** Custom background color for the reward. Format: Hex with # prefix. Example: #FA1ED2. */
|
|
47
|
+
background_color: string
|
|
48
|
+
/** Set of custom images of 1x, 2x and 4x sizes for the reward. Can be null if no images have been uploaded. */
|
|
49
|
+
image: ChannelPointsCustomRewardImage
|
|
50
|
+
/** Set of default images of 1x, 2x and 4x sizes for the reward. */
|
|
51
|
+
default_image: ChannelPointsCustomRewardImage
|
|
52
|
+
/** Whether a cooldown is enabled and what the cooldown is in seconds. */
|
|
53
|
+
global_cooldown: ChannelPointsCustomRewardGlobalCooldown
|
|
54
|
+
/** The time the cooldown expires. null if the reward isn't on cooldown. */
|
|
55
|
+
cooldown_expires_at: Date
|
|
56
|
+
/** Integer. The number of redemptions redeemed during the current live stream. Counts against the max_per_stream limit. null if the broadcasters stream isn't live or max_per_stream isn't enabled. */
|
|
57
|
+
redemptions_redeemed_current_stream: number
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The event notification received when The broadcaster updates a custom channel points reward. */
|
|
61
|
+
export type ChannelPointsCustomRewardUpdateSubscription = BaseSubscription<
|
|
62
|
+
ChannelPointsCustomRewardUpdateType,
|
|
63
|
+
ChannelPointsCustomRewardUpdateVersion,
|
|
64
|
+
ChannelPointsCustomRewardUpdateCondition
|
|
65
|
+
>
|
|
66
|
+
|
|
67
|
+
export function makeChannelPointsCustomRewardUpdateSubscription(
|
|
68
|
+
userId: string,
|
|
69
|
+
): ChannelPointsCustomRewardUpdateSubscription {
|
|
70
|
+
return {
|
|
71
|
+
type: "channel.channel_points_custom_reward.update",
|
|
72
|
+
version: "1",
|
|
73
|
+
condition: {
|
|
74
|
+
broadcaster_user_id: userId,
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
}
|