multichat-ts 0.0.3 → 0.0.4

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
@@ -1,7 +1,8 @@
1
1
  import Pusher from 'pusher-js';
2
2
  import { type BadgeURLsByNameOrCount, type EmoteURLsByName, type Message } from './index.js';
3
3
  type EventCallbackFunctions = {
4
- message: (data: Message) => unknown;
4
+ message: (message: Message) => unknown;
5
+ raw_message: (message: ChatMessageEvent) => unknown;
5
6
  };
6
7
  type EventNames = keyof EventCallbackFunctions;
7
8
  export declare class KickPusher {
@@ -22,4 +23,24 @@ export declare class KickPusher {
22
23
  private onSubscriptionSuccess;
23
24
  private onChatMessage;
24
25
  }
26
+ interface ChatMessageEvent {
27
+ id: string;
28
+ chatroom_id: number;
29
+ content: string;
30
+ type: string;
31
+ created_at: string;
32
+ sender: {
33
+ id: number;
34
+ username: string;
35
+ slug?: string;
36
+ identity: {
37
+ color: string;
38
+ badges: Array<{
39
+ type: string;
40
+ text: string;
41
+ count?: number;
42
+ }>;
43
+ };
44
+ };
45
+ }
25
46
  export {};
package/dist/kick.js CHANGED
@@ -62,7 +62,7 @@ export class KickPusher {
62
62
  console.log(`Connected to Kick Pusher (${this.channel_name})`);
63
63
  }
64
64
  onChatMessage(data) {
65
- console.log('onMessage', data);
65
+ this.public_listeners.raw_message?.(data);
66
66
  const text = data.content;
67
67
  const emote_matches = [...data.content.matchAll(/\[emote:\d+:[a-zA-Z0-9]*\]/g)];
68
68
  console.log(emote_matches);
package/dist/twitch.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { WebSocket } from 'partysocket';
2
2
  import { type ClearMessages, type DeleteMessage, type Message, type Event, type EmoteURLsByName, type BadgeURLsBySetIDAndVersionIDOrAny } from './index.js';
3
3
  type EventCallbackFunctions = {
4
- message: (data: Message) => unknown;
4
+ message: (message: Message) => unknown;
5
5
  clear_messages: (data: ClearMessages) => unknown;
6
6
  delete_message: (data: DeleteMessage) => unknown;
7
- event: (data: Event) => unknown;
7
+ event: (event: Event) => unknown;
8
+ raw_message: (message: IRC_Message) => unknown;
8
9
  };
9
10
  type EventNames = keyof EventCallbackFunctions;
10
11
  export declare class TwitchIRC {
@@ -35,4 +36,37 @@ export declare class TwitchIRC {
35
36
  private send;
36
37
  private onMessage;
37
38
  }
39
+ type IRC_Message = {
40
+ [C in CommandType]: {
41
+ channel: string;
42
+ command: C;
43
+ params: string[];
44
+ source: RawSource | undefined;
45
+ tags: SpecificRawTags<C> | undefined;
46
+ };
47
+ }[CommandType];
48
+ type RAW_TAGS = typeof RAW_TAGS;
49
+ type CommandType = keyof RAW_TAGS;
50
+ type SpecificRawTags<Command extends CommandType> = Record<RAW_TAGS[Command][number], string | undefined>;
51
+ type RawSource = {
52
+ host: string;
53
+ nick?: string | undefined;
54
+ user?: string | undefined;
55
+ };
56
+ declare const RAW_TAGS: {
57
+ readonly CLEARCHAT: readonly ["ban-duration", "room-id", "target-user-id", "tmi-sent-ts"];
58
+ readonly CLEARMSG: readonly ["login", "room-id", "target-msg-id", "tmi-sent-ts"];
59
+ readonly GLOBALUSERSTATE: readonly ["badge-info", "badges", "color", "display-name", "emote-sets", "turbo", "user-id", "user-type"];
60
+ readonly HOSTTARGET: readonly [];
61
+ readonly NOTICE: readonly ["msg-id", "target-user-id"];
62
+ readonly PART: readonly [];
63
+ readonly PING: readonly [];
64
+ readonly PONG: readonly [];
65
+ readonly PRIVMSG: readonly ["badge-info", "badges", "bits", "color", "display-name", "emotes", "emote-only", "id", "mod", "custom-reward-id", "reply-thread-parent-display-name", "reply-thread-parent-user-id", "pinned-chat-paid-amount", "pinned-chat-paid-currency", "pinned-chat-paid-exponent", "pinned-chat-paid-level", "pinned-chat-paid-is-system-message", "reply-parent-msg-id", "reply-parent-user-id", "reply-parent-user-login", "reply-parent-display-name", "reply-parent-msg-body", "reply-thread-parent-msg-id", "reply-thread-parent-user-login", "room-id", "subscriber", "tmi-sent-ts", "turbo", "user-id", "user-type", "vip", "client-nonce", "first-msg", "flags", "returning-chatter"];
66
+ readonly RECONNECT: readonly [];
67
+ readonly ROOMSTATE: readonly ["emote-only", "followers-only", "r9k", "room-id", "slow", "subs-only"];
68
+ readonly USERNOTICE: readonly ["badge-info", "badges", "color", "display-name", "emotes", "id", "login", "mod", "msg-id", "room-id", "subscriber", "system-msg", "tmi-sent-ts", "turbo", "user-id", "user-type", "vip", "flags", "msg-param-cumulative-months", "msg-param-displayName", "msg-param-login", "msg-param-multimonth-duration", "msg-param-multimonth-tenure", "msg-param-was-gifted=false", "msg-param-months", "msg-param-promo-gift-total", "msg-param-promo-name", "msg-param-recipient-display-name", "msg-param-recipient-id", "msg-param-recipient-user-name", "msg-param-sender-login", "msg-param-sender-name", "msg-param-should-share-streak", "msg-param-streak-months", "msg-param-sub-plan", "msg-param-sub-plan-name", "msg-param-viewerCount", "msg-param-ritual-name", "msg-param-threshold", "msg-param-gift-months", "msg-param-was-gifted", "msg-param-community-gift-id", "msg-param-mass-gift-count", "msg-param-origin-id"];
69
+ readonly USERSTATE: readonly ["badge-info", "badges", "color", "display-name", "emote-sets", "id", "mod", "subscriber", "turbo", "user-type"];
70
+ readonly WHISPER: readonly ["badges", "color", "display-name", "emotes", "message-id", "thread-id", "turbo", "user-id", "user-type"];
71
+ };
38
72
  export {};
package/dist/twitch.js CHANGED
@@ -77,6 +77,7 @@ export class TwitchIRC {
77
77
  const lines = String(event.data).trim().split('\r\n');
78
78
  const messages = lines.map(parseIRCLine);
79
79
  messages.forEach((message) => {
80
+ this.public_listeners.raw_message?.(message);
80
81
  switch (message.command) {
81
82
  case 'PONG': {
82
83
  if (!this.ping.lastSentTimestamp)
package/package.json CHANGED
@@ -1,52 +1,54 @@
1
1
  {
2
- "name": "multichat-ts",
3
- "version": "0.0.3",
4
- "type": "module",
5
- "description": "Receive type-safe realtime events for chat-related messages on multiple platforms (Twitch, Kick)",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/0Abdullah/multichat-ts.git"
9
- },
10
- "homepage": "https://github.com/0Abdullah/multichat-ts",
11
- "main": "dist/index.js",
12
- "types": "dist/index.d.ts",
13
- "exports": {
14
- ".": "./dist/index.js"
15
- },
16
- "keywords": [
17
- "chat",
18
- "multichat",
19
- "twitch",
20
- "kick",
21
- "realtime",
22
- "irc",
23
- "pusher",
24
- "typescript",
25
- "ts"
26
- ],
27
- "author": {
28
- "name": "Abdullah",
29
- "url": "https://github.com/0Abdullah"
30
- },
31
- "license": "MIT",
32
- "devDependencies": {
33
- "@eslint/js": "^9.10.0",
34
- "@types/node": "^22.5.4",
35
- "eslint": "^9.10.0",
36
- "eslint-config-prettier": "^9.1.0",
37
- "prettier": "^3.3.3",
38
- "typescript": "^5.5.4",
39
- "typescript-eslint": "^8.4.0"
40
- },
41
- "dependencies": {
42
- "partysocket": "^1.0.2",
43
- "pusher-js": "8.4.0-rc2"
44
- },
45
- "scripts": {
46
- "build": "tsc",
47
- "lint": "eslint .",
48
- "lint:fix": "eslint . --fix",
49
- "format": "prettier --check src",
50
- "format:fix": "prettier --write src"
51
- }
52
- }
2
+ "name": "multichat-ts",
3
+ "version": "0.0.4",
4
+ "type": "module",
5
+ "description": "Receive type-safe realtime events for chat-related messages on multiple platforms (Twitch, Kick)",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/0Abdullah/multichat-ts.git"
9
+ },
10
+ "homepage": "https://github.com/0Abdullah/multichat-ts",
11
+ "main": "dist/index.js",
12
+ "types": "dist/index.d.ts",
13
+ "exports": {
14
+ ".": "./dist/index.js"
15
+ },
16
+ "scripts": {
17
+ "build": "tsc",
18
+ "prepublishOnly": "pnpm build",
19
+ "pub": "npm publish --access public",
20
+ "lint": "eslint .",
21
+ "lint:fix": "eslint . --fix",
22
+ "format": "prettier --check src",
23
+ "format:fix": "prettier --write src"
24
+ },
25
+ "keywords": [
26
+ "chat",
27
+ "multichat",
28
+ "twitch",
29
+ "kick",
30
+ "realtime",
31
+ "irc",
32
+ "pusher",
33
+ "typescript",
34
+ "ts"
35
+ ],
36
+ "author": {
37
+ "name": "Abdullah",
38
+ "url": "https://github.com/0Abdullah"
39
+ },
40
+ "license": "MIT",
41
+ "devDependencies": {
42
+ "@eslint/js": "^9.10.0",
43
+ "@types/node": "^22.5.4",
44
+ "eslint": "^9.10.0",
45
+ "eslint-config-prettier": "^9.1.0",
46
+ "prettier": "^3.3.3",
47
+ "typescript": "^5.5.4",
48
+ "typescript-eslint": "^8.4.0"
49
+ },
50
+ "dependencies": {
51
+ "partysocket": "^1.0.2",
52
+ "pusher-js": "8.4.0-rc2"
53
+ }
54
+ }
package/src/kick.ts CHANGED
@@ -8,7 +8,8 @@ import {
8
8
  } from './index.js';
9
9
 
10
10
  type EventCallbackFunctions = {
11
- message: (data: Message) => unknown;
11
+ message: (message: Message) => unknown;
12
+ raw_message: (message: ChatMessageEvent) => unknown;
12
13
  };
13
14
 
14
15
  type EventNames = keyof EventCallbackFunctions;
@@ -109,8 +110,7 @@ export class KickPusher {
109
110
  }
110
111
 
111
112
  private onChatMessage(data: ChatMessageEvent) {
112
- console.log('onMessage', data);
113
-
113
+ this.public_listeners.raw_message?.(data);
114
114
  const text = data.content;
115
115
  const emote_matches = [...data.content.matchAll(/\[emote:\d+:[a-zA-Z0-9]*\]/g)];
116
116
  console.log(emote_matches);
package/src/twitch.ts CHANGED
@@ -16,10 +16,11 @@ const PING_INTERVAL_MS = 30_000;
16
16
  const PING_TIMEOUT_MS = 10_000;
17
17
 
18
18
  type EventCallbackFunctions = {
19
- message: (data: Message) => unknown;
19
+ message: (message: Message) => unknown;
20
20
  clear_messages: (data: ClearMessages) => unknown;
21
21
  delete_message: (data: DeleteMessage) => unknown;
22
- event: (data: Event) => unknown;
22
+ event: (event: Event) => unknown;
23
+ raw_message: (message: IRC_Message) => unknown;
23
24
  };
24
25
 
25
26
  type EventNames = keyof EventCallbackFunctions;
@@ -122,6 +123,7 @@ export class TwitchIRC {
122
123
  const lines = String(event.data).trim().split('\r\n');
123
124
  const messages = lines.map(parseIRCLine);
124
125
  messages.forEach((message) => {
126
+ this.public_listeners.raw_message?.(message);
125
127
  switch (message.command) {
126
128
  case 'PONG': {
127
129
  if (!this.ping.lastSentTimestamp) return console.error('got PONG without sending PING');