multichat-ts 0.0.87 → 0.0.89

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/dist/kick.d.ts ADDED
@@ -0,0 +1,383 @@
1
+ import Pusher from 'pusher-js';
2
+ import { type BadgeURLsByNameOrCount, type EmoteURLsByName, type Message } from './index.js';
3
+ type ConnectionState = 'initialized' | 'connecting' | 'connected' | 'unavailable' | 'failed';
4
+ type ConnectionStateEvent = {
5
+ previous: ConnectionState;
6
+ current: ConnectionState;
7
+ };
8
+ type EventCallbackFunctions = {
9
+ message: (message: Message) => unknown;
10
+ subscription: (data: ChatroomsV2Events['SubscriptionEvent']) => unknown;
11
+ gifted: (data: ChatroomV1Events['GiftedSubscriptionsEvent']) => unknown;
12
+ raw_message: (message: ChatMessageEvent) => unknown;
13
+ connection_state_changed: (state: ConnectionStateEvent) => unknown;
14
+ };
15
+ type EventNames = keyof EventCallbackFunctions;
16
+ export declare class KickPusher {
17
+ kick_pusher_key: string;
18
+ channel_name?: string;
19
+ private assets;
20
+ private public_listeners;
21
+ socket?: Pusher;
22
+ isConnected: boolean;
23
+ setBadges(badges: BadgeURLsByNameOrCount): void;
24
+ setExternalEmotes(external_emotes: EmoteURLsByName): void;
25
+ getStoredBadges(): BadgeURLsByNameOrCount;
26
+ getStoredExternalEmotes(): EmoteURLsByName;
27
+ connect(channel?: {
28
+ channelName?: string;
29
+ }, get_channel?: (channelName: string) => Promise<GetChannelResponse | undefined>): Promise<void>;
30
+ disconnect(): void;
31
+ on<EventName extends EventNames>(event_name: EventName, callback_fn: EventCallbackFunctions[EventName]): void;
32
+ private onSubscriptionSuccess;
33
+ private onChatSubscription;
34
+ private onChatGifted;
35
+ private onChatMessage;
36
+ }
37
+ export interface GetChannelResponse {
38
+ id: number;
39
+ user_id: number;
40
+ slug: string;
41
+ is_banned: boolean;
42
+ playback_url?: string;
43
+ vod_enabled: boolean;
44
+ subscription_enabled: boolean;
45
+ followers_count: number;
46
+ following?: boolean;
47
+ subscription?: unknown;
48
+ subscriber_badges: Array<{
49
+ id: number;
50
+ channel_id: number;
51
+ months: number;
52
+ badge_image: {
53
+ srcset: string;
54
+ src: string;
55
+ };
56
+ }>;
57
+ banner_image?: {
58
+ url: string;
59
+ };
60
+ livestream?: ChannelLivestream;
61
+ role?: unknown;
62
+ muted: boolean;
63
+ follower_badges: unknown[];
64
+ offline_banner_image: unknown;
65
+ verified: boolean;
66
+ recent_categories: Array<{
67
+ id: number;
68
+ category_id: number;
69
+ name: string;
70
+ slug: string;
71
+ tags: string[];
72
+ description?: string;
73
+ deleted_at: unknown;
74
+ viewers: number;
75
+ banner: {
76
+ responsive: string;
77
+ url: string;
78
+ };
79
+ category: {
80
+ id: number;
81
+ name: string;
82
+ slug: string;
83
+ icon: string;
84
+ };
85
+ }>;
86
+ can_host: boolean;
87
+ user: {
88
+ id: number;
89
+ username: string;
90
+ agreed_to_terms: true;
91
+ email_verified_at: Date;
92
+ bio?: string;
93
+ country?: string;
94
+ state?: string;
95
+ city?: string;
96
+ instagram?: string;
97
+ twitter?: string;
98
+ youtube?: string;
99
+ discord?: string;
100
+ tiktok?: string;
101
+ facebook?: string;
102
+ profile_pic?: string;
103
+ };
104
+ chatroom: ChannelChatroom;
105
+ ascending_links?: Array<{
106
+ id: number;
107
+ channel_id: number;
108
+ description: string;
109
+ link: string;
110
+ created_at: Date;
111
+ updated_at: Date;
112
+ order: number;
113
+ title: string;
114
+ }>;
115
+ }
116
+ export interface ChannelLivestream {
117
+ id: number;
118
+ slug: string;
119
+ channel_id: number;
120
+ created_at: Date;
121
+ session_title: string;
122
+ is_live: boolean;
123
+ risk_level_id: unknown;
124
+ start_time: Date;
125
+ source: unknown;
126
+ twitch_channel: unknown;
127
+ duration: number;
128
+ language: string;
129
+ is_mature: boolean;
130
+ viewer_count: number;
131
+ thumbnail: {
132
+ url: string;
133
+ };
134
+ categories: Array<{
135
+ id: number;
136
+ category_id: number;
137
+ name: string;
138
+ slug: string;
139
+ tags: string[];
140
+ description?: string;
141
+ deleted_at: unknown;
142
+ viewers: number;
143
+ category: {
144
+ id: number;
145
+ name: string;
146
+ slug: string;
147
+ icon: string;
148
+ };
149
+ }>;
150
+ tags: unknown[];
151
+ }
152
+ export interface ChannelChatroom {
153
+ id: number;
154
+ chatable_type: string;
155
+ channel_id: string;
156
+ created_at: Date;
157
+ updated_at: Date;
158
+ chat_mode_old: string;
159
+ chat_mode: string;
160
+ slow_mode: boolean;
161
+ chatable_id: number;
162
+ followers_mode: boolean;
163
+ subscribers_mode: boolean;
164
+ emotes_mode: boolean;
165
+ message_interval: number;
166
+ following_min_duration: number;
167
+ }
168
+ export interface ChatMessageEvent {
169
+ id: string;
170
+ chatroom_id: number;
171
+ content: string;
172
+ type: 'message' | 'celebration';
173
+ created_at: string;
174
+ metadata?: {
175
+ celebration: {
176
+ created_at: string;
177
+ id: string;
178
+ total_months: number;
179
+ type: 'subscription_renewed';
180
+ };
181
+ };
182
+ sender: {
183
+ id: number;
184
+ username: string;
185
+ slug?: string;
186
+ identity: {
187
+ color: string;
188
+ badges: Array<{
189
+ type: string;
190
+ text: string;
191
+ count?: number;
192
+ }>;
193
+ };
194
+ };
195
+ }
196
+ export interface ChannelEvents {
197
+ ChannelSubscriptionEvent: {
198
+ user_ids: number[];
199
+ username: string;
200
+ channel_id: number;
201
+ };
202
+ GiftsLeaderboardUpdated: {
203
+ leaderboard: {
204
+ user_id: number;
205
+ username: string;
206
+ quantity: number;
207
+ }[];
208
+ weekly_leaderboard: {
209
+ user_id: number;
210
+ username: string;
211
+ quantity: number;
212
+ }[];
213
+ monthly_leaderboard: {
214
+ user_id: number;
215
+ username: string;
216
+ quantity: number;
217
+ }[];
218
+ gifter_id: number;
219
+ gifter_username: string;
220
+ gifted_quantity: number;
221
+ };
222
+ LuckyUsersWhoGotGiftSubscriptionsEvent: {
223
+ channel: {
224
+ id: number;
225
+ user_id: number;
226
+ slug: string;
227
+ is_banned: boolean;
228
+ playback_url: string;
229
+ name_updated_at: unknown;
230
+ vod_enabled: boolean;
231
+ subscription_enabled: boolean;
232
+ is_affiliate: boolean;
233
+ can_host: boolean;
234
+ chatroom: {
235
+ id: number;
236
+ chatable_type: string;
237
+ channel_id: number;
238
+ created_at: string;
239
+ updated_at: string;
240
+ chat_mode_old: string;
241
+ chat_mode: string;
242
+ slow_mode: boolean;
243
+ chatable_id: number;
244
+ followers_mode: boolean;
245
+ subscribers_mode: boolean;
246
+ emotes_mode: boolean;
247
+ message_interval: number;
248
+ following_min_duration: number;
249
+ };
250
+ };
251
+ usernames: string[];
252
+ gifter_username: string;
253
+ };
254
+ }
255
+ export interface ChatroomsV1Events {
256
+ StreamHostedEvent: {
257
+ message: {
258
+ createdAt: string;
259
+ id: string;
260
+ numberOfViewers: number;
261
+ optionalMessage: string;
262
+ };
263
+ user: {
264
+ id: number;
265
+ isSuperAdmin: boolean;
266
+ username: string;
267
+ verified: {
268
+ id: number;
269
+ channel_id: number;
270
+ created_at: string;
271
+ updated_at: string;
272
+ };
273
+ };
274
+ };
275
+ ChatMessageSentEvent: {
276
+ message: {
277
+ action: 'subscribe' | 'gift';
278
+ chatroom_id: number;
279
+ created_at: number;
280
+ giftedUsers: {
281
+ username: string;
282
+ monthsSubscribed: number;
283
+ }[];
284
+ id: string;
285
+ is_info: unknown;
286
+ link_preview: unknown;
287
+ message: unknown;
288
+ months_subscribed: number | null;
289
+ optional_message: unknown;
290
+ replied_to: unknown;
291
+ role: 'user';
292
+ subscriptions_count: number;
293
+ type: 'info';
294
+ };
295
+ user: {
296
+ follower_badges: unknown[];
297
+ id: number;
298
+ isSuperAdmin: boolean;
299
+ is_founder: boolean;
300
+ is_subscribed: unknown;
301
+ months_subscribed: number;
302
+ profile_thumb: string;
303
+ quantity_gifted: number;
304
+ role: 'user';
305
+ username: string;
306
+ verified: boolean;
307
+ };
308
+ };
309
+ }
310
+ export interface ChatroomV1Events {
311
+ GiftedSubscriptionsEvent: {
312
+ chatroom_id: number;
313
+ gifted_usernames: string[];
314
+ gifter_total: number;
315
+ gifter_username: string;
316
+ };
317
+ }
318
+ export interface ChatroomsV2Events {
319
+ StreamHostEvent: {
320
+ chatroom_id: number;
321
+ optional_message: string;
322
+ number_viewers: number;
323
+ host_username: string;
324
+ };
325
+ MessageDeletedEvent: {
326
+ id: string;
327
+ message: {
328
+ id: string;
329
+ };
330
+ aiModerated: boolean;
331
+ violatedRules: unknown[];
332
+ };
333
+ UserBannedEvent: {
334
+ id: string;
335
+ user: {
336
+ id: number;
337
+ username: string;
338
+ slug: string;
339
+ };
340
+ banned_by: {
341
+ id: number;
342
+ username: string;
343
+ slug: string;
344
+ };
345
+ permanent: boolean;
346
+ duration: number;
347
+ expires_at: string;
348
+ };
349
+ SubscriptionEvent: {
350
+ chatroom_id: number;
351
+ username: string;
352
+ months: number;
353
+ };
354
+ ChatMessageEvent: {
355
+ id: string;
356
+ chatroom_id: number;
357
+ content: string;
358
+ type: 'message' | 'celebration';
359
+ created_at: string;
360
+ metadata?: {
361
+ celebration: {
362
+ created_at: string;
363
+ id: string;
364
+ total_months: number;
365
+ type: 'subscription_renewed';
366
+ };
367
+ };
368
+ sender: {
369
+ id: number;
370
+ username: string;
371
+ slug?: string;
372
+ identity: {
373
+ color: string;
374
+ badges: Array<{
375
+ type: string;
376
+ text: string;
377
+ count?: number;
378
+ }>;
379
+ };
380
+ };
381
+ };
382
+ }
383
+ export {};
@@ -65,8 +65,9 @@ export class KickPusher {
65
65
  this.socket = new Pusher(this.kick_pusher_key, {
66
66
  cluster: 'us2',
67
67
  });
68
+ this.socket.subscribe(`chatroom_${channel_response.chatroom.id}`);
69
+ this.socket.subscribe(`chatrooms.${channel_response.chatroom.id}.v2`);
68
70
  this.socket
69
- .subscribe(`chatrooms.${channel_response.chatroom.id}.v2`)
70
71
  .bind('pusher:subscription_succeeded', () => this.onSubscriptionSuccess('pusher:subscription_succeeded'))
71
72
  .bind('App\\Events\\ChatMessageEvent', (data) => this.onChatMessage(data))
72
73
  .bind('App\\Events\\SubscriptionEvent', (data) => this.onChatSubscription(data))
@@ -128,7 +129,6 @@ export class KickPusher {
128
129
  const emote_id = emote_parts[1];
129
130
  if (!emote_id)
130
131
  return;
131
- console.log(emote_id);
132
132
  body.push({
133
133
  type: 'emote',
134
134
  start_inclusive: match.index,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "multichat-ts",
3
- "version": "0.0.87",
3
+ "version": "0.0.89",
4
4
  "type": "module",
5
5
  "description": "Receive type-safe realtime events for chat-related messages on multiple platforms (Twitch, Kick)",
6
6
  "repository": {
@@ -11,8 +11,7 @@
11
11
  "main": "dist/index.js",
12
12
  "types": "dist/index.d.ts",
13
13
  "exports": {
14
- ".": "./dist/default/index.js",
15
- "./worker": "./dist/worker/index.js"
14
+ ".": "./dist/default/index.js"
16
15
  },
17
16
  "scripts": {
18
17
  "build": "tsc",