multichat-ts 0.0.7 → 0.0.8
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 +14 -0
- package/dist/kick.js +9 -1
- package/package.json +1 -1
- package/src/kick.ts +29 -1
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,6 +24,8 @@ 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
31
|
interface ChatMessageEvent {
|
|
@@ -44,4 +48,14 @@ interface ChatMessageEvent {
|
|
|
44
48
|
};
|
|
45
49
|
};
|
|
46
50
|
}
|
|
51
|
+
interface ChatSubscriptionEvent {
|
|
52
|
+
chatroom_id: string;
|
|
53
|
+
username: string;
|
|
54
|
+
months: number;
|
|
55
|
+
}
|
|
56
|
+
interface ChatGiftedEvent {
|
|
57
|
+
chatroom_id: string;
|
|
58
|
+
gifted_usernames: string[];
|
|
59
|
+
gifter_username: string;
|
|
60
|
+
}
|
|
47
61
|
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
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;
|
|
@@ -381,3 +397,15 @@ interface ChatMessageEvent {
|
|
|
381
397
|
};
|
|
382
398
|
};
|
|
383
399
|
}
|
|
400
|
+
|
|
401
|
+
interface ChatSubscriptionEvent {
|
|
402
|
+
chatroom_id: string;
|
|
403
|
+
username: string;
|
|
404
|
+
months: number;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
interface ChatGiftedEvent {
|
|
408
|
+
chatroom_id: string;
|
|
409
|
+
gifted_usernames: string[];
|
|
410
|
+
gifter_username: string;
|
|
411
|
+
}
|