multichat-ts 0.0.7 → 0.0.81

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 CHANGED
@@ -2,6 +2,8 @@ import Pusher from 'pusher-js';
2
2
  import { type BadgeURLsByNameOrCount, type EmoteURLsByName, type Message } from './index.js';
3
3
  type EventCallbackFunctions = {
4
4
  message: (message: Message) => unknown;
5
+ subscription: (data: ChatSubscriptionEvent) => unknown;
6
+ gifted: (data: ChatGiftedEvent) => unknown;
5
7
  raw_message: (message: ChatMessageEvent) => unknown;
6
8
  };
7
9
  type EventNames = keyof EventCallbackFunctions;
@@ -22,9 +24,142 @@ export declare class KickPusher {
22
24
  disconnect(): void;
23
25
  on<EventName extends EventNames>(event_name: EventName, callback_fn: EventCallbackFunctions[EventName]): void;
24
26
  private onSubscriptionSuccess;
27
+ private onChatSubscription;
28
+ private onChatGifted;
25
29
  private onChatMessage;
26
30
  }
27
- interface ChatMessageEvent {
31
+ export interface GetChannelResponse {
32
+ id: number;
33
+ user_id: number;
34
+ slug: string;
35
+ is_banned: boolean;
36
+ playback_url?: string;
37
+ vod_enabled: boolean;
38
+ subscription_enabled: boolean;
39
+ followers_count: number;
40
+ following?: boolean;
41
+ subscription?: unknown;
42
+ subscriber_badges: Array<{
43
+ id: number;
44
+ channel_id: number;
45
+ months: number;
46
+ badge_image: {
47
+ srcset: string;
48
+ src: string;
49
+ };
50
+ }>;
51
+ banner_image?: {
52
+ url: string;
53
+ };
54
+ livestream?: ChannelLivestream;
55
+ role?: unknown;
56
+ muted: boolean;
57
+ follower_badges: unknown[];
58
+ offline_banner_image: unknown;
59
+ verified: boolean;
60
+ recent_categories: Array<{
61
+ id: number;
62
+ category_id: number;
63
+ name: string;
64
+ slug: string;
65
+ tags: string[];
66
+ description?: string;
67
+ deleted_at: unknown;
68
+ viewers: number;
69
+ banner: {
70
+ responsive: string;
71
+ url: string;
72
+ };
73
+ category: {
74
+ id: number;
75
+ name: string;
76
+ slug: string;
77
+ icon: string;
78
+ };
79
+ }>;
80
+ can_host: boolean;
81
+ user: {
82
+ id: number;
83
+ username: string;
84
+ agreed_to_terms: true;
85
+ email_verified_at: Date;
86
+ bio?: string;
87
+ country?: string;
88
+ state?: string;
89
+ city?: string;
90
+ instagram?: string;
91
+ twitter?: string;
92
+ youtube?: string;
93
+ discord?: string;
94
+ tiktok?: string;
95
+ facebook?: string;
96
+ profile_pic?: string;
97
+ };
98
+ chatroom: ChannelChatroom;
99
+ ascending_links?: Array<{
100
+ id: number;
101
+ channel_id: number;
102
+ description: string;
103
+ link: string;
104
+ created_at: Date;
105
+ updated_at: Date;
106
+ order: number;
107
+ title: string;
108
+ }>;
109
+ }
110
+ export interface ChannelLivestream {
111
+ id: number;
112
+ slug: string;
113
+ channel_id: number;
114
+ created_at: Date;
115
+ session_title: string;
116
+ is_live: boolean;
117
+ risk_level_id: unknown;
118
+ start_time: Date;
119
+ source: unknown;
120
+ twitch_channel: unknown;
121
+ duration: number;
122
+ language: string;
123
+ is_mature: boolean;
124
+ viewer_count: number;
125
+ thumbnail: {
126
+ url: string;
127
+ };
128
+ categories: Array<{
129
+ id: number;
130
+ category_id: number;
131
+ name: string;
132
+ slug: string;
133
+ tags: string[];
134
+ description?: string;
135
+ deleted_at: unknown;
136
+ viewers: number;
137
+ category: {
138
+ id: number;
139
+ name: string;
140
+ slug: string;
141
+ icon: string;
142
+ };
143
+ }>;
144
+ tags: unknown[];
145
+ }
146
+ export interface ChannelChatroom {
147
+ id: number;
148
+ chatable_type: string;
149
+ channel_id: string;
150
+ created_at: Date;
151
+ updated_at: Date;
152
+ chat_mode_old: string;
153
+ chat_mode: string;
154
+ slow_mode: boolean;
155
+ chatable_id: number;
156
+ followers_mode: boolean;
157
+ subscribers_mode: boolean;
158
+ emotes_mode: boolean;
159
+ message_interval: number;
160
+ following_min_duration: number;
161
+ }
162
+ export interface ChatMessageEvent {
28
163
  id: string;
29
164
  chatroom_id: number;
30
165
  content: string;
@@ -44,4 +179,14 @@ interface ChatMessageEvent {
44
179
  };
45
180
  };
46
181
  }
182
+ export interface ChatSubscriptionEvent {
183
+ chatroom_id: string;
184
+ username: string;
185
+ months: number;
186
+ }
187
+ export interface ChatGiftedEvent {
188
+ chatroom_id: string;
189
+ gifted_usernames: string[];
190
+ gifter_username: string;
191
+ }
47
192
  export {};
