zaileys 0.27.1-dev → 0.28.1-dev
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.mts +49 -80
- package/dist/index.d.ts +49 -80
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +3 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,82 +1,38 @@
|
|
|
1
1
|
import { WAMessage, makeInMemoryStore, AuthenticationState, UserFacingSocketConfig } from 'baileys';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Represents the properties of the ReadyParserProps.
|
|
5
|
-
* Used to represent the status of the client.
|
|
6
|
-
*/
|
|
7
3
|
type ReadyParserProps = 'ready' | 'connecting' | 'close';
|
|
8
|
-
|
|
9
|
-
* Represents the properties of the MessageTypeProps.
|
|
10
|
-
* Used to represent the type of the message.
|
|
11
|
-
*/
|
|
12
|
-
type MessageTypeProps = 'text' | 'sticker' | 'image' | 'video' | 'document' | 'product' | 'reaction' | 'gif' | 'audio' | 'voice' | 'contact' | 'polling' | 'location' | 'unknown';
|
|
13
|
-
/**
|
|
14
|
-
* Represents the internal properties of a message.
|
|
15
|
-
* Used to hold the essential information about a message.
|
|
16
|
-
*/
|
|
17
|
-
type MessageInternalProps = {
|
|
18
|
-
/**
|
|
19
|
-
* The ID of the chat the message is in.
|
|
20
|
-
* @type {string}
|
|
21
|
-
*/
|
|
22
|
-
chatId: string;
|
|
23
|
-
/**
|
|
24
|
-
* Whether the message was sent by the current user.
|
|
25
|
-
* @type {boolean}
|
|
26
|
-
*/
|
|
27
|
-
fromMe: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* The user's username.
|
|
30
|
-
* @type {string}
|
|
31
|
-
*/
|
|
32
|
-
pushName: string;
|
|
33
|
-
/**
|
|
34
|
-
* The user's ID.
|
|
35
|
-
* @type {string}
|
|
36
|
-
*/
|
|
37
|
-
remoteJid: string;
|
|
38
|
-
/**
|
|
39
|
-
* The timestamp of the message.
|
|
40
|
-
* @type {number}
|
|
41
|
-
*/
|
|
42
|
-
timestamp: number;
|
|
43
|
-
/**
|
|
44
|
-
* Whether the message is from an authorized user.
|
|
45
|
-
* @type {boolean}
|
|
46
|
-
*/
|
|
47
|
-
isAuthor: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Whether the message is a broadcast message.
|
|
50
|
-
* @type {boolean}
|
|
51
|
-
*/
|
|
52
|
-
isBroadcast: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Whether the message is sent in a group.
|
|
55
|
-
* @type {boolean}
|
|
56
|
-
*/
|
|
57
|
-
isGroup: boolean;
|
|
58
|
-
/**
|
|
59
|
-
* Whether the message is a view-once message.
|
|
60
|
-
* @type {boolean}
|
|
61
|
-
*/
|
|
62
|
-
isViewOnce: boolean;
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Represents the parsed properties of a message.
|
|
66
|
-
* Used to hold the parsed information about a message.
|
|
67
|
-
*/
|
|
68
|
-
type MessageParserProps = MessageInternalProps[] & {
|
|
69
|
-
/**
|
|
70
|
-
* The body of the message.
|
|
71
|
-
* @type {Object}
|
|
72
|
-
* @property {MessageTypeProps} type - The type of the message.
|
|
73
|
-
* @property {string} [text] - The text of the message (if applicable).
|
|
74
|
-
*/
|
|
4
|
+
type MessageParserProps = {
|
|
75
5
|
body: {
|
|
76
|
-
|
|
77
|
-
|
|
6
|
+
fromMe: boolean;
|
|
7
|
+
chatId: string;
|
|
8
|
+
remoteJid: string;
|
|
9
|
+
participant: string;
|
|
10
|
+
pushName: string;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
type: string;
|
|
13
|
+
text: string;
|
|
14
|
+
isStory: boolean;
|
|
15
|
+
isGroup: boolean;
|
|
16
|
+
isViewOnce: boolean;
|
|
17
|
+
isForwarded: boolean;
|
|
18
|
+
isEdited: boolean;
|
|
19
|
+
isBroadcast: boolean;
|
|
20
|
+
isAuthor: boolean;
|
|
21
|
+
isEphemeral: boolean;
|
|
22
|
+
media: any;
|
|
23
|
+
};
|
|
24
|
+
reply: {
|
|
25
|
+
chatId: string;
|
|
26
|
+
participant: string;
|
|
27
|
+
type: string;
|
|
28
|
+
text: string;
|
|
29
|
+
isGroup: boolean;
|
|
30
|
+
isViewOnce: boolean;
|
|
31
|
+
isForwarded: boolean;
|
|
32
|
+
isAuthor: boolean;
|
|
33
|
+
media: any;
|
|
78
34
|
};
|
|
79
|
-
}
|
|
35
|
+
};
|
|
80
36
|
|
|
81
37
|
type Prettify<T> = {
|
|
82
38
|
[K in keyof T]: T[K];
|
|
@@ -84,6 +40,7 @@ type Prettify<T> = {
|
|
|
84
40
|
type ClientProps = {
|
|
85
41
|
phoneNumber: number;
|
|
86
42
|
pairing?: boolean;
|
|
43
|
+
markOnline?: boolean;
|
|
87
44
|
showLogs?: boolean;
|
|
88
45
|
ignoreMe?: boolean;
|
|
89
46
|
authors?: number[];
|
|
@@ -93,23 +50,35 @@ type ActionsProps = {
|
|
|
93
50
|
connection: ReadyParserProps;
|
|
94
51
|
};
|
|
95
52
|
|
|
96
|
-
declare class
|
|
53
|
+
declare class Actions {
|
|
54
|
+
constructor({ pairing, markOnline, phoneNumber, showLogs, authors, ignoreMe }: ClientProps);
|
|
55
|
+
sendText(): string;
|
|
56
|
+
sendReply(): void;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
declare class Client extends Actions {
|
|
97
60
|
pairing: boolean;
|
|
61
|
+
markOnline: boolean;
|
|
98
62
|
phoneNumber: number;
|
|
99
63
|
showLogs: boolean;
|
|
100
64
|
authors: number[];
|
|
101
65
|
ignoreMe: boolean;
|
|
102
|
-
private canNext;
|
|
103
66
|
private socket;
|
|
104
|
-
private
|
|
105
|
-
|
|
67
|
+
private socked;
|
|
68
|
+
private spinners;
|
|
69
|
+
private initialized;
|
|
70
|
+
private initPromise;
|
|
71
|
+
constructor({ pairing, markOnline, phoneNumber, showLogs, authors, ignoreMe }: ClientProps);
|
|
106
72
|
private init;
|
|
107
73
|
on<T extends keyof ActionsProps>(actions: T, callback: (ctx: Prettify<ActionsProps[T]>) => void): Promise<void>;
|
|
74
|
+
sendMsg(text: string, { jid }: {
|
|
75
|
+
jid: string;
|
|
76
|
+
}): Promise<void>;
|
|
108
77
|
}
|
|
109
78
|
|
|
110
79
|
declare function InitDisplay(config: ClientProps): void;
|
|
111
80
|
|
|
112
|
-
declare function MessageParser(ctx: WAMessage[], config: ClientProps, store: ReturnType<typeof makeInMemoryStore
|
|
81
|
+
declare function MessageParser(ctx: WAMessage[], config: ClientProps, store: ReturnType<typeof makeInMemoryStore>, state: AuthenticationState): Promise<MessageParserProps[] | undefined>;
|
|
113
82
|
|
|
114
83
|
declare function ConnectionConfig(props: ClientProps, state: AuthenticationState, store: ReturnType<typeof makeInMemoryStore>): UserFacingSocketConfig;
|
|
115
84
|
declare const MESSAGE_TYPE: {
|
|
@@ -189,4 +158,4 @@ declare function getValuesByKeys(object: any, keys: string[]): any[];
|
|
|
189
158
|
declare function removeKeys(object: any, keys: string[]): any;
|
|
190
159
|
declare function getMessageType(obj: any): string[];
|
|
191
160
|
|
|
192
|
-
export { type ActionsProps, Client, type ClientProps, ConnectionConfig, InitDisplay, MESSAGE_TYPE, MessageParser, type Prettify, delay, fetchJson, getMessageType, getValuesByKeys, jsonParse, jsonString, loop, postJson, removeKeys, timeout };
|
|
161
|
+
export { Actions, type ActionsProps, Client, type ClientProps, ConnectionConfig, InitDisplay, MESSAGE_TYPE, MessageParser, type Prettify, delay, fetchJson, getMessageType, getValuesByKeys, jsonParse, jsonString, loop, postJson, removeKeys, timeout };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,82 +1,38 @@
|
|
|
1
1
|
import { WAMessage, makeInMemoryStore, AuthenticationState, UserFacingSocketConfig } from 'baileys';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Represents the properties of the ReadyParserProps.
|
|
5
|
-
* Used to represent the status of the client.
|
|
6
|
-
*/
|
|
7
3
|
type ReadyParserProps = 'ready' | 'connecting' | 'close';
|
|
8
|
-
|
|
9
|
-
* Represents the properties of the MessageTypeProps.
|
|
10
|
-
* Used to represent the type of the message.
|
|
11
|
-
*/
|
|
12
|
-
type MessageTypeProps = 'text' | 'sticker' | 'image' | 'video' | 'document' | 'product' | 'reaction' | 'gif' | 'audio' | 'voice' | 'contact' | 'polling' | 'location' | 'unknown';
|
|
13
|
-
/**
|
|
14
|
-
* Represents the internal properties of a message.
|
|
15
|
-
* Used to hold the essential information about a message.
|
|
16
|
-
*/
|
|
17
|
-
type MessageInternalProps = {
|
|
18
|
-
/**
|
|
19
|
-
* The ID of the chat the message is in.
|
|
20
|
-
* @type {string}
|
|
21
|
-
*/
|
|
22
|
-
chatId: string;
|
|
23
|
-
/**
|
|
24
|
-
* Whether the message was sent by the current user.
|
|
25
|
-
* @type {boolean}
|
|
26
|
-
*/
|
|
27
|
-
fromMe: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* The user's username.
|
|
30
|
-
* @type {string}
|
|
31
|
-
*/
|
|
32
|
-
pushName: string;
|
|
33
|
-
/**
|
|
34
|
-
* The user's ID.
|
|
35
|
-
* @type {string}
|
|
36
|
-
*/
|
|
37
|
-
remoteJid: string;
|
|
38
|
-
/**
|
|
39
|
-
* The timestamp of the message.
|
|
40
|
-
* @type {number}
|
|
41
|
-
*/
|
|
42
|
-
timestamp: number;
|
|
43
|
-
/**
|
|
44
|
-
* Whether the message is from an authorized user.
|
|
45
|
-
* @type {boolean}
|
|
46
|
-
*/
|
|
47
|
-
isAuthor: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Whether the message is a broadcast message.
|
|
50
|
-
* @type {boolean}
|
|
51
|
-
*/
|
|
52
|
-
isBroadcast: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Whether the message is sent in a group.
|
|
55
|
-
* @type {boolean}
|
|
56
|
-
*/
|
|
57
|
-
isGroup: boolean;
|
|
58
|
-
/**
|
|
59
|
-
* Whether the message is a view-once message.
|
|
60
|
-
* @type {boolean}
|
|
61
|
-
*/
|
|
62
|
-
isViewOnce: boolean;
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Represents the parsed properties of a message.
|
|
66
|
-
* Used to hold the parsed information about a message.
|
|
67
|
-
*/
|
|
68
|
-
type MessageParserProps = MessageInternalProps[] & {
|
|
69
|
-
/**
|
|
70
|
-
* The body of the message.
|
|
71
|
-
* @type {Object}
|
|
72
|
-
* @property {MessageTypeProps} type - The type of the message.
|
|
73
|
-
* @property {string} [text] - The text of the message (if applicable).
|
|
74
|
-
*/
|
|
4
|
+
type MessageParserProps = {
|
|
75
5
|
body: {
|
|
76
|
-
|
|
77
|
-
|
|
6
|
+
fromMe: boolean;
|
|
7
|
+
chatId: string;
|
|
8
|
+
remoteJid: string;
|
|
9
|
+
participant: string;
|
|
10
|
+
pushName: string;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
type: string;
|
|
13
|
+
text: string;
|
|
14
|
+
isStory: boolean;
|
|
15
|
+
isGroup: boolean;
|
|
16
|
+
isViewOnce: boolean;
|
|
17
|
+
isForwarded: boolean;
|
|
18
|
+
isEdited: boolean;
|
|
19
|
+
isBroadcast: boolean;
|
|
20
|
+
isAuthor: boolean;
|
|
21
|
+
isEphemeral: boolean;
|
|
22
|
+
media: any;
|
|
23
|
+
};
|
|
24
|
+
reply: {
|
|
25
|
+
chatId: string;
|
|
26
|
+
participant: string;
|
|
27
|
+
type: string;
|
|
28
|
+
text: string;
|
|
29
|
+
isGroup: boolean;
|
|
30
|
+
isViewOnce: boolean;
|
|
31
|
+
isForwarded: boolean;
|
|
32
|
+
isAuthor: boolean;
|
|
33
|
+
media: any;
|
|
78
34
|
};
|
|
79
|
-
}
|
|
35
|
+
};
|
|
80
36
|
|
|
81
37
|
type Prettify<T> = {
|
|
82
38
|
[K in keyof T]: T[K];
|
|
@@ -84,6 +40,7 @@ type Prettify<T> = {
|
|
|
84
40
|
type ClientProps = {
|
|
85
41
|
phoneNumber: number;
|
|
86
42
|
pairing?: boolean;
|
|
43
|
+
markOnline?: boolean;
|
|
87
44
|
showLogs?: boolean;
|
|
88
45
|
ignoreMe?: boolean;
|
|
89
46
|
authors?: number[];
|
|
@@ -93,23 +50,35 @@ type ActionsProps = {
|
|
|
93
50
|
connection: ReadyParserProps;
|
|
94
51
|
};
|
|
95
52
|
|
|
96
|
-
declare class
|
|
53
|
+
declare class Actions {
|
|
54
|
+
constructor({ pairing, markOnline, phoneNumber, showLogs, authors, ignoreMe }: ClientProps);
|
|
55
|
+
sendText(): string;
|
|
56
|
+
sendReply(): void;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
declare class Client extends Actions {
|
|
97
60
|
pairing: boolean;
|
|
61
|
+
markOnline: boolean;
|
|
98
62
|
phoneNumber: number;
|
|
99
63
|
showLogs: boolean;
|
|
100
64
|
authors: number[];
|
|
101
65
|
ignoreMe: boolean;
|
|
102
|
-
private canNext;
|
|
103
66
|
private socket;
|
|
104
|
-
private
|
|
105
|
-
|
|
67
|
+
private socked;
|
|
68
|
+
private spinners;
|
|
69
|
+
private initialized;
|
|
70
|
+
private initPromise;
|
|
71
|
+
constructor({ pairing, markOnline, phoneNumber, showLogs, authors, ignoreMe }: ClientProps);
|
|
106
72
|
private init;
|
|
107
73
|
on<T extends keyof ActionsProps>(actions: T, callback: (ctx: Prettify<ActionsProps[T]>) => void): Promise<void>;
|
|
74
|
+
sendMsg(text: string, { jid }: {
|
|
75
|
+
jid: string;
|
|
76
|
+
}): Promise<void>;
|
|
108
77
|
}
|
|
109
78
|
|
|
110
79
|
declare function InitDisplay(config: ClientProps): void;
|
|
111
80
|
|
|
112
|
-
declare function MessageParser(ctx: WAMessage[], config: ClientProps, store: ReturnType<typeof makeInMemoryStore
|
|
81
|
+
declare function MessageParser(ctx: WAMessage[], config: ClientProps, store: ReturnType<typeof makeInMemoryStore>, state: AuthenticationState): Promise<MessageParserProps[] | undefined>;
|
|
113
82
|
|
|
114
83
|
declare function ConnectionConfig(props: ClientProps, state: AuthenticationState, store: ReturnType<typeof makeInMemoryStore>): UserFacingSocketConfig;
|
|
115
84
|
declare const MESSAGE_TYPE: {
|
|
@@ -189,4 +158,4 @@ declare function getValuesByKeys(object: any, keys: string[]): any[];
|
|
|
189
158
|
declare function removeKeys(object: any, keys: string[]): any;
|
|
190
159
|
declare function getMessageType(obj: any): string[];
|
|
191
160
|
|
|
192
|
-
export { type ActionsProps, Client, type ClientProps, ConnectionConfig, InitDisplay, MESSAGE_TYPE, MessageParser, type Prettify, delay, fetchJson, getMessageType, getValuesByKeys, jsonParse, jsonString, loop, postJson, removeKeys, timeout };
|
|
161
|
+
export { Actions, type ActionsProps, Client, type ClientProps, ConnectionConfig, InitDisplay, MESSAGE_TYPE, MessageParser, type Prettify, delay, fetchJson, getMessageType, getValuesByKeys, jsonParse, jsonString, loop, postJson, removeKeys, timeout };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Y=Object.create;var T=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty;var te=(s,t)=>{for(var o in t)T(s,o,{get:t[o],enumerable:!0})},W=(s,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of $(t))!ee.call(s,e)&&e!==o&&T(s,e,{get:()=>t[e],enumerable:!(n=Z(t,e))||n.enumerable});return s};var h=(s,t,o)=>(o=s!=null?Y(X(s)):{},W(t||!s||!s.__esModule?T(o,"default",{value:s,enumerable:!0}):o,s)),se=s=>W(T({},"__esModule",{value:!0}),s);var ce={};te(ce,{Client:()=>B,ConnectionConfig:()=>z,InitDisplay:()=>_,MESSAGE_TYPE:()=>O,MessageParser:()=>J,delay:()=>b,fetchJson:()=>ae,getMessageType:()=>l,getValuesByKeys:()=>i,jsonParse:()=>L,jsonString:()=>c,loop:()=>N,postJson:()=>ie,removeKeys:()=>k,timeout:()=>ne});module.exports=se(ce);var f=require("baileys"),A=h(require("chalk"));var I=require("baileys"),V=h(require("node-cache")),R=h(require("pino"));var E={author:"https://github.com/zaadevofc",repository:"https://github.com/zaadevofc/zaileys",package:"https://www.npmjs.com/package/zaileys",version:[2,2413,1],browser:["Mac OS","chrome","121.0.6167.159"]};function z(s,t,o){async function n(e){return o?(await o.loadMessage(e.remoteJid,e.id))?.message||void 0:I.proto.Message.fromObject({})}return{printQRInTerminal:!s.pairing,defaultQueryTimeoutMs:0,connectTimeoutMs:6e4,keepAliveIntervalMs:1e4,msgRetryCounterCache:new V.default,syncFullHistory:!0,mobile:!1,markOnlineOnConnect:!1,generateHighQualityLinkPreview:!0,browser:E.browser,version:E.version,logger:(0,R.default)({enabled:!1}),auth:{creds:t.creds,keys:(0,I.makeCacheableSignalKeyStore)(t.keys,(0,R.default)({enabled:!1}))},getMessage:n,patchMessageBeforeSending:e=>(!!(e.buttonsMessage||e.templateMessage||e.listMessage)&&(e={viewOnceMessage:{message:{messageContextInfo:{deviceListMetadataVersion:2,deviceListMetadata:{}},...e}}}),e)}}var O={text:"text",conversation:"text",imageMessage:"image",contactMessage:"contact",locationMessage:"location",extendedTextMessage:"text",documentMessage:"document",audioMessage:"audio",videoMessage:"video",protocolMessage:"protocol",contactsArrayMessage:"contactsArray",highlyStructuredMessage:"highlyStructured",sendPaymentMessage:"sendPayment",liveLocationMessage:"liveLocation",requestPaymentMessage:"requestPayment",declinePaymentRequestMessage:"declinePaymentRequest",cancelPaymentRequestMessage:"cancelPaymentRequest",templateMessage:"template",stickerMessage:"sticker",groupInviteMessage:"groupInvite",templateButtonReplyMessage:"templateButtonReply",productMessage:"product",deviceSentMessage:"deviceSent",listMessage:"list",viewOnceMessage:"viewOnce",orderMessage:"order",listResponseMessage:"listResponse",ephemeralMessage:"ephemeral",invoiceMessage:"invoice",buttonsMessage:"buttons",buttonsResponseMessage:"buttonsResponse",paymentInviteMessage:"paymentInvite",interactiveMessage:"interactive",reactionMessage:"reaction",stickerSyncRmrMessage:"sticker",interactiveResponseMessage:"interactiveResponse",pollCreationMessage:"pollCreation",pollUpdateMessage:"pollUpdate",keepInChatMessage:"keepInChat",documentWithCaptionMessage:"document",requestPhoneNumberMessage:"requestPhoneNumber",viewOnceMessageV2:"viewOnce",encReactionMessage:"reaction",editedMessage:"text",viewOnceMessageV2Extension:"viewOnce",pollCreationMessageV2:"pollCreation",scheduledCallCreationMessage:"scheduledCallCreation",groupMentionedMessage:"groupMentioned",pinInChatMessage:"pinInChat",pollCreationMessageV3:"pollCreation",scheduledCallEditMessage:"scheduledCallEdit",ptvMessage:"ptv",botInvokeMessage:"botInvoke",callLogMesssage:"callLog",encCommentMessage:"encComment",bcallMessage:"bcall",lottieStickerMessage:"lottieSticker",eventMessage:"event",commentMessage:"comment",newsletterAdminInviteMessage:"newsletterAdminInvite",extendedTextMessageWithParentKey:"text",placeholderMessage:"placeholder",encEventUpdateMessage:"encEventUpdate"};function N(s,t){return setInterval(s,t)}function c(s){return JSON.stringify(s??{},null,2)}function L(s){return JSON.parse(c(s))}function ne(s,t){return setTimeout(s,t)}async function b(s){return new Promise(t=>setTimeout(t,s))}var ae=async(s,t)=>await fetch(s).then(o=>o.json()),ie=async(s,t)=>await fetch(s,{body:JSON.stringify(t),method:"POST"}).then(o=>o.json());function i(s,t){let o=[],n=e=>{e!=null&&(Array.isArray(e)?e.forEach(n):typeof e=="object"&&Object.entries(e).forEach(([a,r])=>{t.includes(a)&&o.push(r),n(r)}))};return n(s),o}function k(s,t){let o=n=>{if(n===null||typeof n!="object")return n;if(Array.isArray(n))return n.map(o);let e={};for(let a in n)t.includes(a)||(e[a]=o(n[a]));return e};return o(L(s))}function l(s){if(s=L(s),typeof s!="object"||s===null)return[];for(let t of Object.keys(s))if(Object.keys(O).includes(t))return[O[t],t];for(let t of Object.values(s)){let o=l(t);if(o)return o}return[]}var q=h(require("cfonts")),G=h(require("ora"));var j=require("events"),U=h(require("quick-lru")),Pe=new U.default({maxSize:9999999999}),w=new j.EventEmitter;var D="https://ko-fi.com/zaadevofc";function _(s){console.clear(),q.default.say("Zaileys",{font:"block",colors:["white","green"],letterSpacing:1,lineHeight:1,space:!1,maxLength:"0"}),q.default.say(` Love this package? help me with donation: | ${D} |`,{font:"console",colors:["black"],background:"green",letterSpacing:1,space:!1,maxLength:"0"}),w.on("conn_msg",async t=>{let o=(0,G.default)();await o[t[0]](t[1]),await o.clear()}),s.showLogs&&w.on("act_msg",t=>{})}async function J(s,t,o){return s?await Promise.all(s.map(async(e,a)=>{if(l(e.message).length==0||l(e.message)[0]=="protocol"||c(e.message).includes("pollUpdateMessage"))return;let r=k(e.message,["contextInfo"]),p=i(e.message,["quotedMessage"])[0],g=e.key,y=i(e.message,["contextInfo"])[0],x=l(r)[1]=="editedMessage",F=x&&i(e.message,["protocolMessage"])[0].key,P=x&&k(await o.loadMessage(F.remoteJid,F.id),["contextInfo"]);P=k(P.message,["contextInfo"]);let K=/\b\d+@\S+\b/g.exec(i(g,["participant"])[0]||i(g,["remoteJid"])[0])?.[0],S=/\b\d+@\S+\b/g.exec(i(y,["participant"])[0])?.[0],d=l(x?P:r);d=d[0]=="viewOnce"?l(i(r,[d[1]])):d;let u=l(p);u=u[0]=="viewOnce"?l(i(p,[u[1]])):u;let Q=i(r,["conversation","text","caption","contentText","description"])[0],H=i(p,["conversation","text","caption","contentText","description"])[0],M=d[0]!="text"&&i(x?P:r,[d[1]=="documentWithCaptionMessage"?"documentMessage":d[1]])[0];M=d[0]=="viewOnce"?i(M,l(M))[0]:M;let v=u[0]!="text"&&i(p,[u[1]=="documentWithCaptionMessage"?"documentMessage":u[1]])[0];v=u[0]=="viewOnce"?i(v,l(v))[0]:v;let C=await o.messages[S].get(i(y,["stanzaId"])[0]);return console.log("\u{1F680} ~ letmessages:any=awaitPromise.all ~ replyJid:",S),console.log("\u{1F680} ~ letmessages:any=awaitPromise.all ~ replyStore:",C),{body:{fromMe:e.key.fromMe,chatId:e.key.id,participant:K,pushName:e.pushName,timestamp:e.messageTimestamp,type:d[0],text:Q,isStory:c(g).includes("status@broadcast")??!1,isGroup:c(g).includes("@g.us")??!1,isViewOnce:c(r).includes("viewOnce"),isForwarded:c(e.message).includes("isForwarded"),isEdited:c(r).includes("editedMessage"),isBroadcast:e.broadcast,isAuthor:t.authors.includes(Number(K?.split("@")[0])),media:M},reply:p&&{fromMe:C?.key?.fromMe,chatId:i(y,["stanzaId"])[0],participant:S,pushName:C?.pushName,timestamp:C?.messageTimestamp,type:u[0],text:H,isGroup:c(y).includes("@g.us")??!1,isViewOnce:c(y).includes("viewOnce"),isForwarded:c(e.message).includes("isForwarded"),isAuthor:t.authors.includes(Number(S?.split("@")[0])),media:v}}})):[]}var B=class{pairing;phoneNumber;showLogs;authors;ignoreMe;canNext=!1;socket=w;sock={};constructor({pairing:t,phoneNumber:o,showLogs:n,authors:e,ignoreMe:a}){this.pairing=t??!0,this.phoneNumber=o,this.showLogs=n??!0,this.ignoreMe=a??!1,this.authors=e??[],this.init()}async init(){let t=(0,f.makeInMemoryStore)({}),{state:o,saveCreds:n}=await(0,f.useMultiFileAuthState)("session/zaileys");t.readFromFile("session/data.json"),N(async()=>{try{t.writeToFile("session/data.json")}catch{await this.socket.emit("conn_msg",["fail",A.default.yellow("[DETECTED] session folder has been deleted by the user")]),await b(2e3),await this.socket.emit("conn_msg",["fail",A.default.yellow("Please rerun the program...")]),await process.exit()}},1e4);let e=(0,f.makeWASocket)(z(this,o,t));t.bind(e.ev),e.ev.on("creds.update",n),e.ev.on("connection.update",async a=>{let r=_(this),{connection:p,lastDisconnect:g}=a;if(p=="connecting"&&console.log("menghubungkan...."),this.pairing&&this.phoneNumber&&!o.creds.me&&!e.authState.creds.registered){this.socket.emit("conn_msg",["start","Initialization new session..."]),await b(2e3),this.socket.emit("conn_msg",["start","Creating new pairing code..."]),await b(6e3);let y=await e.requestPairingCode(this.phoneNumber.toString());this.socket.emit("conn_msg",["info",`Connect with pairing code : ${A.default.green(y)}`])}p==="close"?g?.error?.output?.statusCode!==f.DisconnectReason.loggedOut&&(console.log("reconecting..."),this.init()):p==="open"&&console.log("koneekk")}),e.ev.process(async a=>{if(a["messages.upsert"]){let r=a["messages.upsert"];console.log(c({msg:r}));let p=await J(r.messages,this,t);if(p.filter(g=>g).length==0)return;await this.socket.emit("messages.upsert",p)}})}async on(t,o){let n=(e,a)=>this.socket.on(e,a);switch(t){case"connection":break;case"message":n("messages.upsert",e=>{e&&o(e)});break}}};0&&(module.exports={Client,ConnectionConfig,InitDisplay,MESSAGE_TYPE,MessageParser,delay,fetchJson,getMessageType,getValuesByKeys,jsonParse,jsonString,loop,postJson,removeKeys,timeout});
|
|
1
|
+
"use strict";var Z=Object.create;var O=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var ee=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty;var se=(t,e)=>{for(var s in e)O(t,s,{get:e[s],enumerable:!0})},V=(t,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of X(e))!te.call(t,n)&&n!==s&&O(t,n,{get:()=>e[n],enumerable:!(i=$(e,n))||i.enumerable});return t};var v=(t,e,s)=>(s=t!=null?Z(ee(t)):{},V(e||!t||!t.__esModule?O(s,"default",{value:t,enumerable:!0}):s,t)),ne=t=>V(O({},"__esModule",{value:!0}),t);var pe={};se(pe,{Actions:()=>x,Client:()=>W,ConnectionConfig:()=>z,InitDisplay:()=>q,MESSAGE_TYPE:()=>I,MessageParser:()=>J,delay:()=>w,fetchJson:()=>ae,getMessageType:()=>r,getValuesByKeys:()=>a,jsonParse:()=>N,jsonString:()=>u,loop:()=>E,postJson:()=>re,removeKeys:()=>P,timeout:()=>ie});module.exports=ne(pe);var x=class{constructor({pairing:e,markOnline:s,phoneNumber:i,showLogs:n,authors:o,ignoreMe:m}){}sendText(){return"system"}sendReply(){}};var M=require("baileys"),Q=v(require("ora"));var T=require("baileys"),_=v(require("node-cache")),R=v(require("pino"));var A={author:"https://github.com/zaadevofc",repository:"https://github.com/zaadevofc/zaileys",package:"https://www.npmjs.com/package/zaileys",homepage:"https://zaadevofc.github.io/zaileys/",version:[2,2413,1],browser:["Mac OS","chrome","121.0.6167.159"]};function z(t,e,s){async function i(n){return s?(await s.loadMessage(n.remoteJid,n.id))?.message||void 0:T.proto.Message.fromObject({})}return{printQRInTerminal:!t.pairing,markOnlineOnConnect:!t.markOnline,defaultQueryTimeoutMs:0,connectTimeoutMs:6e4,keepAliveIntervalMs:1e4,msgRetryCounterCache:new _.default,syncFullHistory:!0,mobile:!1,generateHighQualityLinkPreview:!0,browser:A.browser,version:A.version,logger:(0,R.default)({enabled:!1}),auth:{creds:e.creds,keys:(0,T.makeCacheableSignalKeyStore)(e.keys,(0,R.default)({enabled:!1}))},getMessage:i,patchMessageBeforeSending:n=>(!!(n.buttonsMessage||n.templateMessage||n.listMessage)&&(n={viewOnceMessage:{message:{messageContextInfo:{deviceListMetadataVersion:2,deviceListMetadata:{}},...n}}}),n)}}var I={text:"text",conversation:"text",imageMessage:"image",contactMessage:"contact",locationMessage:"location",extendedTextMessage:"text",documentMessage:"document",audioMessage:"audio",videoMessage:"video",protocolMessage:"protocol",contactsArrayMessage:"contactsArray",highlyStructuredMessage:"highlyStructured",sendPaymentMessage:"sendPayment",liveLocationMessage:"liveLocation",requestPaymentMessage:"requestPayment",declinePaymentRequestMessage:"declinePaymentRequest",cancelPaymentRequestMessage:"cancelPaymentRequest",templateMessage:"template",stickerMessage:"sticker",groupInviteMessage:"groupInvite",templateButtonReplyMessage:"templateButtonReply",productMessage:"product",deviceSentMessage:"deviceSent",listMessage:"list",viewOnceMessage:"viewOnce",orderMessage:"order",listResponseMessage:"listResponse",ephemeralMessage:"ephemeral",invoiceMessage:"invoice",buttonsMessage:"buttons",buttonsResponseMessage:"buttonsResponse",paymentInviteMessage:"paymentInvite",interactiveMessage:"interactive",reactionMessage:"reaction",stickerSyncRmrMessage:"sticker",interactiveResponseMessage:"interactiveResponse",pollCreationMessage:"pollCreation",pollUpdateMessage:"pollUpdate",keepInChatMessage:"keepInChat",documentWithCaptionMessage:"document",requestPhoneNumberMessage:"requestPhoneNumber",viewOnceMessageV2:"viewOnce",encReactionMessage:"reaction",editedMessage:"text",viewOnceMessageV2Extension:"viewOnce",pollCreationMessageV2:"pollCreation",scheduledCallCreationMessage:"scheduledCallCreation",groupMentionedMessage:"groupMentioned",pinInChatMessage:"pinInChat",pollCreationMessageV3:"pollCreation",scheduledCallEditMessage:"scheduledCallEdit",ptvMessage:"ptv",botInvokeMessage:"botInvoke",callLogMesssage:"callLog",encCommentMessage:"encComment",bcallMessage:"bcall",lottieStickerMessage:"lottieSticker",eventMessage:"event",commentMessage:"comment",newsletterAdminInviteMessage:"text",extendedTextMessageWithParentKey:"text",placeholderMessage:"placeholder",encEventUpdateMessage:"encEventUpdate"};function E(t,e){return setInterval(t,e)}function u(t){return JSON.stringify(t??{},null,2)}function N(t){return JSON.parse(u(t))}function ie(t,e){return setTimeout(t,e)}async function w(t){return new Promise(e=>setTimeout(e,t))}var ae=async(t,e)=>await fetch(t).then(s=>s.json()),re=async(t,e)=>await fetch(t,{body:JSON.stringify(e),method:"POST"}).then(s=>s.json());function a(t,e){let s=[],i=n=>{n!=null&&(Array.isArray(n)?n.forEach(i):typeof n=="object"&&Object.entries(n).forEach(([o,m])=>{e.includes(o)&&s.push(m),i(m)}))};return i(t),s}function P(t,e){let s=i=>{if(i===null||typeof i!="object")return i;if(Array.isArray(i))return i.map(s);let n={};for(let o in i)e.includes(o)||(n[o]=s(i[o]));return n};return s(N(t))}function r(t){if(t=N(t),typeof t!="object"||t===null)return[];for(let e of Object.keys(t))if(Object.keys(I).includes(e))return[I[e],e];for(let e of Object.values(t)){let s=r(e);if(s)return s}return[]}var L=v(require("cfonts")),G=v(require("ora"));var j=require("events"),U=v(require("quick-lru")),Oe=new U.default({maxSize:9999999999}),C=new j.EventEmitter;var D="https://trakteer.id/zaadevofc";function q(t){console.clear(),L.default.say("Zaileys",{font:"block",colors:["white","green"],letterSpacing:1,lineHeight:1,space:!1,maxLength:"0"}),L.default.say(` Love this package? help me with donation: | ${D} |`,{font:"console",colors:["black"],background:"green",letterSpacing:1,space:!1,maxLength:"0"});let e=(0,G.default)();C.on("conn_msg",async s=>{await e[s[0]](s[1])}),t.showLogs&&C.on("act_msg",s=>{})}async function J(t,e,s,i){return t?await Promise.all(t.map(async(o,m)=>{if(r(o.message).length==0||r(o.message)[0]=="protocol"||u(o.message).includes("pollUpdateMessage"))return;let c=P(o.message,["contextInfo"]),d=a(o.message,["quotedMessage"])[0],g=o.key,b=a(o.message,["contextInfo"])[0],k=r(c)[1]=="editedMessage",B=k&&a(o.message,["protocolMessage"])[0].key,S=k&&P(await s.loadMessage(B.remoteJid,B.id),["contextInfo"]);S=P(S.message,["contextInfo"]);let F=a(g,["participant"])[0]||a(g,["remoteJid"])[0],K=a(b,["participant"])[0],p=r(k?S:c);p=p[0]=="ephemeral"?r(a(c,[p[1]])):p,p=p[0]=="viewOnce"?r(a(c,[p[1]])):p;let l=r(d);l=l[0]=="ephemeral"?r(a(d,[l[1]])):l,l=l[0]=="viewOnce"?r(a(d,[l[1]])):l;let H=a(c,["conversation","text","caption","contentText","description"])[0],Y=a(d,["conversation","text","caption","contentText","description"])[0],h=!["text","reaction"].includes(p[0])&&a(k?S:c,[p[1]=="documentWithCaptionMessage"?"documentMessage":p[1]])[0];h=p[0]=="ephemeral"?a(h,r(h))[0]:h,h=p[0]=="viewOnce"?a(h,r(h))[0]:h;let f=!["text","reaction"].includes(l[0])&&a(d,[l[1]=="documentWithCaptionMessage"?"documentMessage":l[1]])[0];return f=l[0]=="ephemeral"?a(f,r(f))[0]:f,f=l[0]=="viewOnce"?a(f,r(f))[0]:f,{body:{fromMe:o.key.fromMe,chatId:o.key.id,remoteJid:a(g,["remoteJid"])[0],participant:o.key.fromMe?i.creds.me?.id.replace(":74",""):F,pushName:o.key.fromMe?i.creds.me?.verifiedName||i.creds.me?.name:o.pushName,timestamp:o.messageTimestamp*1e3,type:p[0],text:H,isStory:u(g).includes("status@broadcast"),isGroup:u(g).includes("@g.us"),isViewOnce:u(c).includes("viewOnce"),isForwarded:u(o.message).includes("isForwarded"),isEdited:u(c).includes("editedMessage"),isBroadcast:o.broadcast,isAuthor:e.authors.includes(Number(F?.split("@")[0])),isEphemeral:a(o.message,["expiration"])[0]>0,media:h},reply:d?{chatId:a(b,["stanzaId"])[0],participant:K,type:l[0],text:Y,isGroup:u(b).includes("@g.us"),isViewOnce:u(b).includes("viewOnce"),isForwarded:u(o.message).includes("isForwarded"),isAuthor:e.authors.includes(Number(K?.split("@")[0])),media:f}:!1}})):[]}var W=class extends x{pairing;markOnline;phoneNumber;showLogs;authors;ignoreMe;socket=C;socked={};spinners=(0,Q.default)();initialized=!1;initPromise=null;constructor({pairing:e,markOnline:s,phoneNumber:i,showLogs:n,authors:o,ignoreMe:m}){super({pairing:e,markOnline:s,phoneNumber:i,showLogs:n,authors:o,ignoreMe:m}),this.pairing=e??!0,this.markOnline=e??!0,this.phoneNumber=i,this.showLogs=n??!0,this.ignoreMe=m??!1,this.authors=o??[]}async init(){return this.initialized?this.initPromise:(this.initialized=!0,this.initPromise=(async()=>{q(this),this.spinners.start("Connecting to server...");let e=(0,M.makeInMemoryStore)({}),{state:s,saveCreds:i}=await(0,M.useMultiFileAuthState)("session/zaileys");E(async()=>{try{e.readFromFile("session/data.json"),e.writeToFile("session/data.json")}catch{await this.spinners.fail("Warning: Cannot detect session file"),await w(2e3),await this.spinners.info("Please rerun the program..."),await process.exit()}},1e4);let n=(0,M.makeWASocket)(z(this,s,e));if(e.bind(n.ev),n.ev.on("creds.update",i),this.pairing&&this.phoneNumber&&!n.authState.creds.registered){this.spinners.text="Initialization new session...",await w(2e3),this.spinners.text="Creating new pairing code...",await w(6e3);try{let o=await n.requestPairingCode(this.phoneNumber.toString());this.spinners.info(`Connect with pairing code : ${o}`)}catch{this.spinners.fail("Connection close. Please delete session and run again..."),process.exit(0)}}return n.ev.on("connection.update",async o=>{let{connection:m,lastDisconnect:c,qr:d,isNewLogin:g}=o;m=="connecting"&&this.spinners.start("Connecting to server..."),!this.pairing&&d&&this.spinners.info("Scan this QR Code with your WhatsApp"),m==="close"?c?.error?.output?.statusCode!==M.DisconnectReason.loggedOut?(this.spinners.info("Reconnecting to server..."),await this.init()):(this.spinners.fail("Detected logout. Please delete session and run again"),process.exit(0)):m==="open"&&(this.spinners.succeed("Successfully connected to server"),console.log())}),{sock:n,store:e,state:s}})(),this.initPromise)}async on(e,s){let{sock:i,store:n,state:o}=await this.init();this.socked={sock:i,store:n,state:o};let m=(c,d)=>this.socket.on(c,d);switch(e){case"connection":break;case"message":i.ev.on("messages.upsert",async c=>{let d=await J(c.messages,this,n,o);d.filter(g=>g).length!=0&&d.forEach(g=>{s(g)})});break}}async sendMsg(e,{jid:s}){await this.socked.sock?.sendMessage(s,{text:e})}};0&&(module.exports={Actions,Client,ConnectionConfig,InitDisplay,MESSAGE_TYPE,MessageParser,delay,fetchJson,getMessageType,getValuesByKeys,jsonParse,jsonString,loop,postJson,removeKeys,timeout});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DisconnectReason as Y,makeInMemoryStore as Z,makeWASocket as $,useMultiFileAuthState as X}from"baileys";import
|
|
1
|
+
var w=class{constructor({pairing:e,markOnline:o,phoneNumber:i,showLogs:n,authors:t,ignoreMe:m}){}sendText(){return"system"}sendReply(){}};import{DisconnectReason as Y,makeInMemoryStore as Z,makeWASocket as $,useMultiFileAuthState as X}from"baileys";import ee from"ora";import{makeCacheableSignalKeyStore as _,proto as j}from"baileys";import U from"node-cache";import R from"pino";var S={author:"https://github.com/zaadevofc",repository:"https://github.com/zaadevofc/zaileys",package:"https://www.npmjs.com/package/zaileys",homepage:"https://zaadevofc.github.io/zaileys/",version:[2,2413,1],browser:["Mac OS","chrome","121.0.6167.159"]};function z(s,e,o){async function i(n){return o?(await o.loadMessage(n.remoteJid,n.id))?.message||void 0:j.Message.fromObject({})}return{printQRInTerminal:!s.pairing,markOnlineOnConnect:!s.markOnline,defaultQueryTimeoutMs:0,connectTimeoutMs:6e4,keepAliveIntervalMs:1e4,msgRetryCounterCache:new U,syncFullHistory:!0,mobile:!1,generateHighQualityLinkPreview:!0,browser:S.browser,version:S.version,logger:R({enabled:!1}),auth:{creds:e.creds,keys:_(e.keys,R({enabled:!1}))},getMessage:i,patchMessageBeforeSending:n=>(!!(n.buttonsMessage||n.templateMessage||n.listMessage)&&(n={viewOnceMessage:{message:{messageContextInfo:{deviceListMetadataVersion:2,deviceListMetadata:{}},...n}}}),n)}}var O={text:"text",conversation:"text",imageMessage:"image",contactMessage:"contact",locationMessage:"location",extendedTextMessage:"text",documentMessage:"document",audioMessage:"audio",videoMessage:"video",protocolMessage:"protocol",contactsArrayMessage:"contactsArray",highlyStructuredMessage:"highlyStructured",sendPaymentMessage:"sendPayment",liveLocationMessage:"liveLocation",requestPaymentMessage:"requestPayment",declinePaymentRequestMessage:"declinePaymentRequest",cancelPaymentRequestMessage:"cancelPaymentRequest",templateMessage:"template",stickerMessage:"sticker",groupInviteMessage:"groupInvite",templateButtonReplyMessage:"templateButtonReply",productMessage:"product",deviceSentMessage:"deviceSent",listMessage:"list",viewOnceMessage:"viewOnce",orderMessage:"order",listResponseMessage:"listResponse",ephemeralMessage:"ephemeral",invoiceMessage:"invoice",buttonsMessage:"buttons",buttonsResponseMessage:"buttonsResponse",paymentInviteMessage:"paymentInvite",interactiveMessage:"interactive",reactionMessage:"reaction",stickerSyncRmrMessage:"sticker",interactiveResponseMessage:"interactiveResponse",pollCreationMessage:"pollCreation",pollUpdateMessage:"pollUpdate",keepInChatMessage:"keepInChat",documentWithCaptionMessage:"document",requestPhoneNumberMessage:"requestPhoneNumber",viewOnceMessageV2:"viewOnce",encReactionMessage:"reaction",editedMessage:"text",viewOnceMessageV2Extension:"viewOnce",pollCreationMessageV2:"pollCreation",scheduledCallCreationMessage:"scheduledCallCreation",groupMentionedMessage:"groupMentioned",pinInChatMessage:"pinInChat",pollCreationMessageV3:"pollCreation",scheduledCallEditMessage:"scheduledCallEdit",ptvMessage:"ptv",botInvokeMessage:"botInvoke",callLogMesssage:"callLog",encCommentMessage:"encComment",bcallMessage:"bcall",lottieStickerMessage:"lottieSticker",eventMessage:"event",commentMessage:"comment",newsletterAdminInviteMessage:"text",extendedTextMessageWithParentKey:"text",placeholderMessage:"placeholder",encEventUpdateMessage:"encEventUpdate"};function E(s,e){return setInterval(s,e)}function g(s){return JSON.stringify(s??{},null,2)}function N(s){return JSON.parse(g(s))}function ye(s,e){return setTimeout(s,e)}async function P(s){return new Promise(e=>setTimeout(e,s))}var ge=async(s,e)=>await fetch(s).then(o=>o.json()),he=async(s,e)=>await fetch(s,{body:JSON.stringify(e),method:"POST"}).then(o=>o.json());function a(s,e){let o=[],i=n=>{n!=null&&(Array.isArray(n)?n.forEach(i):typeof n=="object"&&Object.entries(n).forEach(([t,m])=>{e.includes(t)&&o.push(m),i(m)}))};return i(s),o}function C(s,e){let o=i=>{if(i===null||typeof i!="object")return i;if(Array.isArray(i))return i.map(o);let n={};for(let t in i)e.includes(t)||(n[t]=o(i[t]));return n};return o(N(s))}function r(s){if(s=N(s),typeof s!="object"||s===null)return[];for(let e of Object.keys(s))if(Object.keys(O).includes(e))return[O[e],e];for(let e of Object.values(s)){let o=r(e);if(o)return o}return[]}import q from"cfonts";import H from"ora";import{EventEmitter as D}from"events";import G from"quick-lru";var Ce=new G({maxSize:9999999999}),k=new D;var L="https://trakteer.id/zaadevofc";function J(s){console.clear(),q.say("Zaileys",{font:"block",colors:["white","green"],letterSpacing:1,lineHeight:1,space:!1,maxLength:"0"}),q.say(` Love this package? help me with donation: | ${L} |`,{font:"console",colors:["black"],background:"green",letterSpacing:1,space:!1,maxLength:"0"});let e=H();k.on("conn_msg",async o=>{await e[o[0]](o[1])}),s.showLogs&&k.on("act_msg",o=>{})}async function W(s,e,o,i){return s?await Promise.all(s.map(async(t,m)=>{if(r(t.message).length==0||r(t.message)[0]=="protocol"||g(t.message).includes("pollUpdateMessage"))return;let c=C(t.message,["contextInfo"]),d=a(t.message,["quotedMessage"])[0],h=t.key,v=a(t.message,["contextInfo"])[0],b=r(c)[1]=="editedMessage",T=b&&a(t.message,["protocolMessage"])[0].key,x=b&&C(await o.loadMessage(T.remoteJid,T.id),["contextInfo"]);x=C(x.message,["contextInfo"]);let I=a(h,["participant"])[0]||a(h,["remoteJid"])[0],A=a(v,["participant"])[0],p=r(b?x:c);p=p[0]=="ephemeral"?r(a(c,[p[1]])):p,p=p[0]=="viewOnce"?r(a(c,[p[1]])):p;let l=r(d);l=l[0]=="ephemeral"?r(a(d,[l[1]])):l,l=l[0]=="viewOnce"?r(a(d,[l[1]])):l;let F=a(c,["conversation","text","caption","contentText","description"])[0],K=a(d,["conversation","text","caption","contentText","description"])[0],f=!["text","reaction"].includes(p[0])&&a(b?x:c,[p[1]=="documentWithCaptionMessage"?"documentMessage":p[1]])[0];f=p[0]=="ephemeral"?a(f,r(f))[0]:f,f=p[0]=="viewOnce"?a(f,r(f))[0]:f;let M=!["text","reaction"].includes(l[0])&&a(d,[l[1]=="documentWithCaptionMessage"?"documentMessage":l[1]])[0];return M=l[0]=="ephemeral"?a(M,r(M))[0]:M,M=l[0]=="viewOnce"?a(M,r(M))[0]:M,{body:{fromMe:t.key.fromMe,chatId:t.key.id,remoteJid:a(h,["remoteJid"])[0],participant:t.key.fromMe?i.creds.me?.id.replace(":74",""):I,pushName:t.key.fromMe?i.creds.me?.verifiedName||i.creds.me?.name:t.pushName,timestamp:t.messageTimestamp*1e3,type:p[0],text:F,isStory:g(h).includes("status@broadcast"),isGroup:g(h).includes("@g.us"),isViewOnce:g(c).includes("viewOnce"),isForwarded:g(t.message).includes("isForwarded"),isEdited:g(c).includes("editedMessage"),isBroadcast:t.broadcast,isAuthor:e.authors.includes(Number(I?.split("@")[0])),isEphemeral:a(t.message,["expiration"])[0]>0,media:f},reply:d?{chatId:a(v,["stanzaId"])[0],participant:A,type:l[0],text:K,isGroup:g(v).includes("@g.us"),isViewOnce:g(v).includes("viewOnce"),isForwarded:g(t.message).includes("isForwarded"),isAuthor:e.authors.includes(Number(A?.split("@")[0])),media:M}:!1}})):[]}var B=class extends w{pairing;markOnline;phoneNumber;showLogs;authors;ignoreMe;socket=k;socked={};spinners=ee();initialized=!1;initPromise=null;constructor({pairing:e,markOnline:o,phoneNumber:i,showLogs:n,authors:t,ignoreMe:m}){super({pairing:e,markOnline:o,phoneNumber:i,showLogs:n,authors:t,ignoreMe:m}),this.pairing=e??!0,this.markOnline=e??!0,this.phoneNumber=i,this.showLogs=n??!0,this.ignoreMe=m??!1,this.authors=t??[]}async init(){return this.initialized?this.initPromise:(this.initialized=!0,this.initPromise=(async()=>{J(this),this.spinners.start("Connecting to server...");let e=Z({}),{state:o,saveCreds:i}=await X("session/zaileys");E(async()=>{try{e.readFromFile("session/data.json"),e.writeToFile("session/data.json")}catch{await this.spinners.fail("Warning: Cannot detect session file"),await P(2e3),await this.spinners.info("Please rerun the program..."),await process.exit()}},1e4);let n=$(z(this,o,e));if(e.bind(n.ev),n.ev.on("creds.update",i),this.pairing&&this.phoneNumber&&!n.authState.creds.registered){this.spinners.text="Initialization new session...",await P(2e3),this.spinners.text="Creating new pairing code...",await P(6e3);try{let t=await n.requestPairingCode(this.phoneNumber.toString());this.spinners.info(`Connect with pairing code : ${t}`)}catch{this.spinners.fail("Connection close. Please delete session and run again..."),process.exit(0)}}return n.ev.on("connection.update",async t=>{let{connection:m,lastDisconnect:c,qr:d,isNewLogin:h}=t;m=="connecting"&&this.spinners.start("Connecting to server..."),!this.pairing&&d&&this.spinners.info("Scan this QR Code with your WhatsApp"),m==="close"?c?.error?.output?.statusCode!==Y.loggedOut?(this.spinners.info("Reconnecting to server..."),await this.init()):(this.spinners.fail("Detected logout. Please delete session and run again"),process.exit(0)):m==="open"&&(this.spinners.succeed("Successfully connected to server"),console.log())}),{sock:n,store:e,state:o}})(),this.initPromise)}async on(e,o){let{sock:i,store:n,state:t}=await this.init();this.socked={sock:i,store:n,state:t};let m=(c,d)=>this.socket.on(c,d);switch(e){case"connection":break;case"message":i.ev.on("messages.upsert",async c=>{let d=await W(c.messages,this,n,t);d.filter(h=>h).length!=0&&d.forEach(h=>{o(h)})});break}}async sendMsg(e,{jid:o}){await this.socked.sock?.sendMessage(o,{text:e})}};export{w as Actions,B as Client,z as ConnectionConfig,J as InitDisplay,O as MESSAGE_TYPE,W as MessageParser,P as delay,ge as fetchJson,r as getMessageType,a as getValuesByKeys,N as jsonParse,g as jsonString,E as loop,he as postJson,C as removeKeys,ye as timeout};
|
package/package.json
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
"email": "zaadevofc@gmail.com",
|
|
7
7
|
"url": "https://github.com/zaadevofc"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.28.1-dev",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"main": "dist/index.js",
|
|
12
12
|
"module": "dist/index.mjs",
|
|
13
13
|
"types": "dist/index.d.ts",
|
|
14
14
|
"homepage": "https://zaadevofc.github.io/zaileys/",
|
|
15
|
-
"funding": "https://
|
|
15
|
+
"funding": "https://trakteer.id/zaadevofc",
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/zaadevofc/zaileys/issues"
|
|
18
18
|
},
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"@types/hapi__boom": "^9.0.1",
|
|
61
61
|
"@types/node": "^20.13.0",
|
|
62
62
|
"@types/ws": "^8.5.10",
|
|
63
|
+
"pino-pretty": "^11.1.0",
|
|
63
64
|
"tsup": "^8.0.2",
|
|
64
65
|
"typedoc": "^0.25.13",
|
|
65
66
|
"typescript": "^5.4.5"
|