@lazyneoaz/metachat 4.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/LICENSE +21 -0
- package/README.md +152 -0
- package/assets/banner.svg +69 -0
- package/dist/index.cjs +100006 -0
- package/dist/index.d.mts +555 -0
- package/dist/index.d.ts +555 -0
- package/dist/index.js +14 -0
- package/dist/index.mjs +99969 -0
- package/package.json +112 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 @lazyneoaz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# MetaChat
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="./assets/banner.svg" alt="MetaChat — real-time Messenger automation" />
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
MetaChat is a TypeScript client for automating Facebook Messenger conversations.
|
|
8
|
+
It provides authenticated HTTP and MQTT APIs for messaging, thread management,
|
|
9
|
+
user lookup, attachments, reactions, music search, and theme operations.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
- Node.js 18 or newer
|
|
14
|
+
- A Facebook session supplied as an app state cookie array or cookie string
|
|
15
|
+
- An account authorized to use the requested Facebook features
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @lazyneoaz/metachat
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick start
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { login } from "@lazyneoaz/metachat";
|
|
27
|
+
|
|
28
|
+
const api = await login({ appState: process.env.FACEBOOK_APP_STATE });
|
|
29
|
+
|
|
30
|
+
api.listenMqtt((error, event) => {
|
|
31
|
+
if (error) {
|
|
32
|
+
console.error(error);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (event.type === "message" && event.body === "ping") {
|
|
37
|
+
void api.sendMessage("pong", event.threadID);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The login callback form is also supported:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
login({ appState: cookies }, (error, api) => {
|
|
46
|
+
if (error) throw error;
|
|
47
|
+
api.sendMessage("Connected", threadID);
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Authentication and options
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
const api = await login(
|
|
55
|
+
{ appState: cookies },
|
|
56
|
+
{
|
|
57
|
+
listenEvents: true,
|
|
58
|
+
selfListen: false,
|
|
59
|
+
autoReconnect: true,
|
|
60
|
+
autoMarkRead: false,
|
|
61
|
+
updatePresence: false,
|
|
62
|
+
proxy: "http://host:port",
|
|
63
|
+
},
|
|
64
|
+
);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`appState` may be an array of cookie objects or a semicolon-separated cookie
|
|
68
|
+
string. Email and password credentials are also accepted, but app state is the
|
|
69
|
+
preferred authentication method.
|
|
70
|
+
|
|
71
|
+
Each login creates an independent session with its own cookie jar and options.
|
|
72
|
+
The MQTT listener reconnects automatically after transient connection failures.
|
|
73
|
+
Call `api.logout()` when the session should stop reconnecting.
|
|
74
|
+
|
|
75
|
+
## Common operations
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
await api.sendMessage("Hello", threadID);
|
|
79
|
+
await api.sendMessage(
|
|
80
|
+
{ body: "Here is a file", attachment: fileStream },
|
|
81
|
+
threadID,
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
await api.getThreadInfo(threadID);
|
|
85
|
+
await api.getThreadHistory(threadID, 20, null);
|
|
86
|
+
await api.getUserInfo(userID);
|
|
87
|
+
await api.setMessageReaction("👍", messageID);
|
|
88
|
+
await api.markAsRead(threadID);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Methods that support callbacks also return promises. The callback uses the
|
|
92
|
+
Node.js convention `(error, result)`.
|
|
93
|
+
|
|
94
|
+
## Music search
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
const result = await api.searchMusic("lofi beats", { count: 10 });
|
|
98
|
+
|
|
99
|
+
for (const track of result.tracks) {
|
|
100
|
+
console.log(track.title, track.artist, track.audioUrl);
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The result preserves Facebook's ordering and includes pagination metadata:
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
{
|
|
108
|
+
tracks: MusicTrack[],
|
|
109
|
+
endCursor: string | null,
|
|
110
|
+
hasNextPage: boolean,
|
|
111
|
+
query: string
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## MQTT listeners
|
|
116
|
+
|
|
117
|
+
`listenMqtt` delivers messages and enabled event types in real time. The
|
|
118
|
+
connection uses automatic reconnect with bounded backoff and continues trying
|
|
119
|
+
until the listener is stopped, the session is logged out, or
|
|
120
|
+
`autoReconnect` is disabled.
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
const listener = api.listenMqtt((error, event) => {
|
|
124
|
+
if (error) {
|
|
125
|
+
console.error(error);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
console.log(event);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
listener.stop();
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
`listenSpeed` is available as a lightweight alternative for applications that
|
|
135
|
+
do not require a persistent MQTT connection.
|
|
136
|
+
|
|
137
|
+
## Development
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
npm install
|
|
141
|
+
npm run typecheck
|
|
142
|
+
npm run build
|
|
143
|
+
npm test
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## License
|
|
147
|
+
|
|
148
|
+
MIT
|
|
149
|
+
|
|
150
|
+
Facebook and Messenger are trademarks of Meta Platforms, Inc. This project is
|
|
151
|
+
not affiliated with or endorsed by Meta Platforms, Inc. Facebook may change
|
|
152
|
+
internal APIs without notice.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<svg width="1200" height="420" viewBox="0 0 1200 420" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="title desc">
|
|
2
|
+
<title id="title">MetaChat</title>
|
|
3
|
+
<desc id="desc">Animated gradient banner for MetaChat Messenger automation.</desc>
|
|
4
|
+
<defs>
|
|
5
|
+
<linearGradient id="background" x1="0" y1="0" x2="1200" y2="420" gradientUnits="userSpaceOnUse">
|
|
6
|
+
<stop stop-color="#090B18"/>
|
|
7
|
+
<stop offset="0.52" stop-color="#17133A"/>
|
|
8
|
+
<stop offset="1" stop-color="#071D2A"/>
|
|
9
|
+
</linearGradient>
|
|
10
|
+
<linearGradient id="accent" x1="220" y1="92" x2="924" y2="322" gradientUnits="userSpaceOnUse">
|
|
11
|
+
<stop stop-color="#A78BFA"/>
|
|
12
|
+
<stop offset="0.5" stop-color="#38BDF8"/>
|
|
13
|
+
<stop offset="1" stop-color="#2DD4BF"/>
|
|
14
|
+
</linearGradient>
|
|
15
|
+
<radialGradient id="glow">
|
|
16
|
+
<stop stop-color="#8B5CF6" stop-opacity="0.55"/>
|
|
17
|
+
<stop offset="1" stop-color="#8B5CF6" stop-opacity="0"/>
|
|
18
|
+
</radialGradient>
|
|
19
|
+
<filter id="blur" x="-100%" y="-100%" width="300%" height="300%">
|
|
20
|
+
<feGaussianBlur stdDeviation="28"/>
|
|
21
|
+
</filter>
|
|
22
|
+
<filter id="shadow" x="-30%" y="-30%" width="160%" height="180%">
|
|
23
|
+
<feDropShadow dx="0" dy="18" stdDeviation="20" flood-color="#000000" flood-opacity="0.35"/>
|
|
24
|
+
</filter>
|
|
25
|
+
<pattern id="grid" width="48" height="48" patternUnits="userSpaceOnUse">
|
|
26
|
+
<path d="M48 0H0V48" stroke="#FFFFFF" stroke-opacity="0.06"/>
|
|
27
|
+
</pattern>
|
|
28
|
+
</defs>
|
|
29
|
+
|
|
30
|
+
<rect width="1200" height="420" rx="32" fill="url(#background)"/>
|
|
31
|
+
<rect width="1200" height="420" rx="32" fill="url(#grid)"/>
|
|
32
|
+
<circle cx="152" cy="72" r="190" fill="url(#glow)" filter="url(#blur)">
|
|
33
|
+
<animate attributeName="cx" values="152;240;152" dur="9s" repeatCount="indefinite"/>
|
|
34
|
+
<animate attributeName="cy" values="72;130;72" dur="9s" repeatCount="indefinite"/>
|
|
35
|
+
</circle>
|
|
36
|
+
<circle cx="1050" cy="360" r="220" fill="url(#glow)" filter="url(#blur)" opacity="0.7">
|
|
37
|
+
<animate attributeName="cx" values="1050;940;1050" dur="11s" repeatCount="indefinite"/>
|
|
38
|
+
<animate attributeName="cy" values="360;300;360" dur="11s" repeatCount="indefinite"/>
|
|
39
|
+
</circle>
|
|
40
|
+
|
|
41
|
+
<g opacity="0.85">
|
|
42
|
+
<path d="M80 318C242 248 266 366 420 296C574 226 616 332 752 270C888 208 949 304 1120 210" stroke="url(#accent)" stroke-width="2" stroke-linecap="round" stroke-dasharray="8 14">
|
|
43
|
+
<animate attributeName="stroke-dashoffset" from="0" to="-220" dur="7s" repeatCount="indefinite"/>
|
|
44
|
+
</path>
|
|
45
|
+
<circle cx="420" cy="296" r="5" fill="#38BDF8">
|
|
46
|
+
<animate attributeName="r" values="4;9;4" dur="2.5s" repeatCount="indefinite"/>
|
|
47
|
+
<animate attributeName="opacity" values="1;0.35;1" dur="2.5s" repeatCount="indefinite"/>
|
|
48
|
+
</circle>
|
|
49
|
+
<circle cx="752" cy="270" r="5" fill="#2DD4BF">
|
|
50
|
+
<animate attributeName="r" values="4;9;4" dur="2.2s" begin="0.7s" repeatCount="indefinite"/>
|
|
51
|
+
<animate attributeName="opacity" values="1;0.35;1" dur="2.2s" begin="0.7s" repeatCount="indefinite"/>
|
|
52
|
+
</circle>
|
|
53
|
+
</g>
|
|
54
|
+
|
|
55
|
+
<g filter="url(#shadow)">
|
|
56
|
+
<rect x="86" y="88" width="74" height="74" rx="22" fill="#FFFFFF" fill-opacity="0.08" stroke="#FFFFFF" stroke-opacity="0.18"/>
|
|
57
|
+
<path d="M105 111C105 104.373 110.373 99 117 99H129C135.627 99 141 104.373 141 111V123C141 129.627 135.627 135 129 135H122L114 143V135H117C110.373 135 105 129.627 105 123V111Z" stroke="url(#accent)" stroke-width="3"/>
|
|
58
|
+
<circle cx="116" cy="117" r="2.5" fill="#A78BFA"/>
|
|
59
|
+
<circle cx="123" cy="117" r="2.5" fill="#38BDF8"/>
|
|
60
|
+
<circle cx="130" cy="117" r="2.5" fill="#2DD4BF"/>
|
|
61
|
+
</g>
|
|
62
|
+
|
|
63
|
+
<text x="86" y="236" fill="white" font-family="Inter,Segoe UI,Arial,sans-serif" font-size="74" font-weight="800" letter-spacing="8">METACHAT</text>
|
|
64
|
+
<text x="92" y="274" fill="#C4B5FD" font-family="Inter,Segoe UI,Arial,sans-serif" font-size="18" font-weight="600" letter-spacing="4">REAL-TIME MESSENGER AUTOMATION</text>
|
|
65
|
+
<text x="92" y="304" fill="#2DD4BF" font-family="Inter,Segoe UI,Arial,sans-serif" font-size="15" font-weight="600" letter-spacing="2">by @lazyneoaz</text>
|
|
66
|
+
<rect x="92" y="324" width="128" height="4" rx="2" fill="url(#accent)">
|
|
67
|
+
<animate attributeName="width" values="64;180;64" dur="3.5s" repeatCount="indefinite"/>
|
|
68
|
+
</rect>
|
|
69
|
+
</svg>
|