talkyzap-wapp-api 1.0.17 → 1.0.19
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/CHANGELOG.md +1 -1
- package/README.md +78 -26
- package/dist/call/events/eventTypes.d.ts +2 -3
- package/dist/call/events/registerIncomingCallEvent.d.ts +1 -1
- package/dist/chat/functions/forwardMessage.d.ts +4 -4
- package/dist/chat/functions/forwardMessages.d.ts +33 -0
- package/dist/chat/functions/getMessages.d.ts +7 -0
- package/dist/chat/functions/index.d.ts +2 -1
- package/dist/chat/functions/list.d.ts +4 -0
- package/dist/chat/functions/openChatAt.d.ts +3 -1
- package/dist/chat/functions/openChatBottom.d.ts +3 -1
- package/dist/chat/functions/openChatFromUnread.d.ts +3 -1
- package/dist/chat/functions/pinMsg.d.ts +19 -5
- package/dist/chat/functions/sendFileMessage.d.ts +13 -0
- package/dist/chat/functions/sendTextMessage.d.ts +2 -3
- package/dist/chat/index.d.ts +1 -0
- package/dist/chat/types.d.ts +11 -3
- package/dist/chat/util/index.d.ts +16 -0
- package/dist/chat/util/rehydrateMessage.d.ts +17 -0
- package/dist/conn/functions/changeEnviromentDevice.d.ts +19 -0
- package/dist/conn/functions/getBuildConstants.d.ts +37 -0
- package/dist/conn/functions/getMigrationState.d.ts +52 -0
- package/dist/conn/functions/index.d.ts +3 -0
- package/dist/contact/functions/get.d.ts +2 -0
- package/dist/contact/functions/getPnLidEntry.d.ts +59 -0
- package/dist/contact/functions/index.d.ts +1 -0
- package/dist/contact/functions/save.d.ts +3 -3
- package/dist/gtag/Tracker.d.ts +1 -1
- package/dist/order/functions/accept.d.ts +58 -0
- package/dist/order/functions/decline.d.ts +53 -0
- package/dist/order/functions/index.d.ts +3 -0
- package/dist/order/functions/update.d.ts +77 -0
- package/dist/order/index.d.ts +1 -0
- package/dist/order/types.d.ts +119 -0
- package/dist/util/fileHelpers.d.ts +29 -0
- package/dist/util/index.d.ts +1 -0
- package/dist/util/isUrl.d.ts +21 -0
- package/dist/whatsapp/collections/CallCollection.d.ts +16 -6
- package/dist/whatsapp/enums/ACK.d.ts +5 -3
- package/dist/whatsapp/enums/PinExpiryDurationOption.d.ts +25 -0
- package/dist/whatsapp/enums/index.d.ts +1 -0
- package/dist/whatsapp/functions/addAndSendMessageEdit.d.ts +2 -2
- package/dist/whatsapp/functions/addAndSendMsgToChat.d.ts +2 -2
- package/dist/whatsapp/functions/canSaveAsMyContacts.d.ts +7 -1
- package/dist/whatsapp/functions/createChat.d.ts +2 -0
- package/dist/whatsapp/functions/forwardMessages.d.ts +24 -0
- package/dist/whatsapp/functions/getPhoneLangPref.d.ts +25 -0
- package/dist/whatsapp/functions/getUploadLimit.d.ts +24 -0
- package/dist/whatsapp/functions/index.d.ts +4 -0
- package/dist/whatsapp/functions/isLidMigrated.d.ts +1 -1
- package/dist/whatsapp/functions/msgFindQuery.d.ts +4 -2
- package/dist/whatsapp/functions/queryOrder.d.ts +8 -7
- package/dist/whatsapp/functions/saveContactAction.d.ts +3 -1
- package/dist/whatsapp/functions/sendOrderStatusMessageAsMerchant.d.ts +47 -0
- package/dist/whatsapp/functions/sendPinInChatMsg.d.ts +4 -8
- package/dist/whatsapp/functions/updateMessageTable.d.ts +18 -0
- package/dist/whatsapp/index.d.ts +1 -0
- package/dist/whatsapp/misc/Cmd.d.ts +13 -0
- package/dist/whatsapp/misc/Enviroment.d.ts +22 -0
- package/dist/whatsapp/misc/LidPnCache.d.ts +39 -0
- package/dist/whatsapp/misc/MediaGatingUtils.d.ts +29 -0
- package/dist/whatsapp/misc/MediaPrep.d.ts +3 -2
- package/dist/whatsapp/misc/UserPrefs.d.ts +26 -7
- package/dist/whatsapp/misc/Wid.d.ts +8 -0
- package/dist/whatsapp/misc/WidFactory.d.ts +1 -0
- package/dist/whatsapp/misc/index.d.ts +3 -0
- package/dist/whatsapp/models/ChatModel.d.ts +1 -1
- package/dist/whatsapp/models/MsgModel.d.ts +17 -1
- package/dist/whatsapp/types.d.ts +21 -0
- package/dist/wppconnect-wa.js +1 -1
- package/dist/wppconnect-wa.js.LICENSE.txt +1 -1
- package/eslint.config.mjs +108 -0
- package/package.json +21 -23
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -10,10 +10,11 @@
|
|
|
10
10
|
[](https://github.com/wppconnect-team/wa-js/actions/workflows/lint.yml)
|
|
11
11
|
[](https://github.com/release-it/release-it)
|
|
12
12
|
|
|
13
|
-
> WPPConnect/WA-JS is an open-source project with the aim of exporting functions from WhatsApp Web, which can be used to support the creation of any interaction, such as customer service, media sending, intelligence recognition based on phrases
|
|
13
|
+
> WPPConnect/WA-JS is an open-source project with the aim of exporting functions from WhatsApp Web, which can be used to support the creation of any interaction, such as customer service, media sending, intelligence recognition based on phrases and many other things, use your imagination...
|
|
14
14
|
|
|
15
15
|
## Our online channels
|
|
16
16
|
|
|
17
|
+
[](https://github.com/wppconnect-team/wa-js/discussions)
|
|
17
18
|
[](https://discord.gg/JU5JGGKGNG)
|
|
18
19
|
[](https://www.youtube.com/c/wppconnect)
|
|
19
20
|
[](https://chat.whatsapp.com/LJaQu6ZyNvnBPNAVRbX00K)
|
|
@@ -28,20 +29,20 @@
|
|
|
28
29
|
|
|
29
30
|
## How does it work
|
|
30
31
|
|
|
31
|
-
This project
|
|
32
|
+
This project extracts some functions of WhatsApp sources.
|
|
32
33
|
|
|
33
|
-
After build, this project
|
|
34
|
+
After build, this project generates a file `dist/wppconnect-wa.js` to be used for injection in WhatsApp Web. When injected, it will expose a global variable named `WPP`.
|
|
34
35
|
|
|
35
36
|
Some parts of `WPP` variable:
|
|
36
37
|
|
|
37
|
-
- `WPP.webpack` - Scripts to
|
|
38
|
+
- `WPP.webpack` - Scripts to export WhatsApp functions.
|
|
38
39
|
- `WPP.whatsapp` - Only exported WhatsApp functions.
|
|
39
40
|
- `WPP.chat` - Chat functions and events.
|
|
40
41
|
- ...
|
|
41
42
|
|
|
42
43
|
## Exported WhatsApp modules
|
|
43
44
|
|
|
44
|
-
There are
|
|
45
|
+
There are convention names for some exported modules:
|
|
45
46
|
|
|
46
47
|
- `...Model` - Class for data structure (`ClassModel`, `MsgModel`)
|
|
47
48
|
- `...Collection` - Class for collection of models (`ChatCollection`, `MsgCollection`)
|
|
@@ -55,43 +56,80 @@ There are a convection name for some exported modules:
|
|
|
55
56
|
|
|
56
57
|
`WPP.conn.logout` - Logout from WhatsApp Web
|
|
57
58
|
|
|
58
|
-
|
|
59
|
-
`WPP.chat.sendTextMessage` - Send a text message
|
|
59
|
+
`WPP.conn.getBuildConstants` - Current WhatsApp build constants
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
For the most up-to-date list of available functions, launch the project locally and run this in your browser console:
|
|
62
62
|
|
|
63
|
-
`WPP.
|
|
63
|
+
`Object.keys(WPP.conn).sort()`
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
### Chat Functions
|
|
66
|
+
`WPP.chat.sendTextMessage` - Send a text message
|
|
66
67
|
|
|
67
|
-
`WPP.chat.
|
|
68
|
+
`WPP.chat.sendFileMessage` - Send a file message (medias in general [video, audio, image, pdf])
|
|
68
69
|
|
|
69
|
-
`WPP.chat.
|
|
70
|
+
`WPP.chat.get` - Get chat details
|
|
70
71
|
|
|
71
72
|
`WPP.chat.deleteMessage` - Delete a message
|
|
72
73
|
|
|
73
|
-
|
|
74
|
-
`WPP.contact.getContact` - Get contact details
|
|
74
|
+
For the most up-to-date list of available functions, launch the project locally and run this in your browser console:
|
|
75
75
|
|
|
76
|
-
`WPP.
|
|
76
|
+
`Object.keys(WPP.chat).sort()`
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
### Contact Functions
|
|
79
|
+
`WPP.contact.get` - Get contact details
|
|
79
80
|
|
|
80
81
|
`WPP.contact.getAllContacts` - Get all contacts
|
|
81
82
|
|
|
83
|
+
`WPP.contact.getStatus` - Get status (`about` field in profile)
|
|
84
|
+
|
|
85
|
+
`WPP.contact.getCommonGroups` - Get groups in common with one contact
|
|
86
|
+
|
|
87
|
+
`WPP.contact.getPnLidEntry` - Get PN (Phone Number), Lid and Contact from local cache
|
|
88
|
+
|
|
89
|
+
For the most up-to-date list of available functions, launch the project locally and run this in your browser console:
|
|
90
|
+
|
|
91
|
+
`Object.keys(WPP.contact).sort()`
|
|
92
|
+
|
|
93
|
+
### Blocklist Functions
|
|
94
|
+
|
|
95
|
+
`WPP.blocklist.blockContact` - Block a contact
|
|
96
|
+
|
|
97
|
+
`WPP.blocklist.unblockContact` - Unblock a contact
|
|
98
|
+
|
|
99
|
+
`WPP.blocklist.all` - All blocked contacts
|
|
100
|
+
|
|
101
|
+
`WPP.blocklist.isBlocked` - Check if contact is blocked
|
|
102
|
+
|
|
103
|
+
For the most up-to-date list of available functions, launch the project locally and run this in your browser console:
|
|
104
|
+
|
|
105
|
+
`Object.keys(WPP.blocklist).sort()`
|
|
106
|
+
|
|
82
107
|
### Group Functions
|
|
83
|
-
`WPP.group.createGroup` - Create a new group
|
|
84
108
|
|
|
85
|
-
`WPP.group.
|
|
109
|
+
`WPP.group.create` - Create a new group
|
|
110
|
+
|
|
111
|
+
`WPP.group.canAdd` - Check if contact can be added to group
|
|
112
|
+
|
|
113
|
+
`WPP.group.addParticipants` - Add participants to a group
|
|
114
|
+
|
|
115
|
+
`WPP.group.removeParticipants` - Remove participants from a group.
|
|
116
|
+
|
|
117
|
+
`WPP.group.canPromote` - Check if contact can be promoted
|
|
86
118
|
|
|
87
|
-
`WPP.group.
|
|
119
|
+
`WPP.group.promoteParticipants` - Promote participants to admin
|
|
88
120
|
|
|
89
|
-
`WPP.group.
|
|
121
|
+
`WPP.group.canDemote` - Check if contact can be demoted
|
|
90
122
|
|
|
91
|
-
`WPP.group.
|
|
123
|
+
`WPP.group.demoteParticipants` - Demote participants from admin.
|
|
92
124
|
|
|
93
125
|
`WPP.group.getGroupInfoFromInviteCode` - Get group information from an invitation link or an invite code.
|
|
94
126
|
|
|
127
|
+
`WPP.group.getAllGroups` - Get all groups
|
|
128
|
+
|
|
129
|
+
For the most up-to-date list of available functions, launch the project locally and run this in your browser console:
|
|
130
|
+
|
|
131
|
+
`Object.keys(WPP.group).sort()`
|
|
132
|
+
|
|
95
133
|
### Events
|
|
96
134
|
`WPP.chat.on('chat.new_message')` - Event to dispatch on receive a new message
|
|
97
135
|
|
|
@@ -102,24 +140,38 @@ To see all events, check: [https://wppconnect.io/wa-js/types/ev.EventTypes.html]
|
|
|
102
140
|
Steps to run locally:
|
|
103
141
|
|
|
104
142
|
```bash
|
|
105
|
-
# install the
|
|
143
|
+
# install the dependencies
|
|
106
144
|
npm install
|
|
107
145
|
|
|
108
|
-
# download whatsapp javascript and prettify (optional)
|
|
109
|
-
npm run wa-source
|
|
110
|
-
|
|
111
146
|
# build javascript files
|
|
112
147
|
npm run build:prd # or build:dev for development
|
|
113
148
|
|
|
114
149
|
# launch a local browser with automatic injection
|
|
150
|
+
# this will also cache the files inside wa-source directory, for next requests
|
|
115
151
|
npm run launch:local
|
|
116
152
|
|
|
117
153
|
# or only run in VSCode
|
|
118
154
|
```
|
|
119
155
|
|
|
156
|
+
Note: to run specific versions run:
|
|
157
|
+
|
|
158
|
+
```sh
|
|
159
|
+
npm run wa-source:clean
|
|
160
|
+
|
|
161
|
+
npm run build:prd
|
|
162
|
+
|
|
163
|
+
WA_VERSION="2.3000.1029560485" npm run launch:local
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
To debug or inspect `wa-source` folder, format the files to be easier to understand
|
|
167
|
+
|
|
168
|
+
```sh
|
|
169
|
+
npm run wa-source:format
|
|
170
|
+
```
|
|
171
|
+
|
|
120
172
|
## How to use this project
|
|
121
173
|
|
|
122
|
-
|
|
174
|
+
Basically, you need to inject the `wppconnect-wa.js` file into the browser after WhatsApp page load.
|
|
123
175
|
|
|
124
176
|
### TamperMonkey or GreaseMonkey
|
|
125
177
|
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Wid } from '../../whatsapp';
|
|
17
16
|
export interface CallEventTypes {
|
|
18
17
|
/**
|
|
19
18
|
* Triggered when you a incoming call
|
|
@@ -47,10 +46,10 @@ export interface CallEventTypes {
|
|
|
47
46
|
/**
|
|
48
47
|
* Wid of sender without device id
|
|
49
48
|
*/
|
|
50
|
-
sender:
|
|
49
|
+
sender: any;
|
|
51
50
|
/**
|
|
52
51
|
* Wid of sender with device id
|
|
53
52
|
*/
|
|
54
|
-
peerJid:
|
|
53
|
+
peerJid: any;
|
|
55
54
|
};
|
|
56
55
|
}
|
|
@@ -14,19 +14,19 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { MsgKey, Wid } from '../../whatsapp';
|
|
17
|
-
export interface
|
|
17
|
+
export interface ForwardMessageOptions {
|
|
18
18
|
displayCaptionText?: boolean;
|
|
19
19
|
multicast?: boolean;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* Forward
|
|
22
|
+
* Forward message to a chat
|
|
23
23
|
*
|
|
24
24
|
* @example
|
|
25
25
|
* ```javascript
|
|
26
|
-
* // Forward
|
|
26
|
+
* // Forward message
|
|
27
27
|
* WPP.chat.forwardMessage('[number]@c.us', 'true_[number]@c.us_ABCDEF');
|
|
28
28
|
* ```
|
|
29
29
|
* @category Message
|
|
30
30
|
* @return {any} Any
|
|
31
31
|
*/
|
|
32
|
-
export declare function forwardMessage(toChatId: string | Wid, msgId: string | MsgKey, options?:
|
|
32
|
+
export declare function forwardMessage(toChatId: string | Wid, msgId: string | MsgKey, options?: ForwardMessageOptions): Promise<boolean>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2021 WPPConnect Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { MsgKey, MsgModel, Wid } from '../../whatsapp';
|
|
17
|
+
export interface ForwardMessagesOptions {
|
|
18
|
+
displayCaptionText?: boolean;
|
|
19
|
+
multicast?: boolean;
|
|
20
|
+
appendedText?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Forward many messages to a chat
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```javascript
|
|
27
|
+
* // Forward messages
|
|
28
|
+
* WPP.chat.forwardMessagesWhatsApp('[number]@c.us', ['true_[number]@c.us_ABCDEF', ...]);
|
|
29
|
+
* ```
|
|
30
|
+
* @category Message
|
|
31
|
+
* @return {any} Any
|
|
32
|
+
*/
|
|
33
|
+
export declare function forwardMessages(toChatId: string | Wid, msgsId: string[] | MsgKey[] | MsgModel[], options?: ForwardMessagesOptions): Promise<Array<any>>;
|
|
@@ -21,6 +21,7 @@ export interface GetMessagesOptions {
|
|
|
21
21
|
id?: string;
|
|
22
22
|
onlyUnread?: boolean;
|
|
23
23
|
media?: 'url' | 'document' | 'all' | 'image';
|
|
24
|
+
includeCallMessages?: boolean;
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
27
|
* Fetch messages from a chat
|
|
@@ -79,6 +80,12 @@ export interface GetMessagesOptions {
|
|
|
79
80
|
* count: 20,
|
|
80
81
|
* media: 'url',
|
|
81
82
|
* });
|
|
83
|
+
*
|
|
84
|
+
* // Include call messages along with chat messages
|
|
85
|
+
* WPP.chat.getMessages('[number]@c.us', {
|
|
86
|
+
* count: 20,
|
|
87
|
+
* includeCallMessages: true,
|
|
88
|
+
* });
|
|
82
89
|
* ```
|
|
83
90
|
* @category Message
|
|
84
91
|
* @return {RawMessage[]} List of raw messages
|
|
@@ -24,7 +24,8 @@ export { deleteMessage, DeleteMessageReturn } from './deleteMessage';
|
|
|
24
24
|
export { downloadMedia } from './downloadMedia';
|
|
25
25
|
export { editMessage } from './editMessage';
|
|
26
26
|
export { find } from './find';
|
|
27
|
-
export { forwardMessage,
|
|
27
|
+
export { forwardMessage, ForwardMessageOptions } from './forwardMessage';
|
|
28
|
+
export { forwardMessages, ForwardMessagesOptions } from './forwardMessages';
|
|
28
29
|
export { generateMessageID } from './generateMessageID';
|
|
29
30
|
export { get } from './get';
|
|
30
31
|
export { getActiveChat } from './getActiveChat';
|
|
@@ -23,6 +23,7 @@ export interface ChatListOptions {
|
|
|
23
23
|
onlyNewsletter?: boolean;
|
|
24
24
|
onlyUsers?: boolean;
|
|
25
25
|
onlyWithUnreadMessage?: boolean;
|
|
26
|
+
onlyArchived?: boolean;
|
|
26
27
|
withLabels?: string[];
|
|
27
28
|
}
|
|
28
29
|
/**
|
|
@@ -59,6 +60,9 @@ export interface ChatListOptions {
|
|
|
59
60
|
*
|
|
60
61
|
* // Only with label with one of text or id
|
|
61
62
|
* const chats = await WPP.chat.list({withLabels: ['Alfa','5']});
|
|
63
|
+
*
|
|
64
|
+
* // Only archived chats
|
|
65
|
+
* const chats = await WPP.chat.list({onlyArchived: true});
|
|
62
66
|
* ```
|
|
63
67
|
*
|
|
64
68
|
* @category Chat
|
|
@@ -22,6 +22,8 @@ import { Wid } from '../../whatsapp';
|
|
|
22
22
|
* await WPP.chat.openChatAt('[number]@c.us', <message_id>);
|
|
23
23
|
* ```
|
|
24
24
|
*
|
|
25
|
+
* @argument chatEntryPoint Optional chat entry point: "Chatlist" for any existing chat in the left panel, undefined for any other case.
|
|
26
|
+
*
|
|
25
27
|
* @category Chat
|
|
26
28
|
*/
|
|
27
|
-
export declare function openChatAt(chatId: string | Wid, messageId: string): Promise<boolean>;
|
|
29
|
+
export declare function openChatAt(chatId: string | Wid, messageId: string, chatEntryPoint?: string | undefined): Promise<boolean>;
|
|
@@ -22,6 +22,8 @@ import { Wid } from '../../whatsapp';
|
|
|
22
22
|
* await WPP.chat.openChatBottom('[number]@c.us');
|
|
23
23
|
* ```
|
|
24
24
|
*
|
|
25
|
+
* @argument chatEntryPoint Optional chat entry point: "Chatlist" for any existing chat in the left panel, undefined for any other case.
|
|
26
|
+
*
|
|
25
27
|
* @category Chat
|
|
26
28
|
*/
|
|
27
|
-
export declare function openChatBottom(chatId: string | Wid): Promise<boolean>;
|
|
29
|
+
export declare function openChatBottom(chatId: string | Wid, chatEntryPoint?: string | undefined): Promise<boolean>;
|
|
@@ -22,6 +22,8 @@ import { Wid } from '../../whatsapp';
|
|
|
22
22
|
* await WPP.chat.openChatFromUnread('[number]@c.us');
|
|
23
23
|
* ```
|
|
24
24
|
*
|
|
25
|
+
* @argument chatEntryPoint Optional chat entry point: "Chatlist" for any existing chat in the left panel, undefined for any other case.
|
|
26
|
+
*
|
|
25
27
|
* @category Chat
|
|
26
28
|
*/
|
|
27
|
-
export declare function openChatFromUnread(chatId: string | Wid): Promise<boolean>;
|
|
29
|
+
export declare function openChatFromUnread(chatId: string | Wid, chatEntryPoint?: string | undefined): Promise<boolean>;
|
|
@@ -14,17 +14,31 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { MsgKey, MsgModel } from '../../whatsapp';
|
|
17
|
-
import { SendMsgResult } from '../../whatsapp/enums';
|
|
17
|
+
import { PinExpiryDurationOption, SendMsgResult } from '../../whatsapp/enums';
|
|
18
18
|
/**
|
|
19
19
|
* Pin a message in chat
|
|
20
20
|
*
|
|
21
|
+
* @param msgId - Message ID to pin/unpin
|
|
22
|
+
* @param pin - True to pin, false to unpin
|
|
23
|
+
* @param duration - Pin duration option. Use PinExpiryDurationOption enum for precise control.
|
|
24
|
+
*
|
|
25
|
+
* @since 3.18.9 - BREAKING CHANGE: The `seconds` parameter (number) has been replaced with `PinExpiryDurationOption` enum.
|
|
26
|
+
* For backward compatibility, numbers are still accepted but will ALWAYS default to 7 days,
|
|
27
|
+
* regardless of the value passed. Use `PinExpiryDurationOption` enum for precise duration control.
|
|
28
|
+
*
|
|
21
29
|
* @example
|
|
22
30
|
* ```javascript
|
|
23
|
-
* // Pin a message in chat
|
|
31
|
+
* // Pin a message in chat with default duration (7 days)
|
|
24
32
|
* WPP.chat.pinMsg('true_[number]@c.us_ABCDEF');
|
|
25
33
|
*
|
|
26
|
-
* // Pin a message in chat for 30 days
|
|
27
|
-
* WPP.chat.pinMsg('true_[number]@c.us_ABCDEF',
|
|
34
|
+
* // Pin a message in chat for 30 days (RECOMMENDED)
|
|
35
|
+
* WPP.chat.pinMsg('true_[number]@c.us_ABCDEF', true, WPP.whatsapp.PinExpiryDurationOption.ThirtyDays);
|
|
36
|
+
*
|
|
37
|
+
* // Pin a message in chat for 1 day
|
|
38
|
+
* WPP.chat.pinMsg('true_[number]@c.us_ABCDEF', true, WPP.whatsapp.PinExpiryDurationOption.OneDay);
|
|
39
|
+
*
|
|
40
|
+
* // DEPRECATED: Passing numbers (always results in 7 days)
|
|
41
|
+
* WPP.chat.pinMsg('true_[number]@c.us_ABCDEF', true, 2592000); // Ignored, defaults to 7 days
|
|
28
42
|
*
|
|
29
43
|
* // Unpin a message
|
|
30
44
|
* WPP.chat.pinMsg('true_[number]@c.us_ABCDEF', false);
|
|
@@ -33,7 +47,7 @@ import { SendMsgResult } from '../../whatsapp/enums';
|
|
|
33
47
|
* ```
|
|
34
48
|
* @category Chat
|
|
35
49
|
*/
|
|
36
|
-
export declare function pinMsg(msgId: string | MsgKey, pin?: boolean,
|
|
50
|
+
export declare function pinMsg(msgId: string | MsgKey, pin?: boolean, duration?: number | PinExpiryDurationOption): Promise<{
|
|
37
51
|
message: MsgModel;
|
|
38
52
|
pinned: boolean;
|
|
39
53
|
result: SendMsgResult;
|
|
@@ -179,6 +179,19 @@ export interface VideoMessageOptions extends FileMessageOptions, MessageButtonsO
|
|
|
179
179
|
* isPtv: true,
|
|
180
180
|
* }
|
|
181
181
|
* );
|
|
182
|
+
*
|
|
183
|
+
* // Media using Link, the link must be public accessible
|
|
184
|
+
* // CORS must be enabled on the server and available for all domains
|
|
185
|
+
* // (Access-Control-Allow-Origin: *)
|
|
186
|
+
* // If the server does not have CORS enabled, you can use a public CORS proxy
|
|
187
|
+
* WPP.chat.sendFileMessage(
|
|
188
|
+
* '[number]@c.us',
|
|
189
|
+
* 'https://example.com/image.jpg',
|
|
190
|
+
* {
|
|
191
|
+
* type: 'image',
|
|
192
|
+
* caption: 'My image from URL', // Optional
|
|
193
|
+
* }
|
|
194
|
+
* );
|
|
182
195
|
* ```
|
|
183
196
|
* @category Message
|
|
184
197
|
* @return {SendMessageReturn} The result
|
|
@@ -20,9 +20,8 @@ export type TextMessageOptions = SendMessageOptions & MessageButtonsOptions & Li
|
|
|
20
20
|
*
|
|
21
21
|
* @example
|
|
22
22
|
* ```javascript
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* });
|
|
23
|
+
* // Send a simple text message
|
|
24
|
+
* WPP.chat.sendTextMessage('[number]@c.us', 'Hello new contact');
|
|
26
25
|
*
|
|
27
26
|
* // With Buttons
|
|
28
27
|
* // Attention: The buttons are an alternative solution we found to make it work. There is no guarantee that they will continue functioning, or when they might stop: The only certainty is: They will stop, so use them responsibly.
|
package/dist/chat/index.d.ts
CHANGED
package/dist/chat/types.d.ts
CHANGED
|
@@ -13,12 +13,13 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { ModelPropertiesContructor, MsgKey, MsgModel, Wid } from '../whatsapp';
|
|
17
|
-
|
|
16
|
+
import { ModelPropertiesContructor, MsgKey, MsgModel, SendMsgResultObject, Wid } from '../whatsapp';
|
|
17
|
+
export type { SendMsgResultObject };
|
|
18
18
|
export interface SendMessageOptions {
|
|
19
19
|
/**
|
|
20
20
|
* Create a new chat to a new contact
|
|
21
21
|
*
|
|
22
|
+
* @deprecated This option is no longer used. Chats are automatically created when sending messages.
|
|
22
23
|
* @default false
|
|
23
24
|
*
|
|
24
25
|
* @example
|
|
@@ -82,6 +83,13 @@ export interface SendMessageOptions {
|
|
|
82
83
|
* ```
|
|
83
84
|
*/
|
|
84
85
|
quotedMsg?: string | MsgKey | MsgModel;
|
|
86
|
+
/**
|
|
87
|
+
* Quote a message using a previously saved payload.
|
|
88
|
+
* The payload must be the JSON string representation of a raw message.
|
|
89
|
+
* Raw messages can be obtained when using {@link getMessageById} or {@link getMessages}
|
|
90
|
+
* When provided it has priority over {@link quotedMsg}.
|
|
91
|
+
*/
|
|
92
|
+
quotedMsgPayload?: string;
|
|
85
93
|
/**
|
|
86
94
|
* Wait for send while the ACK of message is SENT(1)
|
|
87
95
|
*
|
|
@@ -114,6 +122,6 @@ export interface SendMessageReturn {
|
|
|
114
122
|
to?: string;
|
|
115
123
|
latestEditMsgKey?: MsgKey;
|
|
116
124
|
ack: number;
|
|
117
|
-
sendMsgResult: Promise<
|
|
125
|
+
sendMsgResult: Promise<SendMsgResultObject>;
|
|
118
126
|
}
|
|
119
127
|
export type RawMessage = ModelPropertiesContructor<MsgModel>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2025 WPPConnect Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export * from './rehydrateMessage';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2025 WPPConnect Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { MsgModel } from '../../whatsapp';
|
|
17
|
+
export declare function rehydrateMessage(value: any): MsgModel | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2021 WPPConnect Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Change the current environment device between Web and Windows.
|
|
18
|
+
*/
|
|
19
|
+
export declare function changeEnviromentDevice(): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2021 WPPConnect Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Get the WhatsApp Web build constants
|
|
18
|
+
* Retrieves the internal WAWebBuildConstants module from WhatsApp source
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```javascript
|
|
22
|
+
* const buildConstants = WPP.conn.getBuildConstants();
|
|
23
|
+
* console.log('Version:', buildConstants.VERSION_STR);
|
|
24
|
+
* console.log('Base Version:', buildConstants.VERSION_BASE);
|
|
25
|
+
* console.log('Windows Build:', buildConstants.WINDOWS_BUILD);
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @returns {object|null} Object containing version constants or null if not available
|
|
29
|
+
* - VERSION_STR: Full version string (e.g., "2.3000.1234567")
|
|
30
|
+
* - VERSION_BASE: Base version (e.g., "2.3000.1234567")
|
|
31
|
+
* - VERSION_PRIMARY: Primary version number
|
|
32
|
+
* - VERSION_SECONDARY: Secondary version number
|
|
33
|
+
* - VERSION_TERTIARY: Tertiary version number
|
|
34
|
+
* - WINDOWS_BUILD: Windows build number (if applicable)
|
|
35
|
+
* - And other build-related constants
|
|
36
|
+
*/
|
|
37
|
+
export declare function getBuildConstants(): string | null;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2025 WPPConnect Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Wid } from '../../whatsapp/misc';
|
|
17
|
+
/**
|
|
18
|
+
* Migration state information for the current WhatsApp account
|
|
19
|
+
*/
|
|
20
|
+
export interface MigrationState {
|
|
21
|
+
/** Whether the account has been migrated to LID (Linked Identity) system */
|
|
22
|
+
isLidMigrated: boolean;
|
|
23
|
+
/** Whether the sync session has been migrated */
|
|
24
|
+
isSyncdSessionMigrated: boolean;
|
|
25
|
+
/** Whether old messaging rules should still be applied */
|
|
26
|
+
shouldApplyNonMigratedMessagingRules: boolean;
|
|
27
|
+
/** Whether the account should have an account LID */
|
|
28
|
+
shouldHaveAccountLid: boolean;
|
|
29
|
+
/** The current user's LID, if available */
|
|
30
|
+
currentLid?: Wid;
|
|
31
|
+
/** The current user's PN, if available */
|
|
32
|
+
currentPn?: Wid;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get comprehensive migration state information for debugging and monitoring
|
|
36
|
+
*
|
|
37
|
+
* This function aggregates various LID (Linked Identity) migration-related
|
|
38
|
+
* information to help understand the current state of the account's migration
|
|
39
|
+
* from the legacy @c.us addressing system to the newer @lid system.
|
|
40
|
+
*
|
|
41
|
+
* @returns Object containing all available migration state information
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const state = WPP.conn.getMigrationState();
|
|
46
|
+
* console.log('Account migrated:', state.isLidMigrated);
|
|
47
|
+
* console.log('Current LID:', state.currentLid);
|
|
48
|
+
* console.log('Should have LID:', state.shouldHaveAccountLid);
|
|
49
|
+
* ```
|
|
50
|
+
* @category Connection
|
|
51
|
+
*/
|
|
52
|
+
export declare function getMigrationState(): MigrationState;
|
|
@@ -13,9 +13,12 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
export { changeEnviromentDevice } from './changeEnviromentDevice';
|
|
16
17
|
export { genLinkDeviceCodeForPhoneNumber } from './genLinkDeviceCodeForPhoneNumber';
|
|
17
18
|
export { getAuthCode } from './getAuthCode';
|
|
19
|
+
export { getBuildConstants } from './getBuildConstants';
|
|
18
20
|
export { getHistorySyncProgress, HistorySyncProgress, } from './getHistorySyncProgress';
|
|
21
|
+
export { getMigrationState, MigrationState } from './getMigrationState';
|
|
19
22
|
export { getMyDeviceId } from './getMyDeviceId';
|
|
20
23
|
export { getMyUserId } from './getMyUserId';
|
|
21
24
|
export { getPlatform } from './getPlatform';
|