@blorkfield/twitch-integration 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 +177 -0
- package/dist/index.cjs +572 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +108 -0
- package/dist/index.d.ts +108 -0
- package/dist/index.js +542 -0
- package/dist/index.js.map +1 -0
- package/package.json +52 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import EventEmitter from 'eventemitter3';
|
|
2
|
+
|
|
3
|
+
interface TwitchChatOptions {
|
|
4
|
+
channelId: string;
|
|
5
|
+
userId: string;
|
|
6
|
+
clientId: string;
|
|
7
|
+
accessToken: string;
|
|
8
|
+
onTokenRefresh?: (newToken: string) => void;
|
|
9
|
+
}
|
|
10
|
+
interface Badge {
|
|
11
|
+
setId: string;
|
|
12
|
+
id: string;
|
|
13
|
+
info: string;
|
|
14
|
+
}
|
|
15
|
+
interface ChatUser {
|
|
16
|
+
id: string;
|
|
17
|
+
login: string;
|
|
18
|
+
displayName: string;
|
|
19
|
+
color: string;
|
|
20
|
+
badges: Badge[];
|
|
21
|
+
isModerator: boolean;
|
|
22
|
+
isSubscriber: boolean;
|
|
23
|
+
isBroadcaster: boolean;
|
|
24
|
+
isVip: boolean;
|
|
25
|
+
}
|
|
26
|
+
interface ResolvedEmote {
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
source: 'twitch' | 'bttv' | '7tv';
|
|
30
|
+
animated: boolean;
|
|
31
|
+
imageUrl1x: string;
|
|
32
|
+
imageUrl2x?: string;
|
|
33
|
+
imageUrl3x?: string;
|
|
34
|
+
}
|
|
35
|
+
type MessageFragment = {
|
|
36
|
+
type: 'text';
|
|
37
|
+
text: string;
|
|
38
|
+
} | {
|
|
39
|
+
type: 'emote';
|
|
40
|
+
text: string;
|
|
41
|
+
emote: ResolvedEmote;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'cheermote';
|
|
44
|
+
text: string;
|
|
45
|
+
bits: number;
|
|
46
|
+
tier: number;
|
|
47
|
+
} | {
|
|
48
|
+
type: 'mention';
|
|
49
|
+
text: string;
|
|
50
|
+
userId: string;
|
|
51
|
+
userLogin: string;
|
|
52
|
+
};
|
|
53
|
+
interface NormalizedMessage {
|
|
54
|
+
id: string;
|
|
55
|
+
text: string;
|
|
56
|
+
user: ChatUser;
|
|
57
|
+
fragments: MessageFragment[];
|
|
58
|
+
emotes: ResolvedEmote[];
|
|
59
|
+
timestamp: string;
|
|
60
|
+
cheer?: {
|
|
61
|
+
bits: number;
|
|
62
|
+
};
|
|
63
|
+
reply?: {
|
|
64
|
+
parentMessageId: string;
|
|
65
|
+
parentUserLogin: string;
|
|
66
|
+
parentUserDisplayName: string;
|
|
67
|
+
};
|
|
68
|
+
channelPointsRewardId?: string;
|
|
69
|
+
}
|
|
70
|
+
interface UserProfile {
|
|
71
|
+
id: string;
|
|
72
|
+
profileImageUrl: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface TwitchChatEvents {
|
|
76
|
+
connected: [];
|
|
77
|
+
disconnected: [code: number, reason: string];
|
|
78
|
+
message: [msg: NormalizedMessage];
|
|
79
|
+
revoked: [reason: string];
|
|
80
|
+
auth_error: [];
|
|
81
|
+
error: [err: Error];
|
|
82
|
+
}
|
|
83
|
+
declare class TwitchChat extends EventEmitter<TwitchChatEvents> {
|
|
84
|
+
private options;
|
|
85
|
+
private emoteCache;
|
|
86
|
+
private userCache;
|
|
87
|
+
private ws;
|
|
88
|
+
private sessionId;
|
|
89
|
+
private keepaliveTimeoutMs;
|
|
90
|
+
private keepaliveTimer;
|
|
91
|
+
private oldWs;
|
|
92
|
+
private stopped;
|
|
93
|
+
constructor(options: TwitchChatOptions);
|
|
94
|
+
connect(): Promise<void>;
|
|
95
|
+
disconnect(): void;
|
|
96
|
+
preloadEmotes(): Promise<void>;
|
|
97
|
+
refreshEmotes(): Promise<void>;
|
|
98
|
+
getProfilePictureUrl(userId: string): Promise<string | null>;
|
|
99
|
+
getProfilePictureUrls(userIds: string[]): Promise<Map<string, string | null>>;
|
|
100
|
+
private _openConnection;
|
|
101
|
+
private _dispatch;
|
|
102
|
+
private _subscribe;
|
|
103
|
+
private _resetKeepaliveTimer;
|
|
104
|
+
private _clearKeepaliveTimer;
|
|
105
|
+
private _closeWs;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export { type Badge, type ChatUser, type MessageFragment, type NormalizedMessage, type ResolvedEmote, TwitchChat, type TwitchChatOptions, type UserProfile };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import EventEmitter from 'eventemitter3';
|
|
2
|
+
|
|
3
|
+
interface TwitchChatOptions {
|
|
4
|
+
channelId: string;
|
|
5
|
+
userId: string;
|
|
6
|
+
clientId: string;
|
|
7
|
+
accessToken: string;
|
|
8
|
+
onTokenRefresh?: (newToken: string) => void;
|
|
9
|
+
}
|
|
10
|
+
interface Badge {
|
|
11
|
+
setId: string;
|
|
12
|
+
id: string;
|
|
13
|
+
info: string;
|
|
14
|
+
}
|
|
15
|
+
interface ChatUser {
|
|
16
|
+
id: string;
|
|
17
|
+
login: string;
|
|
18
|
+
displayName: string;
|
|
19
|
+
color: string;
|
|
20
|
+
badges: Badge[];
|
|
21
|
+
isModerator: boolean;
|
|
22
|
+
isSubscriber: boolean;
|
|
23
|
+
isBroadcaster: boolean;
|
|
24
|
+
isVip: boolean;
|
|
25
|
+
}
|
|
26
|
+
interface ResolvedEmote {
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
source: 'twitch' | 'bttv' | '7tv';
|
|
30
|
+
animated: boolean;
|
|
31
|
+
imageUrl1x: string;
|
|
32
|
+
imageUrl2x?: string;
|
|
33
|
+
imageUrl3x?: string;
|
|
34
|
+
}
|
|
35
|
+
type MessageFragment = {
|
|
36
|
+
type: 'text';
|
|
37
|
+
text: string;
|
|
38
|
+
} | {
|
|
39
|
+
type: 'emote';
|
|
40
|
+
text: string;
|
|
41
|
+
emote: ResolvedEmote;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'cheermote';
|
|
44
|
+
text: string;
|
|
45
|
+
bits: number;
|
|
46
|
+
tier: number;
|
|
47
|
+
} | {
|
|
48
|
+
type: 'mention';
|
|
49
|
+
text: string;
|
|
50
|
+
userId: string;
|
|
51
|
+
userLogin: string;
|
|
52
|
+
};
|
|
53
|
+
interface NormalizedMessage {
|
|
54
|
+
id: string;
|
|
55
|
+
text: string;
|
|
56
|
+
user: ChatUser;
|
|
57
|
+
fragments: MessageFragment[];
|
|
58
|
+
emotes: ResolvedEmote[];
|
|
59
|
+
timestamp: string;
|
|
60
|
+
cheer?: {
|
|
61
|
+
bits: number;
|
|
62
|
+
};
|
|
63
|
+
reply?: {
|
|
64
|
+
parentMessageId: string;
|
|
65
|
+
parentUserLogin: string;
|
|
66
|
+
parentUserDisplayName: string;
|
|
67
|
+
};
|
|
68
|
+
channelPointsRewardId?: string;
|
|
69
|
+
}
|
|
70
|
+
interface UserProfile {
|
|
71
|
+
id: string;
|
|
72
|
+
profileImageUrl: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface TwitchChatEvents {
|
|
76
|
+
connected: [];
|
|
77
|
+
disconnected: [code: number, reason: string];
|
|
78
|
+
message: [msg: NormalizedMessage];
|
|
79
|
+
revoked: [reason: string];
|
|
80
|
+
auth_error: [];
|
|
81
|
+
error: [err: Error];
|
|
82
|
+
}
|
|
83
|
+
declare class TwitchChat extends EventEmitter<TwitchChatEvents> {
|
|
84
|
+
private options;
|
|
85
|
+
private emoteCache;
|
|
86
|
+
private userCache;
|
|
87
|
+
private ws;
|
|
88
|
+
private sessionId;
|
|
89
|
+
private keepaliveTimeoutMs;
|
|
90
|
+
private keepaliveTimer;
|
|
91
|
+
private oldWs;
|
|
92
|
+
private stopped;
|
|
93
|
+
constructor(options: TwitchChatOptions);
|
|
94
|
+
connect(): Promise<void>;
|
|
95
|
+
disconnect(): void;
|
|
96
|
+
preloadEmotes(): Promise<void>;
|
|
97
|
+
refreshEmotes(): Promise<void>;
|
|
98
|
+
getProfilePictureUrl(userId: string): Promise<string | null>;
|
|
99
|
+
getProfilePictureUrls(userIds: string[]): Promise<Map<string, string | null>>;
|
|
100
|
+
private _openConnection;
|
|
101
|
+
private _dispatch;
|
|
102
|
+
private _subscribe;
|
|
103
|
+
private _resetKeepaliveTimer;
|
|
104
|
+
private _clearKeepaliveTimer;
|
|
105
|
+
private _closeWs;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export { type Badge, type ChatUser, type MessageFragment, type NormalizedMessage, type ResolvedEmote, TwitchChat, type TwitchChatOptions, type UserProfile };
|