package/dist/kick.js CHANGED
@@ -61,7 +61,9 @@ export class KickPusher {
61
61
  this.socket
62
62
  .subscribe(`chatrooms.${channel_response.chatroom.id}.v2`)
63
63
  .bind('pusher:subscription_succeeded', () => this.onSubscriptionSuccess())
64
- .bind('App\\Events\\ChatMessageEvent', (data) => this.onChatMessage(data));
64
+ .bind('App\\Events\\ChatMessageEvent', (data) => this.onChatMessage(data))
65
+ .bind('App\\Events\\SubscriptionEvent', (data) => this.onChatSubscription(data))
66
+ .bind('App\\Events\\GiftedSubscriptionsEvent', (data) => this.onChatGifted(data));
65
67
  }
66
68
  disconnect() {
67
69
  this.socket?.disconnect();
@@ -73,6 +75,12 @@ export class KickPusher {
73
75
  onSubscriptionSuccess() {
74
76
  console.log(`Connected to Kick Pusher (${this.channel_name})`);
75
77
  }
78
+ onChatSubscription(data) {
79
+ this.public_listeners.subscription?.(data);
80
+ }
81
+ onChatGifted(data) {
82
+ this.public_listeners.gifted?.(data);
83
+ }
76
84
  onChatMessage(data) {
77
85
  this.public_listeners.raw_message?.(data);
78
86
  const text = data.content;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "multichat-ts",
3
- "version": "0.0.7",
3
+ "version": "0.0.81",
4
4
  "type": "module",
5
5
  "description": "Receive type-safe realtime events for chat-related messages on multiple platforms (Twitch, Kick)",
6
6
  "repository": {
package/src/kick.ts CHANGED
@@ -9,6 +9,8 @@ import {
9
9
 
10
10
  type EventCallbackFunctions = {
11
11
  message: (message: Message) => unknown;
12
+ subscription: (data: ChatSubscriptionEvent) => unknown;
13
+ gifted: (data: ChatGiftedEvent) => unknown;
12
14
  raw_message: (message: ChatMessageEvent) => unknown;
13
15
  };
14
16
 
@@ -106,7 +108,13 @@ export class KickPusher {
106
108
  this.socket
107
109
  .subscribe(`chatrooms.${channel_response.chatroom.id}.v2`)
108
110
  .bind('pusher:subscription_succeeded', () => this.onSubscriptionSuccess())
109
- .bind('App\\Events\\ChatMessageEvent', (data: ChatMessageEvent) => this.onChatMessage(data));
111
+ .bind('App\\Events\\ChatMessageEvent', (data: ChatMessageEvent) => this.onChatMessage(data))
112
+ .bind('App\\Events\\SubscriptionEvent', (data: ChatSubscriptionEvent) =>
113
+ this.onChatSubscription(data),
114
+ )
115
+ .bind('App\\Events\\GiftedSubscriptionsEvent', (data: ChatGiftedEvent) =>
116
+ this.onChatGifted(data),
117
+ );
110
118
  }
111
119
 
112
120
  public disconnect() {
@@ -125,6 +133,14 @@ export class KickPusher {
125
133
  console.log(`Connected to Kick Pusher (${this.channel_name})`);
126
134
  }
127
135
 
136
+ private onChatSubscription(data: ChatSubscriptionEvent) {
137
+ this.public_listeners.subscription?.(data);
138
+ }
139
+
140
+ private onChatGifted(data: ChatGiftedEvent) {
141
+ this.public_listeners.gifted?.(data);
142
+ }
143
+
128
144
  private onChatMessage(data: ChatMessageEvent) {
129
145
  this.public_listeners.raw_message?.(data);
130
146
  const text = data.content;
@@ -229,7 +245,7 @@ export class KickPusher {
229
245
  }
230
246
  }
231
247
 
232
- interface GetChannelResponse {
248
+ export interface GetChannelResponse {
233
249
  id: number;
234
250
  user_id: number;
235
251
  slug: string;
@@ -309,7 +325,7 @@ interface GetChannelResponse {
309
325
  }>;
310
326
  }
311
327
 
312
- interface ChannelLivestream {
328
+ export interface ChannelLivestream {
313
329
  id: number;
314
330
  slug: string;
315
331
  channel_id: number;
@@ -345,7 +361,7 @@ interface ChannelLivestream {
345
361
  }>;
346
362
  tags: unknown[];
347
363
  }
348
- interface ChannelChatroom {
364
+ export interface ChannelChatroom {
349
365
  id: number;
350
366
  chatable_type: string;
351
367
  channel_id: string;
@@ -361,7 +377,7 @@ interface ChannelChatroom {
361
377
  message_interval: number;
362
378
  following_min_duration: number;
363
379
  }
364
- interface ChatMessageEvent {
380
+ export interface ChatMessageEvent {
365
381
  id: string;
366
382
  chatroom_id: number;
367
383
  content: string;
@@ -381,3 +397,15 @@ interface ChatMessageEvent {
381
397
  };
382
398
  };
383
399
  }
400
+
401
+ export interface ChatSubscriptionEvent {
402
+ chatroom_id: string;
403
+ username: string;
404
+ months: number;
405
+ }
406
+
407
+ export interface ChatGiftedEvent {
408
+ chatroom_id: string;
409
+ gifted_usernames: string[];
410
+ gifter_username: string;
411
+ }