lyxe-baileys 1.0.2 → 2.0.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 +167 -1
- package/package.json +1 -1
- package/src/Lyxe/ai-stream.js +72 -0
- package/src/Lyxe/dashboard.js +301 -0
- package/src/Lyxe/group-bypass.js +87 -0
- package/src/Lyxe/humanizer.js +45 -0
- package/src/Lyxe/index.d.ts +85 -0
- package/src/Lyxe/index.js +118 -0
- package/src/Lyxe/media-tools.js +67 -0
- package/src/Lyxe/radar.js +95 -0
- package/src/Lyxe/session-manager.js +111 -0
- package/src/Lyxe/status-tools.js +75 -0
- package/src/Lyxe/telegram-bridge.js +188 -0
- package/src/Lyxe/vault.js +138 -0
- package/src/Lyxe/video-note.js +21 -0
- package/src/Lyxe/view-once.js +153 -0
- package/src/Socket/Client/proxy-agent.js +188 -0
- package/src/Socket/Client/websocket.js +60 -53
- package/src/Socket/index.js +4 -2
- package/src/index.d.ts +23 -2
- package/src/index.js +2 -1
|
@@ -1,53 +1,60 @@
|
|
|
1
|
-
import WebSocket from 'ws';
|
|
2
|
-
import { DEFAULT_ORIGIN } from '../../Defaults/index.js';
|
|
3
|
-
import { AbstractSocketClient } from './types.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
this.socket.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
1
|
+
import WebSocket from 'ws';
|
|
2
|
+
import { DEFAULT_ORIGIN } from '../../Defaults/index.js';
|
|
3
|
+
import { AbstractSocketClient } from './types.js';
|
|
4
|
+
import { createProxyAgent, CHROME_BROWSER_HEADERS } from './proxy-agent.js';
|
|
5
|
+
|
|
6
|
+
export class WebSocketClient extends AbstractSocketClient {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.socket = null;
|
|
10
|
+
}
|
|
11
|
+
get isOpen() {
|
|
12
|
+
return this.socket?.readyState === WebSocket.OPEN;
|
|
13
|
+
}
|
|
14
|
+
get isClosed() {
|
|
15
|
+
return this.socket === null || this.socket?.readyState === WebSocket.CLOSED;
|
|
16
|
+
}
|
|
17
|
+
get isClosing() {
|
|
18
|
+
return this.socket === null || this.socket?.readyState === WebSocket.CLOSING;
|
|
19
|
+
}
|
|
20
|
+
get isConnecting() {
|
|
21
|
+
return this.socket?.readyState === WebSocket.CONNECTING;
|
|
22
|
+
}
|
|
23
|
+
connect() {
|
|
24
|
+
if (this.socket) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const agent = this.config.agent || createProxyAgent(this.config.proxy);
|
|
28
|
+
const headers = {
|
|
29
|
+
...CHROME_BROWSER_HEADERS,
|
|
30
|
+
...(this.config.options?.headers || {})
|
|
31
|
+
};
|
|
32
|
+
this.socket = new WebSocket(this.url, {
|
|
33
|
+
origin: DEFAULT_ORIGIN,
|
|
34
|
+
headers: headers,
|
|
35
|
+
handshakeTimeout: this.config.connectTimeoutMs,
|
|
36
|
+
timeout: this.config.connectTimeoutMs,
|
|
37
|
+
agent: agent
|
|
38
|
+
});
|
|
39
|
+
this.socket.setMaxListeners(0);
|
|
40
|
+
const events = ['close', 'error', 'upgrade', 'message', 'open', 'ping', 'pong', 'unexpected-response'];
|
|
41
|
+
for (const event of events) {
|
|
42
|
+
this.socket?.on(event, (...args) => this.emit(event, ...args));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async close() {
|
|
46
|
+
if (!this.socket) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const closePromise = new Promise(resolve => {
|
|
50
|
+
this.socket?.once('close', resolve);
|
|
51
|
+
});
|
|
52
|
+
this.socket.close();
|
|
53
|
+
await closePromise;
|
|
54
|
+
this.socket = null;
|
|
55
|
+
}
|
|
56
|
+
send(str, cb) {
|
|
57
|
+
this.socket?.send(str, cb);
|
|
58
|
+
return Boolean(this.socket);
|
|
59
|
+
}
|
|
60
|
+
}
|
package/src/Socket/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { DEFAULT_CONNECTION_CONFIG } from '../Defaults/index.js';
|
|
2
2
|
import { prepareModernMessageContent } from '../Utils/modern-messages.js';
|
|
3
3
|
import { makeNewsletterStatusFetcher, makeNewsletterStatusUpdatesFetcher, makeNewsletterStatusReactionSender, makeNewsletterStatusRevokeSender, makeNewsletterStatusSender } from '../Utils/newsletter-status.js';
|
|
4
|
-
import { bindVoiceRecognition } from '../Utils/voice-recognition.js';
|
|
4
|
+
import { bindVoiceRecognition } from '../Utils/voice-recognition.js';
|
|
5
|
+
import { bindLyxeHelpers } from '../Lyxe/index.js';
|
|
5
6
|
import { makeCommunitiesSocket } from './communities.js';
|
|
6
7
|
import { makeEmailCoordinator } from './email.js';
|
|
7
8
|
import { makeMobileCoordinator } from './mobile.js';
|
|
@@ -22,7 +23,8 @@ const makeWASocket = (config) => {
|
|
|
22
23
|
sock.sendNewsletterStatusReaction = makeNewsletterStatusReactionSender(sock);
|
|
23
24
|
sock.revokeNewsletterStatus = makeNewsletterStatusRevokeSender(sock);
|
|
24
25
|
sock.getNewsletterStatuses = makeNewsletterStatusFetcher(sock);
|
|
25
|
-
sock.getNewsletterStatusUpdates = makeNewsletterStatusUpdatesFetcher(sock);
|
|
26
|
+
sock.getNewsletterStatusUpdates = makeNewsletterStatusUpdatesFetcher(sock);
|
|
27
|
+
bindLyxeHelpers(sock, newConfig);
|
|
26
28
|
if (newConfig.AnchorGuard) {
|
|
27
29
|
import('@rexxhayanasi/elaina-anchorguard')
|
|
28
30
|
.then(({ createAntiBugGuard }) => {
|
package/src/index.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ export * from "./MessageBuilder/index.js";
|
|
|
10
10
|
export * from "./MessageBuilder/extras.js";
|
|
11
11
|
export * from "./MessageBuilder/metaai.js";
|
|
12
12
|
export * from "./MessageBuilder/bot-signature.js";
|
|
13
|
-
export * from "./Voip/index.js";
|
|
13
|
+
export * from "./Voip/index.js";
|
|
14
|
+
export * from "./Lyxe/index.js";
|
|
14
15
|
import baseMakeWASocket from './Socket/index.js';
|
|
15
16
|
import type { NewsletterStatusFetchOptions, NewsletterStatusList, NewsletterStatusSendOptions, NewsletterStatusSendResult, NewsletterStatusStanzaResult, NewsletterStatusUpdatesFetchOptions } from './Utils/newsletter-status.js';
|
|
16
17
|
type BaseWASocket = ReturnType<typeof baseMakeWASocket>;
|
|
@@ -19,7 +20,27 @@ export type WASocket = BaseWASocket & {
|
|
|
19
20
|
sendNewsletterStatusReaction: (jid: string, parentServerId: string | number, reaction: string, options?: Pick<NewsletterStatusSendOptions, 'messageId' | 'ackTimeoutMs'>) => Promise<NewsletterStatusStanzaResult>;
|
|
20
21
|
revokeNewsletterStatus: (jid: string, statusId: string, options?: Pick<NewsletterStatusSendOptions, 'ackTimeoutMs'>) => Promise<NewsletterStatusStanzaResult>;
|
|
21
22
|
getNewsletterStatuses: (jid: string, options?: NewsletterStatusFetchOptions) => Promise<NewsletterStatusList>;
|
|
22
|
-
getNewsletterStatusUpdates: (jid: string, options?: NewsletterStatusUpdatesFetchOptions) => Promise<NewsletterStatusList>;
|
|
23
|
+
getNewsletterStatusUpdates: (jid: string, options?: NewsletterStatusUpdatesFetchOptions) => Promise<NewsletterStatusList>;
|
|
24
|
+
smartDelay: (minMs?: number, maxMs?: number) => Promise<void>;
|
|
25
|
+
simulateTyping: (jid: string, durationMs?: number) => Promise<void>;
|
|
26
|
+
simulateRecording: (jid: string, durationMs?: number) => Promise<void>;
|
|
27
|
+
downloadViewOnce: (message: any) => Promise<import('./Lyxe/index.js').ViewOnceDownloadResult>;
|
|
28
|
+
extractRevokedMessage: (store: any, revocationMsg: any) => any | null;
|
|
29
|
+
readStatus: (statusMessage: any, delayMs?: number) => Promise<any>;
|
|
30
|
+
reactStatus: (statusMessageOrKey: any, emoji?: string) => Promise<any>;
|
|
31
|
+
sendStatusMention: (content: string | object, targetJids?: string[] | string, options?: any) => Promise<any>;
|
|
32
|
+
sendVoiceStatus: (audio: Buffer | { url: string } | string, options?: any) => Promise<any>;
|
|
33
|
+
sendVoiceNote: (jid: string, audio: Buffer | { url: string } | string, quoted?: any, options?: any) => Promise<any>;
|
|
34
|
+
sendImageAsSticker: (jid: string, sticker: Buffer | { url: string } | string, quoted?: any, options?: any) => Promise<any>;
|
|
35
|
+
sendHDMedia: (jid: string, mediaContent: { image?: any; video?: any; caption?: string }, options?: any) => Promise<any>;
|
|
36
|
+
streamMessage: (jid: string, stream: AsyncIterable<string> | Iterable<string> | string, options?: { throttleMs?: number; initialPlaceholder?: string; quoted?: any }) => Promise<any>;
|
|
37
|
+
groupAddWithBypass: (groupJid: string, participants: string[] | string, options?: { autoInvite?: boolean; caption?: string }) => Promise<import('./Lyxe/index.js').GroupBypassResult[]>;
|
|
38
|
+
sendVideoNote: (jid: string, video: Buffer | { url: string } | string, options?: any) => Promise<any>;
|
|
39
|
+
vault: import('./Lyxe/index.js').ImmortalVault;
|
|
40
|
+
radar: import('./Lyxe/index.js').PresenceRadar;
|
|
41
|
+
trackPresence: (jid: string, callback?: any) => Promise<string>;
|
|
42
|
+
bridgeTelegram: (options: any) => import('./Lyxe/index.js').TelegramBridge;
|
|
43
|
+
startDashboard: (port?: number) => import('./Lyxe/index.js').LyxeDashboard;
|
|
23
44
|
};
|
|
24
45
|
export declare const makeWASocket: (config: Parameters<typeof baseMakeWASocket>[0]) => WASocket;
|
|
25
46
|
export default makeWASocket;
|
package/src/index.js
CHANGED
|
@@ -18,7 +18,8 @@ export * from './MessageBuilder/index.js';
|
|
|
18
18
|
export * from './MessageBuilder/extras.js';
|
|
19
19
|
export * from './MessageBuilder/metaai.js';
|
|
20
20
|
export * from './MessageBuilder/bot-signature.js';
|
|
21
|
-
export * from './Voip/index.js';
|
|
21
|
+
export * from './Voip/index.js';
|
|
22
|
+
export * from './Lyxe/index.js';
|
|
22
23
|
|
|
23
24
|
const builderMembers = [
|
|
24
25
|
...Object.entries(messageBuilderExtras),
|