multichat-ts 0.0.1 → 0.0.2
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 +77 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/kick.d.ts +1 -1
- package/dist/kick.js +0 -1
- package/dist/twitch.d.ts +1 -1
- package/dist/twitch.js +0 -1
- package/package.json +2 -2
- package/src/index.ts +2 -2
- package/src/kick.ts +1 -1
- package/src/twitch.ts +1 -1
- package/tsconfig.json +36 -36
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# multichat-ts
|
|
2
|
+
|
|
3
|
+
Receive type-safe realtime events for chat-related messages on multiple platforms (Twitch, Kick)
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm install multichat-ts # or (npm, bun, deno, etc) install
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { TwitchIRC, KickPusher } from 'multichat-ts';
|
|
13
|
+
|
|
14
|
+
const twitch_chat = new TwitchIRC();
|
|
15
|
+
const kick_chat = new KickPusher();
|
|
16
|
+
|
|
17
|
+
twitch_chat.connect({
|
|
18
|
+
channelName: 'piratesoftware',
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
kick_chat.connect({
|
|
22
|
+
channelName: 'xqc',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// set custom badge assets or external emotes (ffz, bttv, 7tv, etc)
|
|
26
|
+
twitch_chat.assets.external_emotes = {
|
|
27
|
+
OMEGALUL: 'https://cdn.frankerfacez.com/emoticon/128054/1',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
twitch_chat.on('message', (message) => {
|
|
31
|
+
console.log('new twitch message', message.raw_text, message);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
kick_chat.on('message', (message) => {
|
|
35
|
+
console.log('new twitch message', message.raw_text, message);
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Example usage with Svelte 5
|
|
40
|
+
|
|
41
|
+
```svelte
|
|
42
|
+
<script lang="ts">
|
|
43
|
+
import { TwitchIRC, type Message, KickPusher } from 'multichat-ts';
|
|
44
|
+
|
|
45
|
+
let messages: Message[] = $state([]);
|
|
46
|
+
|
|
47
|
+
const twitch_chat = new TwitchIRC();
|
|
48
|
+
|
|
49
|
+
twitch_chat.connect({
|
|
50
|
+
channelName: 'piratesoftware'
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
twitch_chat.on('message', (message) => {
|
|
54
|
+
messages.push(message);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
twitch_chat.on('clear_messages', (data) => {
|
|
58
|
+
if (data.user !== undefined) {
|
|
59
|
+
messages.filter((message) => message.user.id !== data.user!.id);
|
|
60
|
+
} else {
|
|
61
|
+
messages.filter((message) => message.channel.room_id !== data.channel.room_id);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
twitch_chat.on('delete_message', (message_data) => {
|
|
66
|
+
messages.filter((message) => message.id !== message_data.id);
|
|
67
|
+
});
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<ul>
|
|
71
|
+
{#each messages as message}
|
|
72
|
+
<li>{message.user.display_name}: {message.raw_text}</li>
|
|
73
|
+
{/each}
|
|
74
|
+
</ul>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
MIT
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './kick';
|
|
2
|
-
export * from './twitch';
|
|
1
|
+
export * from './kick.js';
|
|
2
|
+
export * from './twitch.js';
|
package/dist/kick.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Pusher from 'pusher-js';
|
|
2
|
-
import { type BadgeURLsByNameOrCount, type EmoteURLsByName, type Message } from './index';
|
|
2
|
+
import { type BadgeURLsByNameOrCount, type EmoteURLsByName, type Message } from './index.js';
|
|
3
3
|
type EventCallbackFunctions = {
|
|
4
4
|
message: (data: Message) => unknown;
|
|
5
5
|
};
|
package/dist/kick.js
CHANGED
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 BadgeURLsBySetIDAndVersionID } from './index';
|
|
2
|
+
import { type ClearMessages, type DeleteMessage, type Message, type Event, type EmoteURLsByName, type BadgeURLsBySetIDAndVersionID } from './index.js';
|
|
3
3
|
type EventCallbackFunctions = {
|
|
4
4
|
message: (data: Message) => unknown;
|
|
5
5
|
clear_messages: (data: ClearMessages) => unknown;
|
package/dist/twitch.js
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "multichat-ts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Receive
|
|
5
|
+
"description": "Receive type-safe realtime events for chat-related messages on multiple platforms (Twitch, Kick)",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/0Abdullah/multichat-ts.git"
|
package/src/index.ts
CHANGED
package/src/kick.ts
CHANGED
package/src/twitch.ts
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/* Language and Environment */
|
|
6
|
+
"target": "ESNext",
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
/* Modules */
|
|
9
|
+
"module": "ESNext",
|
|
10
|
+
"moduleResolution": "Bundler",
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
/* JavaScript Support */
|
|
13
|
+
"checkJs": true,
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
/* Emit */
|
|
16
|
+
"declaration": true,
|
|
17
|
+
"outDir": "dist",
|
|
18
|
+
"removeComments": true,
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
/* Interop Constraints */
|
|
21
|
+
"isolatedModules": true,
|
|
22
|
+
"verbatimModuleSyntax": false,
|
|
23
|
+
"allowSyntheticDefaultImports": true,
|
|
24
|
+
"esModuleInterop": true,
|
|
25
|
+
"forceConsistentCasingInFileNames": true,
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
/* Type Checking */
|
|
28
|
+
"strict": true,
|
|
29
|
+
"strictNullChecks": true,
|
|
30
|
+
"noUnusedLocals": true,
|
|
31
|
+
"noUnusedParameters": true,
|
|
32
|
+
"exactOptionalPropertyTypes": true,
|
|
33
|
+
"noImplicitReturns": true,
|
|
34
|
+
"noFallthroughCasesInSwitch": true,
|
|
35
|
+
"noUncheckedIndexedAccess": true,
|
|
36
|
+
"noImplicitOverride": true,
|
|
37
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
38
|
+
"allowUnusedLabels": false,
|
|
39
|
+
"allowUnreachableCode": false,
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
/* Completeness */
|
|
42
|
+
"skipLibCheck": true
|
|
43
|
+
},
|
|
44
|
+
"include": ["src"]
|
|
45
45
|
}
|