multichat-ts 0.0.4 → 0.0.5

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/index.d.ts CHANGED
@@ -134,9 +134,10 @@ export type BadgeURLsByNameOrCount = {
134
134
  [badge_count: number]: string;
135
135
  };
136
136
  };
137
- type StringOrAny = '*' | (string & Record<never, never>);
138
- export type BadgeURLsBySetIDAndVersionIDOrAny = {
139
- [badge_set_id: string]: Record<StringOrAny, string>;
137
+ export type BadgeURLsBySetIDOrSetIDAndVersion = {
138
+ [set_id: string]: {
139
+ [version: string]: string;
140
+ } | string;
140
141
  };
141
142
  export type EmoteURLsByName = {
142
143
  [emote_name: string]: string;
package/dist/kick.d.ts CHANGED
@@ -8,13 +8,14 @@ type EventNames = keyof EventCallbackFunctions;
8
8
  export declare class KickPusher {
9
9
  kick_pusher_key: string;
10
10
  channel_name?: string;
11
- assets: {
12
- external_emotes: EmoteURLsByName;
13
- badges: BadgeURLsByNameOrCount;
14
- };
11
+ private assets;
15
12
  private public_listeners;
16
13
  socket?: Pusher;
17
14
  isConnected: boolean;
15
+ setBadges(badges: BadgeURLsByNameOrCount): void;
16
+ setExternalEmotes(external_emotes: EmoteURLsByName): void;
17
+ getStoredBadges(): BadgeURLsByNameOrCount;
18
+ getStoredExternalEmotes(): EmoteURLsByName;
18
19
  connect(channel?: {
19
20
  channelName?: string;
20
21
  }): Promise<void>;
package/dist/kick.js CHANGED
@@ -25,6 +25,18 @@ export class KickPusher {
25
25
  public_listeners = {};
26
26
  socket;
27
27
  isConnected = false;
28
+ setBadges(badges) {
29
+ this.assets.badges = { ...badges, ...this.assets.badges };
30
+ }
31
+ setExternalEmotes(external_emotes) {
32
+ this.assets.external_emotes = { ...external_emotes, ...this.assets.external_emotes };
33
+ }
34
+ getStoredBadges() {
35
+ return this.assets.badges;
36
+ }
37
+ getStoredExternalEmotes() {
38
+ return this.assets.external_emotes;
39
+ }
28
40
  async connect(channel) {
29
41
  if (channel?.channelName)
30
42
  this.channel_name = channel.channelName;
package/dist/twitch.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { WebSocket } from 'partysocket';
2
- import { type ClearMessages, type DeleteMessage, type Message, type Event, type EmoteURLsByName, type BadgeURLsBySetIDAndVersionIDOrAny } from './index.js';
2
+ import { type ClearMessages, type DeleteMessage, type Message, type Event, type EmoteURLsByName, type BadgeURLsBySetIDOrSetIDAndVersion } from './index.js';
3
3
  type EventCallbackFunctions = {
4
4
  message: (message: Message) => unknown;
5
5
  clear_messages: (data: ClearMessages) => unknown;
@@ -10,16 +10,17 @@ type EventCallbackFunctions = {
10
10
  type EventNames = keyof EventCallbackFunctions;
11
11
  export declare class TwitchIRC {
12
12
  channel_name?: string;
13
- assets: {
14
- external_emotes: EmoteURLsByName;
15
- badges: BadgeURLsBySetIDAndVersionIDOrAny;
16
- };
13
+ private assets;
17
14
  latency: number;
18
15
  private ping;
19
16
  private public_listeners;
20
17
  socket?: WebSocket;
21
18
  ws?: WebSocket | undefined;
22
19
  constructor(ws?: WebSocket);
20
+ setBadges(badges: BadgeURLsBySetIDOrSetIDAndVersion): void;
21
+ setExternalEmotes(external_emotes: EmoteURLsByName): void;
22
+ getStoredBadges(): BadgeURLsBySetIDOrSetIDAndVersion;
23
+ getStoredExternalEmotes(): EmoteURLsByName;
23
24
  connect(channel?: {
24
25
  channelName?: string;
25
26
  }): void;
package/dist/twitch.js CHANGED
@@ -17,6 +17,18 @@ export class TwitchIRC {
17
17
  constructor(ws) {
18
18
  this.ws = ws;
19
19
  }
20
+ setBadges(badges) {
21
+ this.assets.badges = { ...badges, ...this.assets.badges };
22
+ }
23
+ setExternalEmotes(external_emotes) {
24
+ this.assets.external_emotes = { ...external_emotes, ...this.assets.external_emotes };
25
+ }
26
+ getStoredBadges() {
27
+ return this.assets.badges;
28
+ }
29
+ getStoredExternalEmotes() {
30
+ return this.assets.external_emotes;
31
+ }
20
32
  connect(channel) {
21
33
  if (channel?.channelName)
22
34
  this.channel_name = channel.channelName;
@@ -189,7 +201,10 @@ export class TwitchIRC {
189
201
  const [set_id, version] = badge.split('/');
190
202
  if (!set_id || !version)
191
203
  return [];
192
- const url = this.assets.badges[set_id]?.[version] ?? this.assets.badges[set_id]?.['*'];
204
+ const storedBadge = this.assets.badges[set_id];
205
+ if (!storedBadge)
206
+ return [];
207
+ const url = typeof storedBadge === 'object' ? storedBadge[version] : storedBadge;
193
208
  if (!url)
194
209
  return [];
195
210
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "multichat-ts",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
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/index.ts CHANGED
@@ -155,10 +155,12 @@ export type BadgeURLsByNameOrCount = {
155
155
  };
156
156
  };
157
157
 
158
- type StringOrAny = '*' | (string & Record<never, never>);
159
-
160
- export type BadgeURLsBySetIDAndVersionIDOrAny = {
161
- [badge_set_id: string]: Record<StringOrAny, string>;
158
+ export type BadgeURLsBySetIDOrSetIDAndVersion = {
159
+ [set_id: string]:
160
+ | {
161
+ [version: string]: string;
162
+ }
163
+ | string;
162
164
  };
163
165
 
164
166
  export type EmoteURLsByName = {
package/src/kick.ts CHANGED
@@ -19,7 +19,7 @@ const DEFAULT_KICK_PUSHER_KEY = '32cbd69e4b950bf97679';
19
19
  export class KickPusher {
20
20
  public kick_pusher_key = DEFAULT_KICK_PUSHER_KEY;
21
21
  public channel_name?: string;
22
- public assets: {
22
+ private assets: {
23
23
  external_emotes: EmoteURLsByName;
24
24
  badges: BadgeURLsByNameOrCount;
25
25
  } = {
@@ -47,6 +47,22 @@ export class KickPusher {
47
47
  public socket?: Pusher;
48
48
  public isConnected = false;
49
49
 
50
+ public setBadges(badges: BadgeURLsByNameOrCount) {
51
+ this.assets.badges = { ...badges, ...this.assets.badges };
52
+ }
53
+
54
+ public setExternalEmotes(external_emotes: EmoteURLsByName) {
55
+ this.assets.external_emotes = { ...external_emotes, ...this.assets.external_emotes };
56
+ }
57
+
58
+ public getStoredBadges() {
59
+ return this.assets.badges;
60
+ }
61
+
62
+ public getStoredExternalEmotes() {
63
+ return this.assets.external_emotes;
64
+ }
65
+
50
66
  public async connect(channel?: { channelName?: string }) {
51
67
  if (channel?.channelName) this.channel_name = channel.channelName;
52
68
  if (!this.channel_name) return console.error('channel_name not specified');
package/src/twitch.ts CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  type Message,
8
8
  type Event,
9
9
  type EmoteURLsByName,
10
- type BadgeURLsBySetIDAndVersionIDOrAny,
10
+ type BadgeURLsBySetIDOrSetIDAndVersion,
11
11
  } from './index.js';
12
12
 
13
13
  const ANONYMOUS_IRC_PASS = 'SCHMOOPIIE';
@@ -27,9 +27,9 @@ type EventNames = keyof EventCallbackFunctions;
27
27
 
28
28
  export class TwitchIRC {
29
29
  public channel_name?: string;
30
- public assets: {
30
+ private assets: {
31
31
  external_emotes: EmoteURLsByName;
32
- badges: BadgeURLsBySetIDAndVersionIDOrAny;
32
+ badges: BadgeURLsBySetIDOrSetIDAndVersion;
33
33
  } = {
34
34
  external_emotes: {},
35
35
  badges: {},
@@ -51,6 +51,22 @@ export class TwitchIRC {
51
51
  this.ws = ws;
52
52
  }
53
53
 
54
+ public setBadges(badges: BadgeURLsBySetIDOrSetIDAndVersion) {
55
+ this.assets.badges = { ...badges, ...this.assets.badges };
56
+ }
57
+
58
+ public setExternalEmotes(external_emotes: EmoteURLsByName) {
59
+ this.assets.external_emotes = { ...external_emotes, ...this.assets.external_emotes };
60
+ }
61
+
62
+ public getStoredBadges() {
63
+ return this.assets.badges;
64
+ }
65
+
66
+ public getStoredExternalEmotes() {
67
+ return this.assets.external_emotes;
68
+ }
69
+
54
70
  public connect(channel?: { channelName?: string }) {
55
71
  if (channel?.channelName) this.channel_name = channel.channelName;
56
72
  if (!this.channel_name) return console.error('channel_name not specified');
@@ -246,8 +262,10 @@ export class TwitchIRC {
246
262
  const [set_id, version] = badge.split('/');
247
263
  if (!set_id || !version) return [];
248
264
 
249
- const url =
250
- this.assets.badges[set_id]?.[version] ?? this.assets.badges[set_id]?.['*'];
265
+ const storedBadge = this.assets.badges[set_id];
266
+ if (!storedBadge) return [];
267
+
268
+ const url = typeof storedBadge === 'object' ? storedBadge[version] : storedBadge;
251
269
  if (!url) return [];
252
270
 
253
271
  return {