@open-wa/wa-automate 4.76.0 → 5.0.0-alpha.2

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.
Files changed (125) hide show
  1. package/README.md +14 -165
  2. package/dist/cli-runtime-B7_3MM0c.cjs +798 -0
  3. package/dist/cli-runtime-B7_3MM0c.cjs.map +1 -0
  4. package/dist/cli-runtime-CmpYxFCk.d.cts +31 -0
  5. package/dist/cli-runtime-CmpYxFCk.d.cts.map +1 -0
  6. package/dist/cli.cjs +17 -0
  7. package/dist/cli.cjs.map +1 -0
  8. package/dist/cli.d.cts +2 -0
  9. package/dist/index.cjs +224 -0
  10. package/dist/index.cjs.map +1 -0
  11. package/dist/index.d.cts +81 -0
  12. package/dist/index.d.cts.map +1 -0
  13. package/package.json +34 -177
  14. package/CNAME +0 -1
  15. package/_tsconfig.docs.json +0 -140
  16. package/bin/config-schema.json +0 -1
  17. package/bin/oas-type-schemas.json +0 -1
  18. package/bin/server.js +0 -45
  19. package/build/build-config-json-for-bin.ts +0 -56
  20. package/build/generate-oas-types.ts +0 -31
  21. package/dist/api/Client.d.ts +0 -2255
  22. package/dist/api/Client.js +0 -4358
  23. package/dist/api/functions/exposed.enum.d.ts +0 -7
  24. package/dist/api/functions/exposed.enum.js +0 -11
  25. package/dist/api/model/aliases.d.ts +0 -110
  26. package/dist/api/model/aliases.js +0 -3
  27. package/dist/api/model/button.d.ts +0 -24
  28. package/dist/api/model/button.js +0 -2
  29. package/dist/api/model/call.d.ts +0 -51
  30. package/dist/api/model/call.js +0 -18
  31. package/dist/api/model/chat.d.ts +0 -221
  32. package/dist/api/model/chat.js +0 -52
  33. package/dist/api/model/config.d.ts +0 -836
  34. package/dist/api/model/config.js +0 -111
  35. package/dist/api/model/contact.d.ts +0 -143
  36. package/dist/api/model/contact.js +0 -2
  37. package/dist/api/model/errors.d.ts +0 -90
  38. package/dist/api/model/errors.js +0 -117
  39. package/dist/api/model/events.d.ts +0 -120
  40. package/dist/api/model/events.js +0 -127
  41. package/dist/api/model/group-metadata.d.ts +0 -124
  42. package/dist/api/model/group-metadata.js +0 -25
  43. package/dist/api/model/id.d.ts +0 -5
  44. package/dist/api/model/id.js +0 -2
  45. package/dist/api/model/index.d.ts +0 -110
  46. package/dist/api/model/index.js +0 -128
  47. package/dist/api/model/label.d.ts +0 -24
  48. package/dist/api/model/label.js +0 -2
  49. package/dist/api/model/media.d.ts +0 -93
  50. package/dist/api/model/media.js +0 -12
  51. package/dist/api/model/message.d.ts +0 -422
  52. package/dist/api/model/message.js +0 -40
  53. package/dist/api/model/product.d.ts +0 -141
  54. package/dist/api/model/product.js +0 -2
  55. package/dist/api/model/reactions.d.ts +0 -76
  56. package/dist/api/model/reactions.js +0 -2
  57. package/dist/api/model/sessionInfo.d.ts +0 -77
  58. package/dist/api/model/sessionInfo.js +0 -2
  59. package/dist/build/build-postman.d.ts +0 -1
  60. package/dist/build/build-postman.js +0 -262
  61. package/dist/cli/cli-options.d.ts +0 -9
  62. package/dist/cli/cli-options.js +0 -289
  63. package/dist/cli/collections.d.ts +0 -2
  64. package/dist/cli/collections.js +0 -251
  65. package/dist/cli/file-utils.d.ts +0 -1
  66. package/dist/cli/file-utils.js +0 -71
  67. package/dist/cli/index.d.ts +0 -1
  68. package/dist/cli/index.js +0 -231
  69. package/dist/cli/integrations/chatwoot.d.ts +0 -49
  70. package/dist/cli/integrations/chatwoot.js +0 -672
  71. package/dist/cli/integrations/cloudflare.d.ts +0 -6
  72. package/dist/cli/integrations/cloudflare.js +0 -76
  73. package/dist/cli/logo.d.ts +0 -1
  74. package/dist/cli/logo.js +0 -49
  75. package/dist/cli/server.d.ts +0 -24
  76. package/dist/cli/server.js +0 -540
  77. package/dist/cli/setup.d.ts +0 -30
  78. package/dist/cli/setup.js +0 -308
  79. package/dist/config/puppeteer.config.d.ts +0 -11
  80. package/dist/config/puppeteer.config.js +0 -65
  81. package/dist/controllers/auth.d.ts +0 -36
  82. package/dist/controllers/auth.js +0 -322
  83. package/dist/controllers/browser.d.ts +0 -17
  84. package/dist/controllers/browser.js +0 -603
  85. package/dist/controllers/events.d.ts +0 -82
  86. package/dist/controllers/events.js +0 -173
  87. package/dist/controllers/init_patch.d.ts +0 -13
  88. package/dist/controllers/init_patch.js +0 -42
  89. package/dist/controllers/initializer.d.ts +0 -22
  90. package/dist/controllers/initializer.js +0 -511
  91. package/dist/controllers/launch_checks.d.ts +0 -8
  92. package/dist/controllers/launch_checks.js +0 -130
  93. package/dist/controllers/patch_manager.d.ts +0 -37
  94. package/dist/controllers/patch_manager.js +0 -231
  95. package/dist/controllers/popup/index.d.ts +0 -3
  96. package/dist/controllers/popup/index.html +0 -168
  97. package/dist/controllers/popup/index.js +0 -148
  98. package/dist/controllers/script_preloader.d.ts +0 -17
  99. package/dist/controllers/script_preloader.js +0 -88
  100. package/dist/index.d.ts +0 -13
  101. package/dist/index.js +0 -36
  102. package/dist/lib/README.md +0 -5
  103. package/dist/lib/base64.js +0 -1
  104. package/dist/lib/hash.js +0 -1
  105. package/dist/lib/jsSha.min.js +0 -1
  106. package/dist/lib/launch.js +0 -1
  107. package/dist/lib/qr.min.js +0 -1
  108. package/dist/lib/wapi.js +0 -2163
  109. package/dist/logging/custom_transport.d.ts +0 -9
  110. package/dist/logging/custom_transport.js +0 -35
  111. package/dist/logging/logging.d.ts +0 -50
  112. package/dist/logging/logging.js +0 -196
  113. package/dist/structures/Collector.d.ts +0 -202
  114. package/dist/structures/Collector.js +0 -391
  115. package/dist/structures/Dialog.d.ts +0 -55
  116. package/dist/structures/Dialog.js +0 -21
  117. package/dist/structures/MessageCollector.d.ts +0 -78
  118. package/dist/structures/MessageCollector.js +0 -145
  119. package/dist/structures/preProcessors.d.ts +0 -58
  120. package/dist/structures/preProcessors.js +0 -181
  121. package/dist/utils/pid_utils.d.ts +0 -1
  122. package/dist/utils/pid_utils.js +0 -26
  123. package/dist/utils/tools.d.ts +0 -152
  124. package/dist/utils/tools.js +0 -494
  125. package/tos.md +0 -77
@@ -1,2255 +0,0 @@
1
- /// <reference types="node" />
2
- import { Page } from 'puppeteer';
3
- import { Chat, LiveLocationChangedEvent, ChatState, ChatMuteDuration, GroupChatCreationResponse, EphemeralDuration } from './model/chat';
4
- import { BusinessProfile, Contact, NumberCheck } from './model/contact';
5
- import { Message, MessageInfo, MessagePinDuration, PollData } from './model/message';
6
- import { AxiosRequestConfig } from 'axios';
7
- import { NewCommunityGroup, ParticipantChangedEventModel, GenericGroupChangeEvent, GroupMetadata } from './model/group-metadata';
8
- import { ConfigObject, STATE, LicenseType, Webhook, EventPayload } from './model';
9
- import PQueue, { DefaultAddOptions, Options } from 'p-queue';
10
- import { HealthCheck, SessionInfo } from './model/sessionInfo';
11
- import { ChatId, GroupChatId, Content, Base64, MessageId, ContactId, DataURL, AdvancedFile, GroupId } from './model/aliases';
12
- import { CustomProduct, Order, Product } from './model/product';
13
- import { Label } from './model/label';
14
- import { Mp4StickerConversionProcessOptions, StickerMetadata } from './model/media';
15
- import { SimpleListener } from './model/events';
16
- import { AwaitMessagesOptions, Collection, CollectorFilter, CollectorOptions } from '../structures/Collector';
17
- import { MessageCollector } from '../structures/MessageCollector';
18
- import { Listener } from 'eventemitter2';
19
- import PriorityQueue from 'p-queue/dist/priority-queue';
20
- import { NextFunction, Request, Response } from 'express';
21
- import { Call } from './model/call';
22
- import { AdvancedButton, Button, LocationButtonBody, Section } from './model/button';
23
- import { JsonObject } from 'type-fest';
24
- import { ReactionEvent } from './model/reactions';
25
- export declare enum namespace {
26
- Chat = "Chat",
27
- Msg = "Msg",
28
- Contact = "Contact",
29
- GroupMetadata = "GroupMetadata"
30
- }
31
- export declare class Client {
32
- private _loadedModules;
33
- private _registeredWebhooks;
34
- private _registeredEvListeners;
35
- private _webhookQueue;
36
- private _createConfig;
37
- private _sessionInfo;
38
- private _listeners;
39
- private _page;
40
- private _currentlyBeingKilled;
41
- private _refreshing;
42
- private _loaded;
43
- private _hostAccountNumber;
44
- private _prio;
45
- private _pageListeners;
46
- private _registeredPageListeners;
47
- private _onLogoutCallbacks;
48
- private _queues;
49
- private _autoEmojiSet;
50
- private _autoEmojiQ;
51
- private _onLogoutSet;
52
- private _preprocIdempotencyCheck;
53
- /**
54
- * This is used to track if a listener is already used via webhook. Before, webhooks used to be set once per listener. Now a listener can be set via multiple webhooks, or revoked from a specific webhook.
55
- * For this reason, listeners assigned to a webhook are only set once and map through all possible webhooks to and fire only if the specific listener is assigned.
56
- *
57
- * Note: This would be much simpler if eventMode was the default (and only) listener strategy.
58
- */
59
- private _registeredWebhookListeners;
60
- /**
61
- * @ignore
62
- * @param page [Page] [Puppeteer Page]{@link https://pptr.dev/#?product=Puppeteer&version=v2.1.1&show=api-class-page} running WA Web
63
- */
64
- constructor(page: Page, createConfig: ConfigObject, sessionInfo: SessionInfo);
65
- /**
66
- * @private
67
- *
68
- * DO NOT USE THIS.
69
- *
70
- * Run all tasks to set up client AFTER init is fully completed
71
- */
72
- loaded(): Promise<void>;
73
- private registerAllSimpleListenersOnEv;
74
- getSessionId(): string;
75
- getPage(): Page;
76
- private _setOnClose;
77
- private _reInjectWapi;
78
- private _reRegisterListeners;
79
- /**
80
- * A convinience method to download the [[DataURL]] of a file
81
- * @param url The url
82
- * @param optionsOverride You can use this to override the [axios request config](https://github.com/axios/axios#request-config)
83
- * @returns `Promise<DataURL>`
84
- */
85
- download(url: string, optionsOverride?: any): Promise<DataURL>;
86
- /**
87
- * Grab the logger for this session/process
88
- */
89
- logger(): any;
90
- /**
91
- * Refreshes the page and reinjects all necessary files. This may be useful for when trying to save memory
92
- * This will attempt to re register all listeners EXCEPT onLiveLocation and onParticipantChanged
93
- */
94
- refresh(): Promise<boolean>;
95
- /**
96
- * Get the session info
97
- *
98
- * @returns SessionInfo
99
- */
100
- getSessionInfo(): SessionInfo;
101
- /**
102
- * Easily resize page on the fly. Useful if you're showing screenshots in a web-app.
103
- */
104
- resizePage(width?: number, height?: number): Promise<boolean>;
105
- /**
106
- * Get the config which was used to set up the client. Sensitive details (like devTools username and password, and browserWSEndpoint) are scrubbed
107
- *
108
- * @returns SessionInfo
109
- */
110
- getConfig(): ConfigObject;
111
- private pup;
112
- private responseWrap;
113
- /**
114
- * //////////////////////// LISTENERS
115
- */
116
- removeListener(listener: SimpleListener): boolean;
117
- removeAllListeners(): boolean;
118
- /**
119
- *
120
- */
121
- private registerListener;
122
- private registerPageEventListener;
123
- /**
124
- * It calls the JavaScript garbage collector
125
- * @returns Nothing.
126
- */
127
- gc(): Promise<void>;
128
- /**
129
- * Listens to a log out event
130
- *
131
- * @event
132
- * @param fn callback
133
- * @param priority A priority of -1 will mean the callback will be triggered after all the non -1 callbacks
134
- * @fires `true`
135
- */
136
- onLogout(fn: (loggedOut?: boolean) => any, priority?: number): Promise<boolean>;
137
- /**
138
- * Wait for the webhook queue to become idle. This is useful for ensuring webhooks are cleared before ending a process.
139
- */
140
- waitWhQIdle(): Promise<true | void>;
141
- /**
142
- * Wait for all queues to be empty
143
- */
144
- waitAllQEmpty(): Promise<true | void[]>;
145
- /**
146
- * If you have set `onAnyMessage` or `onMessage` with the second parameter (PQueue options) then you may want to inspect their respective PQueue's.
147
- */
148
- getListenerQueues(): {
149
- [key in SimpleListener]?: PQueue;
150
- };
151
- private preprocessMessage;
152
- /**
153
- * Listens to incoming messages
154
- *
155
- * @event
156
- * @param fn callback
157
- * @param queueOptions PQueue options. Set to `{}` for default PQueue.
158
- * @fires [[Message]]
159
- */
160
- onMessage(fn: (message: Message) => void, queueOptions?: Options<PriorityQueue, DefaultAddOptions>): Promise<Listener | boolean>;
161
- /**
162
- * Listens to all new messages
163
- *
164
- * @event
165
- * @param fn callback
166
- * @param queueOptions PQueue options. Set to `{}` for default PQueue.
167
- * @fires [[Message]]
168
- */
169
- onAnyMessage(fn: (message: Message) => void, queueOptions?: Options<PriorityQueue, DefaultAddOptions>): Promise<Listener | boolean>;
170
- /**
171
- *
172
- * Listens to when a message is deleted by a recipient or the host account
173
- * @event
174
- * @param fn callback
175
- * @fires [[Message]]
176
- */
177
- onMessageDeleted(fn: (message: Message) => void): Promise<Listener | boolean>;
178
- /**
179
- * Listens to when a chat is deleted by the host account
180
- * @event
181
- * @param fn callback
182
- * @fires [[Chat]]
183
- */
184
- onChatDeleted(fn: (chat: Chat) => void): Promise<Listener | boolean>;
185
- /**
186
- * Listens to button message responses
187
- * @event
188
- * @param fn callback
189
- * @fires [[Message]]
190
- */
191
- onButton(fn: (message: Message) => void): Promise<Listener | boolean>;
192
- /**
193
- * Listens to poll vote events
194
- * @event
195
- * @param fn callback
196
- * @fires [[PollData]]
197
- */
198
- onPollVote(fn: (pollDate: PollData) => void): Promise<Listener | boolean>;
199
- /**
200
- * Listens to broadcast messages
201
- * @event
202
- * @param fn callback
203
- * @fires [[Message]]
204
- */
205
- onBroadcast(fn: (message: Message) => void): Promise<Listener | boolean>;
206
- /**
207
- * @deprecated
208
- *
209
- * Listens to battery changes
210
- *
211
- * :::caution
212
- *
213
- * This will most likely not work with multi-device mode (the only remaining mode) since the session is no longer connected to the phone but directly to WA servers.
214
- *
215
- * :::
216
- *
217
- * @event
218
- * @param fn callback
219
- * @fires number
220
- */
221
- onBattery(fn: (battery: number) => void): Promise<Listener | boolean>;
222
- /**
223
- * Listens to when host device is plugged/unplugged
224
- * @event
225
- *
226
- * @param fn callback
227
- * @fires boolean true if plugged, false if unplugged
228
- */
229
- onPlugged(fn: (plugged: boolean) => void): Promise<Listener | boolean>;
230
- /**
231
- * {@license:restricted@}
232
- *
233
- * Listens to when a contact posts a new story.
234
- * @event
235
- *
236
- * @param fn callback
237
- * @fires e.g
238
- *
239
- * ```javascript
240
- * {
241
- * from: '123456789@c.us'
242
- * id: 'false_132234234234234@status.broadcast'
243
- * }
244
- * ```
245
- */
246
- onStory(fn: (story: Message) => void): Promise<Listener | boolean>;
247
- /**
248
- * Listens to changes in state
249
- *
250
- * @event
251
- * @fires STATE observable sream of states
252
- */
253
- onStateChanged(fn: (state: STATE) => void): Promise<Listener | boolean>;
254
- /**
255
- * Listens to new incoming calls
256
- * @event
257
- * @returns Observable stream of call request objects
258
- */
259
- onIncomingCall(fn: (call: Call) => void): Promise<Listener | boolean>;
260
- /**
261
- * Listens to changes on call state
262
- * @event
263
- * @returns Observable stream of call objects
264
- */
265
- onCallState(fn: (call: Call) => void): Promise<Listener | boolean>;
266
- /**
267
- * Listens to label change events
268
- *
269
- * @event
270
- * @param fn callback
271
- * @fires [[Label]]
272
- */
273
- onLabel(fn: (label: Label) => void): Promise<Listener | boolean>;
274
- /**
275
- *{@license:insiders@}
276
- *
277
- * Listens to new orders. Only works on business accounts
278
- */
279
- onOrder(fn: (order: Order) => void): Promise<Listener | boolean>;
280
- /**
281
- *{@license:insiders@}
282
- *
283
- * Listens to new orders. Only works on business accounts
284
- */
285
- onNewProduct(fn: (product: Product) => void): Promise<Listener | boolean>;
286
- /**
287
- * {@license:insiders@}
288
- *
289
- * Listens to reaction add and change events
290
- *
291
- * @event
292
- * @param fn callback
293
- * @fires [[ReactionEvent]]
294
- */
295
- onReaction(fn: (reactionEvent: ReactionEvent) => void): Promise<Listener | boolean>;
296
- /**
297
- * {@license:insiders@}
298
- *
299
- * Listens to chat state, including when a specific user is recording and typing within a group chat.
300
- *
301
- * @event
302
- *
303
- * Here is an example of the fired object:
304
- *
305
- * @fires
306
- * ```javascript
307
- * {
308
- * "chat": "00000000000-1111111111@g.us", //the chat in which this state is occuring
309
- * "user": "22222222222@c.us", //the user that is causing this state
310
- * "state": "composing, //can also be 'available', 'unavailable', 'recording' or 'composing'
311
- * }
312
- * ```
313
- */
314
- onChatState(fn: (chatState: ChatState) => void): Promise<Listener | boolean>;
315
- /**
316
- * Listens to messages acknowledgement Changes
317
- *
318
- * @param fn callback function that handles a [[Message]] as the first and only parameter.
319
- * @event
320
- * @returns `true` if the callback was registered
321
- */
322
- onAck(fn: (message: Message) => void): Promise<Listener | boolean>;
323
- /**
324
- * Listens to add and remove events on Groups on a global level. It is memory efficient and doesn't require a specific group id to listen to.
325
- *
326
- * @event
327
- * @param fn callback function that handles a [[ParticipantChangedEventModel]] as the first and only parameter.
328
- * @returns `true` if the callback was registered
329
- */
330
- onGlobalParticipantsChanged(fn: (participantChangedEvent: ParticipantChangedEventModel) => void): Promise<Listener | boolean>;
331
- /**
332
- * Listents to group approval requests. Emits a message object. Use it with `message.isGroupApprovalRequest()` to check if it is a group approval request.
333
- *
334
- * @event
335
- * @param fn callback function that handles a [[Message]] as the first and only parameter.
336
- * @returns `true` if the callback was registered
337
- */
338
- onGroupApprovalRequest(fn: (groupApprovalRequestMessage: Message) => void): Promise<Listener | boolean>;
339
- /**
340
- * Listens to all group (gp2) events. This can be useful if you want to catch when a group title, subject or picture is changed.
341
- *
342
- * @event
343
- * @param fn callback function that handles a [[ParticipantChangedEventModel]] as the first and only parameter.
344
- * @returns `true` if the callback was registered
345
- */
346
- onGroupChange(fn: (genericGroupChangeEvent: GenericGroupChangeEvent) => void): Promise<Listener | boolean>;
347
- /**
348
- * Fires callback with Chat object every time the host phone is added to a group.
349
- *
350
- * @event
351
- * @param fn callback function that handles a [[Chat]] (group chat) as the first and only parameter.
352
- * @returns `true` if the callback was registered
353
- */
354
- onAddedToGroup(fn: (chat: Chat) => any): Promise<Listener | boolean>;
355
- /**
356
- * {@license:insiders@}
357
- *
358
- * Fires callback with Chat object every time the host phone is removed to a group.
359
- *
360
- * @event
361
- * @param fn callback function that handles a [[Chat]] (group chat) as the first and only parameter.
362
- * @returns `true` if the callback was registered
363
- */
364
- onRemovedFromGroup(fn: (chat: Chat) => any): Promise<Listener | boolean>;
365
- /**
366
- * {@license:insiders@}
367
- *
368
- * Fires callback with the relevant chat id every time the user clicks on a chat. This will only work in headful mode.
369
- *
370
- * @event
371
- * @param fn callback function that handles a [[ChatId]] as the first and only parameter.
372
- * @returns `true` if the callback was registered
373
- */
374
- onChatOpened(fn: (chat: Chat) => any): Promise<Listener | boolean>;
375
- /**
376
- * {@license:insiders@}
377
- *
378
- * Fires callback with contact id when a new contact is added on the host phone.
379
- *
380
- * @event
381
- * @param fn callback function that handles a [[Chat]] as the first and only parameter.
382
- * @returns `true` if the callback was registered
383
- */
384
- onContactAdded(fn: (chat: Chat) => any): Promise<Listener | boolean>;
385
- /**
386
- * @event
387
- * Listens to add and remove events on Groups. This can no longer determine who commited the action and only reports the following events add, remove, promote, demote
388
- * @param groupId group id: xxxxx-yyyy@c.us
389
- * @param fn callback
390
- * @returns Observable stream of participantChangedEvent
391
- */
392
- onParticipantsChanged(groupId: GroupChatId, fn: (participantChangedEvent: ParticipantChangedEventModel) => void, legacy?: boolean): Promise<Listener | boolean>;
393
- /**
394
- * @event Listens to live locations from a chat that already has valid live locations
395
- * @param chatId the chat from which you want to subscribes to live location updates
396
- * @param fn callback that takes in a LiveLocationChangedEvent
397
- * @returns boolean, if returns false then there were no valid live locations in the chat of chatId
398
- * @emits `<LiveLocationChangedEvent>` LiveLocationChangedEvent
399
- */
400
- onLiveLocation(chatId: ChatId, fn: (liveLocationChangedEvent: LiveLocationChangedEvent) => void): Promise<boolean>;
401
- /**
402
- * Use this simple command to test firing callback events.
403
- *
404
- * @param callbackToTest
405
- * @param testData
406
- * @returns `false` if the callback was not registered/does not exist
407
- */
408
- testCallback(callbackToTest: SimpleListener, testData: any): Promise<boolean>;
409
- /**
410
- * Set presence to available or unavailable.
411
- * @param available if true it will set your presence to 'online', false will set to unavailable (i.e no 'online' on recipients' phone);
412
- */
413
- setPresence(available: boolean): Promise<boolean | void>;
414
- /**
415
- * set your about me
416
- * @param newStatus String new profile status
417
- */
418
- setMyStatus(newStatus: string): Promise<boolean | void>;
419
- /**
420
- * {@license:insiders@}
421
- *
422
- * Adds label from chat, message or contact. Only for business accounts.
423
- * @param label: The desired text of the new label. id will be something simple like anhy nnumber from 1-10, name is the label of the label if that makes sense.
424
- * @returns `false` if something went wrong, or the id (usually a number as a string) of the new label (for example `"58"`)
425
- */
426
- createLabel(label: string): Promise<string | boolean>;
427
- /**
428
- * Adds label from chat, message or contact. Only for business accounts.
429
- * @param label: either the id or the name of the label. id will be something simple like anhy nnumber from 1-10, name is the label of the label if that makes sense.
430
- * @param id The Chat, message or contact id to which you want to add a label
431
- */
432
- addLabel(label: string, chatId: ChatId): Promise<boolean>;
433
- /**
434
- * Returns all labels and the corresponding tagged items.
435
- */
436
- getAllLabels(): Promise<Label[]>;
437
- /**
438
- * Removes label from chat, message or contact. Only for business accounts.
439
- * @param label: either the id or the name of the label. id will be something simple like anhy nnumber from 1-10, name is the label of the label if that makes sense.
440
- * @param id The Chat, message or contact id to which you want to add a label
441
- */
442
- removeLabel(label: string, chatId: ChatId): Promise<boolean>;
443
- /**
444
- * Get an array of chats that match the label parameter. For example, if you want to get an array of chat objects that have the label "New customer".
445
- *
446
- * This method is case insenstive and only works on business host accounts.
447
- *
448
- * @label The label name
449
- */
450
- getChatsByLabel(label: string): Promise<Chat[]>;
451
- /**
452
- * Send VCARD
453
- *
454
- * @param {string} chatId '000000000000@c.us'
455
- * @param {string} vcard vcard as a string, you can send multiple contacts vcard also.
456
- * @param {string} contactName The display name for the contact. Ignored on multiple vcards
457
- * @param {string} contactNumber If supplied, this will be injected into the vcard (VERSION 3 ONLY FROM VCARDJS) with the WA id to make it show up with the correct buttons on WA. The format of this param should be including country code, without any other formating. e.g:
458
- * `4477777777777`
459
- * Ignored on multiple vcards
460
- */
461
- sendVCard(chatId: ChatId, vcard: string, contactName?: string, contactNumber?: string): Promise<boolean>;
462
- /**
463
- * Set your profile name
464
- *
465
- * Please note, this does not work on business accounts!
466
- *
467
- * @param newName String new name to set for your profile
468
- */
469
- setMyName(newName: string): Promise<boolean>;
470
- /**
471
- * Sets the chat state
472
- * @param {ChatState|0|1|2} chatState The state you want to set for the chat. Can be TYPING (0), RECRDING (1) or PAUSED (2).
473
- * @param {String} chatId
474
- */
475
- setChatState(chatState: ChatState, chatId: ChatId): Promise<boolean>;
476
- /**
477
- * Returns the connection state
478
- */
479
- getConnectionState(): Promise<STATE>;
480
- /**
481
- * Retreive an array of messages that are not yet sent to the recipient via the host account device (i.e no ticks)
482
- */
483
- getUnsentMessages(): Promise<Message[]>;
484
- /**
485
- * Forces the session to update the connection state.
486
- * @param killBeforeAttemptingToReconnect Setting this to true will force the session to drop the current socket connection before attempting to reconnect. This is useful if you want to force the session to reconnect immediately.
487
- * @returns updated connection state
488
- */
489
- forceUpdateConnectionState(killBeforeReconnect?: boolean): Promise<STATE>;
490
- /**
491
- * Returns a list of contact with whom the host number has an existing chat who are also not contacts.
492
- */
493
- getChatWithNonContacts(): Promise<Contact[]>;
494
- /**
495
- * Shuts down the page and browser
496
- * @returns true
497
- */
498
- kill(reason?: string): Promise<boolean>;
499
- /**
500
- * This is a convinient method to click the `Use Here` button in the WA web session.
501
- *
502
- * Use this when [[STATE]] is `CONFLICT`. You can read more about managing state here:
503
- *
504
- * [[Detecting Logouts]]
505
- */
506
- forceRefocus(): Promise<boolean>;
507
- /**
508
- * Check if the "Phone not Cconnected" message is showing in the browser. If it is showing, then this will return `true`.
509
- *
510
- * @returns `boolean`
511
- */
512
- isPhoneDisconnected(): Promise<boolean>;
513
- /**
514
- * Runs a health check to help you determine if/when is an appropiate time to restart/refresh the session.
515
- */
516
- healthCheck(): Promise<HealthCheck>;
517
- /**
518
- * Get the stats of the current process and the corresponding browser process.
519
- */
520
- getProcessStats(): Promise<any>;
521
- /**
522
- * A list of participants in the chat who have their live location on. If the chat does not exist, or the chat does not have any contacts actively sharing their live locations, it will return false. If it's a chat with a single contact, there will be only 1 value in the array if the contact has their livelocation on.
523
- * Please note. This should only be called once every 30 or so seconds. This forces the phone to grab the latest live location data for the number. This can be used in conjunction with onLiveLocation (this will trigger onLiveLocation).
524
- * @param chatId string Id of the chat you want to force the phone to get the livelocation data for.
525
- * @returns `Promise<LiveLocationChangedEvent []>` | boolean
526
- */
527
- forceUpdateLiveLocation(chatId: ChatId): Promise<LiveLocationChangedEvent[] | boolean>;
528
- /**
529
- *
530
- * @deprecated
531
- *
532
- * :::danger
533
- *
534
- * Buttons are broken for the foreseeable future. Please DO NOT get a license solely for access to buttons. They are no longer reliable due to recent changes at WA.
535
- *
536
- * :::
537
- *
538
- * Test the button commands on MD accounts with an insiders key. This is a temporary feature to help fix issue #2658
539
- */
540
- testButtons(chatId: ChatId): Promise<any>;
541
- private link;
542
- /**
543
- * Generate a license link
544
- */
545
- getLicenseLink(params?: string): Promise<string>;
546
- /**
547
- *
548
- * {@license:restricted@}
549
- *
550
- * Sends a text message to given chat
551
- *
552
- * A license is **NOT** required to send messages with existing chats/contacts. A license is only required for starting conversations with new numbers.
553
- *
554
- * @param to chat id: `xxxxx@c.us`
555
- * @param content text message
556
- */
557
- sendText(to: ChatId, content: Content): Promise<boolean | MessageId>;
558
- /**
559
- * Sends a text message to given chat that includes mentions.
560
- * In order to use this method correctly you will need to send the text like this:
561
- * "@4474747474747 how are you?"
562
- * Basically, add a @ symbol before the number of the contact you want to mention.
563
- *
564
- * @param to chat id: `xxxxx@c.us`
565
- * @param content text message
566
- * @param hideTags Removes all tags within the message
567
- * @param mentions You can optionally add an array of contact IDs to tag only specific people
568
- */
569
- sendTextWithMentions(to: ChatId, content: Content, hideTags?: boolean, mentions?: ContactId[]): Promise<boolean | MessageId>;
570
- /**
571
- * NOTE: This is experimental, most accounts do not have access to this feature in their apps.
572
- *
573
- * Edit an existing message
574
- *
575
- * @param messageId The message ID to edit
576
- * @param text The new text content
577
- * @returns
578
- */
579
- editMessage(messageId: MessageId, text: Content): Promise<boolean | MessageId>;
580
- /**
581
- * [UNTESTED - REQUIRES FEEDBACK]
582
- * Sends a payment request message to given chat
583
- *
584
- * @param to chat id: `xxxxx@c.us`
585
- * @param amount number the amount to request in 1000 format (e.g £10 => 10000)
586
- * @param currency string The 3 letter currency code
587
- * @param message string optional message to send with the payment request
588
- */
589
- sendPaymentRequest(to: ChatId, amount: number, currency: string, message?: string): Promise<boolean | MessageId>;
590
- /**
591
- *
592
- * @deprecated
593
- *
594
- * :::danger
595
- *
596
- * WA BIZ accounts CANNOT send buttons. This is a WA limitation. DO NOT get a license solely for access to buttons on wa business accounts.
597
- * THIS IS NOT WORKING FOR GROUPS YET.
598
- *
599
- * BUTTONS ARE DEPRECATED FOR NOW. DO NOT GET A LICENSE TO USE BUTTONS.
600
- *
601
- * :::
602
- *
603
- * Send generic quick reply buttons. This is an insiders feature for MD accounts.
604
- *
605
- * @param {ChatId} to chat id
606
- * @param {string | LocationButtonBody} body The body of the buttons message
607
- * @param {Button[]} buttons Array of buttons - limit is 3!
608
- * @param {string} title The title/header of the buttons message
609
- * @param {string} footer The footer of the buttons message
610
- */
611
- sendButtons(to: ChatId, body: string | LocationButtonBody, buttons: Button[], title?: string, footer?: string): Promise<boolean | MessageId>;
612
- /**
613
- * @deprecated
614
- *
615
- * :::danger
616
- *
617
- * Template messages (URL & CALL buttons) are broken for the foreseeable future. Please DO NOT get a license solely for access to URL or CALL buttons. They are no longer reliable due to recent changes at WA.
618
- * WA BIZ accounts CANNOT send buttons. This is a WA limitation. DO NOT get a license solely for access to buttons on wa business accounts.
619
- *
620
- * THIS IS NOT WORKING FOR GROUPS YET.
621
- *
622
- * ADVANCED ARE DEPRECATED FOR NOW. DO NOT GET A LICENSE TO USE BUTTONS.
623
- *
624
- * :::
625
- *
626
- *
627
- * Send advanced buttons with media body. This is an insiders feature for MD accounts.
628
- *
629
- * Body can be location, image, video or document. Buttons can be quick reply, url or call buttons.
630
- *
631
- * @param {ChatId} to chat id
632
- * @param {string | LocationButtonBody} body The body of the buttons message
633
- * @param {AdvancedButton[]} buttons Array of buttons - limit is 3!
634
- * @param {string} title The title/header of the buttons message
635
- * @param {string} footer The footer of the buttons message
636
- * @param {string} filename Required if body is a file!!
637
- */
638
- sendAdvancedButtons(to: ChatId, body: string | LocationButtonBody, buttons: AdvancedButton[], text: string, footer: string, filename: string): Promise<boolean | MessageId>;
639
- /**
640
- * Send a banner image
641
- *
642
- * Note this is a bit of hack on top of a location message. During testing it is shown to not work on iPhones.
643
- *
644
- * @param {ChatId} to
645
- * @param {Base64} base64 base64 encoded jpeg
646
- */
647
- sendBanner(to: ChatId, base64: Base64): Promise<boolean | MessageId>;
648
- /**
649
- *
650
- * @deprecated
651
- *
652
- * :::danger
653
- *
654
- * It is not currently possible to send a listmessage to a group chat. This is a WA limitation.
655
- * Please DO NOT get a license solely for access to list messages in group chats.
656
- *
657
- * LIST MESSAGES ARE DEPRECATED TILL FURTHER NOTICE
658
- *
659
- * :::
660
- *
661
- * Send a list message. This will not work when being sent from business accounts!
662
- *
663
- * @param {ChatId} to
664
- * @param {Section[]} sections The Sections of rows for the list message
665
- * @param {string} title The title of the list message
666
- * @param {string} description The description of the list message
667
- * @param {string} actionText The action text of the list message
668
- */
669
- sendListMessage(to: ChatId, sections: Section[], title: string, description: string, actionText: string): Promise<boolean | MessageId>;
670
- /**
671
- * Sends a reply to given chat that includes mentions, replying to the provided replyMessageId.
672
- * In order to use this method correctly you will need to send the text like this:
673
- * "@4474747474747 how are you?"
674
- * Basically, add a @ symbol before the number of the contact you want to mention.
675
- * @param to chat id: `xxxxx@c.us`
676
- * @param content text message
677
- * @param replyMessageId id of message to reply to
678
- * @param hideTags Removes all tags within the message
679
- * @param mentions You can optionally add an array of contact IDs to tag only specific people
680
- */
681
- sendReplyWithMentions(to: ChatId, content: Content, replyMessageId: MessageId, hideTags?: boolean, mentions?: ContactId[]): Promise<boolean | MessageId>;
682
- /**
683
- * {@license:insiders@}
684
- *
685
- * Tags everyone in the group with a message
686
- *
687
- * @param groupId group chat id: `xxxxx@g.us`
688
- * @param content text message to add under all of the tags
689
- * @param hideTags Removes all tags within the message
690
- * @param formatting The formatting of the tags. Use @mention to indicate the actual tag. @default `@mention `
691
- * @param messageBeforeTags set to `true` to show the message before all of the tags
692
- * @returns `Promise<MessageId>`
693
- */
694
- tagEveryone(groupId: GroupChatId, content: Content, hideTags?: boolean, formatting?: string, messageBeforeTags?: boolean): Promise<boolean | MessageId>;
695
- /**
696
- * Sends a link to a chat that includes a link preview.
697
- * @param thumb The base 64 data of the image you want to use as the thunbnail. This should be no more than 200x200px. Note: Dont need data url on this param
698
- * @param url The link you want to send
699
- * @param title The title of the link
700
- * @param description The long description of the link preview
701
- * @param text The text you want to inslude in the message section. THIS HAS TO INCLUDE THE URL otherwise the url will be prepended to the text automatically.
702
- * @param chatId The chat you want to send this message to.
703
- * @param quotedMsgId [INSIDERS] Send this link preview message in response to a given quoted message
704
- * @param customSize [INSIDERS] Anchor the size of the thumbnail
705
- */
706
- sendMessageWithThumb(thumb: string, url: string, title: string, description: string, text: Content, chatId: ChatId, quotedMsgId?: MessageId, customSize?: {
707
- height: number;
708
- width: number;
709
- }): Promise<MessageId | boolean>;
710
- /**
711
- * Note: `address` and `url` are parameters available to insiders only.
712
- *
713
- * Sends a location message to given chat
714
- * @param to chat id: `xxxxx@c.us`
715
- * @param lat latitude: '51.5074'
716
- * @param lng longitude: '0.1278'
717
- * @param loc location text: 'LONDON!'
718
- * @param address address text: '1 Regents Park!'
719
- * @param url address text link: 'https://example.com'
720
- */
721
- sendLocation(to: ChatId, lat: string, lng: string, loc: string, address?: string, url?: string): Promise<boolean | MessageId>;
722
- /**
723
- * Get the generated user agent, this is so you can send it to the decryption module.
724
- * @returns String useragent of wa-web session
725
- */
726
- getGeneratedUserAgent(userA?: string): Promise<string>;
727
- /**
728
- * Decrypts a media message.
729
- * @param message This can be the serialized [[MessageId]] or the whole [[Message]] object. It is advised to just use the serialized message ID.
730
- * @returns `Promise<[[DataURL]]>`
731
- */
732
- decryptMedia(message: Message | MessageId): Promise<DataURL>;
733
- /**
734
- * Sends a image to given chat, with caption or not, using base64
735
- * @param to chat id `xxxxx@c.us`
736
- * @param file DataURL data:image/xxx;base64,xxx or the RELATIVE (should start with `./` or `../`) path of the file you want to send. With the latest version, you can now set this to a normal URL (for example [GET] `https://file-examples-com.github.io/uploads/2017/10/file_example_JPG_2500kB.jpg`).
737
- * @param filename string xxxxx
738
- * @param caption string xxxxx
739
- * @param waitForKey boolean default: false set this to true if you want to wait for the id of the message. By default this is set to false as it will take a few seconds to retrieve to the key of the message and this waiting may not be desirable for the majority of users.
740
- * @param hideTags boolean default: false [INSIDERS] set this to try silent tag someone in the caption
741
- * @returns `Promise <boolean | string>` This will either return true or the id of the message. It will return true after 10 seconds even if waitForId is true
742
- */
743
- sendImage(to: ChatId, file: AdvancedFile, filename: string, caption: Content, quotedMsgId?: MessageId, waitForId?: boolean, ptt?: boolean, withoutPreview?: boolean, hideTags?: boolean, viewOnce?: boolean, requestConfig?: any): Promise<MessageId | boolean>;
744
- /**
745
- * Automatically sends a youtube link with the auto generated link preview. You can also add a custom message.
746
- * @param chatId
747
- * @param url string A youtube link.
748
- * @param text string Custom text as body of the message, this needs to include the link or it will be appended after the link.
749
- * @param thumbnail string Base64 of the jpeg/png which will be used to override the automatically generated thumbnail.
750
- * @param quotedMsgId [INSIDERS] Send this link preview message in response to a given quoted message
751
- * @param customSize [INSIDERS] Anchor the size of the thumbnail
752
- */
753
- sendYoutubeLink(to: ChatId, url: string, text?: Content, thumbnail?: Base64, quotedMsgId?: MessageId, customSize?: {
754
- height: number;
755
- width: number;
756
- }): Promise<boolean | MessageId>;
757
- /**
758
- * Automatically sends a link with the auto generated link preview. You can also add a custom message.
759
- * @param chatId
760
- * @param url string A link.
761
- * @param text string Custom text as body of the message, this needs to include the link or it will be appended after the link.
762
- * @param thumbnail Base64 of the jpeg/png which will be used to override the automatically generated thumbnail.
763
- * @param quotedMsgId [INSIDERS] Send this link preview message in response to a given quoted message
764
- * @param customSize [INSIDERS] Anchor the size of the thumbnail
765
- */
766
- sendLinkWithAutoPreview(to: ChatId, url: string, text?: Content, thumbnail?: Base64, quotedMsgId?: MessageId, customSize?: {
767
- height: number;
768
- width: number;
769
- }): Promise<boolean | MessageId>;
770
- /**
771
- *
772
- * Sends a reply to a given message. Please note, you need to have at least sent one normal message to a contact in order for this to work properly.
773
- *
774
- * @param to string chatid
775
- * @param content string reply text
776
- * @param quotedMsgId string the msg id to reply to.
777
- * @param sendSeen boolean If set to true, the chat will 'blue tick' all messages before sending the reply
778
- * @returns `Promise<MessageId | false>` false if didn't work, otherwise returns message id.
779
- */
780
- reply(to: ChatId, content: Content, quotedMsgId: MessageId, sendSeen?: boolean): Promise<boolean | MessageId>;
781
- /**
782
- * {@license:insiders@}
783
- *
784
- * Check if a recipient has read receipts on.
785
- *
786
- * This will only work if you have chats sent back and forth between you and the contact 1-1.
787
- *
788
- * @param contactId The Id of the contact with which you have an existing conversation with messages already.
789
- * @returns `Promise<string | boolean>` true or false or a string with an explaintaion of why it wasn't able to determine the read receipts.
790
- *
791
- */
792
- checkReadReceipts(contactId: ContactId): Promise<string | boolean>;
793
- /**
794
- * Sends a file to given chat, with caption or not, using base64. This is exactly the same as sendImage
795
- *
796
- * Please note that any file that resolves to mime-type `octet-stream` will, by default, resolve to an MP4 file.
797
- *
798
- * If you want a specific filetype, then explcitly select the correct mime-type from https://www.iana.org/assignments/media-types/media-types.xhtml
799
- *
800
- *
801
- * @param to chat id `xxxxx@c.us`
802
- * @param file DataURL data:image/xxx;base64,xxx or the RELATIVE (should start with `./` or `../`) path of the file you want to send. With the latest version, you can now set this to a normal URL (for example [GET] `https://file-examples-com.github.io/uploads/2017/10/file_example_JPG_2500kB.jpg`).
803
- * @param filename string xxxxx
804
- * @param caption string xxxxx With an [INSIDERS LICENSE-KEY](https://gum.co/open-wa?tier=Insiders%20Program) you can also tag people in groups with `@[number]`. For example if you want to mention the user with the number `44771234567`, just add `@44771234567` in the caption.
805
- * @param quotedMsgId string true_0000000000@c.us_JHB2HB23HJ4B234HJB to send as a reply to a message
806
- * @param waitForId boolean default: false set this to true if you want to wait for the id of the message. By default this is set to false as it will take a few seconds to retrieve to the key of the message and this waiting may not be desirable for the majority of users.
807
- * @param ptt boolean default: false set this to true if you want to send the file as a push to talk file.
808
- * @param withoutPreview boolean default: false set this to true if you want to send the file without a preview (i.e as a file). This is useful for preventing auto downloads on recipient devices.
809
- * @param hideTags boolean default: false [INSIDERS] set this to try silent tag someone in the caption
810
- * @returns `Promise <boolean | MessageId>` This will either return true or the id of the message. It will return true after 10 seconds even if waitForId is true
811
- */
812
- sendFile(to: ChatId, file: AdvancedFile, filename: string, caption: Content, quotedMsgId?: MessageId, waitForId?: boolean, ptt?: boolean, withoutPreview?: boolean, hideTags?: boolean, viewOnce?: boolean, requestConfig?: any): Promise<MessageId | boolean>;
813
- /**
814
- * {@license:insiders@}
815
- *
816
- * Checks whether or not the group id provided is known to be unsafe by the contributors of the library.
817
- * @param groupChatId The group chat you want to deteremine is unsafe
818
- * @returns `Promise <boolean | string>` This will either return a boolean indiciating whether this group chat id is considered unsafe or an error message as a string
819
- */
820
- isGroupIdUnsafe(groupChatId: GroupChatId): Promise<string | boolean>;
821
- /**
822
- * Attempts to send a file as a voice note. Useful if you want to send an mp3 file.
823
- * @param to chat id `xxxxx@c.us`
824
- * @param file base64 data:image/xxx;base64,xxx or the path of the file you want to send.
825
- * @param quotedMsgId string true_0000000000@c.us_JHB2HB23HJ4B234HJB to send as a reply to a message
826
- * @returns `Promise <boolean | string>` This will either return true or the id of the message. It will return true after 10 seconds even if waitForId is true
827
- */
828
- sendPtt(to: ChatId, file: AdvancedFile, quotedMsgId?: MessageId): Promise<MessageId>;
829
- /**
830
- * Send an audio file with the default audio player (not PTT/voice message)
831
- * @param to chat id `xxxxx@c.us`
832
- * @param base64 base64 data:image/xxx;base64,xxx or the path of the file you want to send.
833
- * @param quotedMsgId string true_0000000000@c.us_JHB2HB23HJ4B234HJB to send as a reply to a message
834
- */
835
- sendAudio(to: ChatId, file: AdvancedFile, quotedMsgId?: MessageId): Promise<MessageId>;
836
- /**
837
- * Send a poll to a group chat
838
- * @param to chat id - a group chat is required
839
- * @param name the name of the poll
840
- * @param options an array of poll options
841
- * @param quotedMsgId A message to quote when sending the poll
842
- * @param allowMultiSelect Whether or not to allow multiple selections. default false
843
- */
844
- sendPoll(to: GroupChatId, name: string, options: string[], quotedMsgId?: MessageId, allowMultiSelect?: boolean): Promise<MessageId>;
845
- /**
846
- * Sends a video to given chat as a gif, with caption or not, using base64
847
- * @param to chat id `xxxxx@c.us`
848
- * @param file DataURL data:image/xxx;base64,xxx or the RELATIVE (should start with `./` or `../`) path of the file you want to send. With the latest version, you can now set this to a normal URL (for example [GET] `https://file-examples-com.github.io/uploads/2017/10/file_example_JPG_2500kB.jpg`).
849
- * @param filename string xxxxx
850
- * @param caption string xxxxx
851
- * @param quotedMsgId string true_0000000000@c.us_JHB2HB23HJ4B234HJB to send as a reply to a message
852
- * @param requestConfig {} By default the request is a get request, however you can override that and many other options by sending this parameter. You can read more about this parameter here: https://github.com/axios/axios#request-config
853
- */
854
- sendVideoAsGif(to: ChatId, file: AdvancedFile, filename: string, caption: Content, quotedMsgId?: MessageId, requestConfig?: AxiosRequestConfig): Promise<MessageId>;
855
- /**
856
- * Sends a video to given chat as a gif by using a giphy link, with caption or not, using base64
857
- * @param to chat id `xxxxx@c.us`
858
- * @param giphyMediaUrl string https://media.giphy.com/media/oYtVHSxngR3lC/giphy.gif => https://i.giphy.com/media/oYtVHSxngR3lC/200w.mp4
859
- * @param caption string xxxxx
860
- */
861
- sendGiphy(to: ChatId, giphyMediaUrl: string, caption: Content): Promise<MessageId>;
862
- /**
863
- * Sends a file by Url or custom options
864
- * @param to chat id `xxxxx@c.us`
865
- * @param url string https://i.giphy.com/media/oYtVHSxngR3lC/200w.mp4
866
- * @param filename string 'video.mp4'
867
- * @param caption string xxxxx
868
- * @param quotedMsgId string true_0000000000@c.us_JHB2HB23HJ4B234HJB to send as a reply to a message
869
- * @param requestConfig {} By default the request is a get request, however you can override that and many other options by sending this parameter. You can read more about this parameter here: https://github.com/axios/axios#request-config
870
- * @param waitForId boolean default: false set this to true if you want to wait for the id of the message. By default this is set to false as it will take a few seconds to retrieve to the key of the message and this waiting may not be desirable for the majority of users.
871
- * @param ptt boolean default: false set this to true if you want to send the file as a push to talk file.
872
- * @param withoutPreview boolean default: false set this to true if you want to send the file without a preview (i.e as a file). This is useful for preventing auto downloads on recipient devices.
873
- */
874
- sendFileFromUrl(to: ChatId, url: string, filename: string, caption: Content, quotedMsgId?: MessageId, requestConfig?: AxiosRequestConfig, waitForId?: boolean, ptt?: boolean, withoutPreview?: boolean, hideTags?: boolean, viewOnce?: boolean): Promise<MessageId | boolean>;
875
- /**
876
- * Returns an object with all of your host device details
877
- */
878
- getMe(): Promise<any>;
879
- /**
880
- * Returns an object with properties of internal features and boolean values that represent if the respective feature is enabled or not.
881
- */
882
- getFeatures(): Promise<any>;
883
- /**
884
- * Returns a PNG DataURL screenshot of the session
885
- * @param chatId Chat ID to open before taking a snapshot
886
- * @param width Width of the viewport for the snapshot. Height also required if you want to resize.
887
- * @param height Height of the viewport for the snapshot. Width also required if you want to resize.
888
- * @returns `Promise<DataURL>`
889
- */
890
- getSnapshot(chatId?: ChatId, width?: number, height?: number): Promise<DataURL>;
891
- /**
892
- * Returns some metrics of the session/page.
893
- * @returns `Promise<any>`
894
- */
895
- metrics(): Promise<any>;
896
- /**
897
- * Returns an array of group ids where the host account is admin
898
- */
899
- iAmAdmin(): Promise<GroupChatId[]>;
900
- /**
901
- * Returns an array of group ids where the host account has been kicked
902
- */
903
- getKickedGroups(): Promise<GroupChatId[]>;
904
- /**
905
- * Syncs contacts with phone. This promise does not resolve so it will instantly return true.
906
- */
907
- syncContacts(): Promise<boolean>;
908
- /**
909
- * Easily get the amount of messages loaded up in the session. This will allow you to determine when to clear chats/cache.
910
- */
911
- getAmountOfLoadedMessages(): Promise<number>;
912
- /**
913
- * Find any product listings of the given number. Use this to query a catalog
914
- *
915
- * @param id id of business profile (i.e the number with @c.us)
916
- * @returns None
917
- */
918
- getBusinessProfilesProducts(id: ContactId): Promise<any>;
919
- /**
920
- * Get the business info of a given contact id
921
- *
922
- * @param id id of business profile (i.e the number with @c.us)
923
- * @returns None
924
- */
925
- getBusinessProfile(id: ContactId): Promise<BusinessProfile>;
926
- /**
927
- * Sends product with image to chat
928
- * @param imgBase64 Base64 image data
929
- * @param chatid string the id of the chat that you want to send this product to
930
- * @param caption string the caption you want to add to this message
931
- * @param bizNumber string the @c.us number of the business account from which you want to grab the product
932
- * @param productId string the id of the product within the main catalog of the aforementioned business
933
- * @returns
934
- */
935
- sendImageWithProduct(to: ChatId, image: Base64, caption: Content, bizNumber: ContactId, productId: string): Promise<boolean | MessageId>;
936
- /**
937
- * @deprecated
938
- * Feature Currently only available with Premium License accounts.
939
- *
940
- * Send a custom product to a chat. Please see [[CustomProduct]] for details.
941
- *
942
- * Caveats:
943
- * - URL will not work (unable to click), you will have to send another message with the URL.
944
- * - Recipient will see a thin banner under picture that says "Something went wrong"
945
- * - This will only work if you have at least 1 product already in your catalog
946
- * - Only works on Business accounts
947
- */
948
- sendCustomProduct(to: ChatId, image: DataURL, productData: CustomProduct): Promise<MessageId | boolean>;
949
- /**
950
- * Sends contact card to given chat id. You can use this to send multiple contacts but they will show up as multiple single-contact messages.
951
- * @param {string} to 'xxxx@c.us'
952
- * @param {string|array} contact 'xxxx@c.us' | ['xxxx@c.us', 'yyyy@c.us', ...]
953
- */
954
- sendContact(to: ChatId, contactId: ContactId | ContactId[]): Promise<MessageId | boolean>;
955
- /**
956
- *
957
- * {@license:insiders@}
958
- *
959
- * Sends multiple contacts as a single message
960
- *
961
- * @param to 'xxxx@c.us'
962
- * @param contact ['xxxx@c.us', 'yyyy@c.us', ...]
963
- */
964
- sendMultipleContacts(to: ChatId, contactIds: ContactId[]): Promise<MessageId | boolean>;
965
- /**
966
- * Simulate '...typing' in chat
967
- * @param {string} to 'xxxx@c.us'
968
- * @param {boolean} on turn on similated typing, false to turn it off you need to manually turn this off.
969
- */
970
- simulateTyping(to: ChatId, on: boolean): Promise<boolean>;
971
- /**
972
- * Simulate '...recording' in chat
973
- * @param {string} to 'xxxx@c.us'
974
- * @param {boolean} on turn on similated recording, false to turn it off you need to manually turn this off.
975
- */
976
- simulateRecording(to: ChatId, on: boolean): Promise<boolean>;
977
- /**
978
- * @param id The id of the conversation
979
- * @param archive boolean true => archive, false => unarchive
980
- * @return boolean true: worked, false: didnt work (probably already in desired state)
981
- */
982
- archiveChat(id: ChatId, archive: boolean): Promise<boolean>;
983
- /**
984
- * Pin/Unpin chats
985
- *
986
- * @param id The id of the conversation
987
- * @param pin boolean true => pin, false => unpin
988
- * @return boolean true: worked
989
- */
990
- pinChat(id: ChatId, pin: boolean): Promise<boolean>;
991
- /**
992
- * Pin/Unpin message
993
- *
994
- * @param id The id of the message
995
- * @param pin boolean true => pin, false => unpin
996
- * @param pinDuration The length of time to pin the message. Default `ThirtyDays`
997
- * @return boolean true: worked
998
- */
999
- pinMessage(id: MessageId, pin: boolean, pinDuration?: MessagePinDuration): Promise<boolean>;
1000
- /**
1001
- * Keep a message inside an ephemeral chat
1002
- *
1003
- * @param id The id of the message
1004
- * @return boolean true: worked
1005
- */
1006
- keepMessage(id: MessageId, keep: boolean): Promise<boolean>;
1007
- /**
1008
- *
1009
- * {@license:insiders@}
1010
- *
1011
- * Mutes a conversation for a given duration. If already muted, this will update the muted duration. Mute durations are relative from when the method is called.
1012
- * @param chatId The id of the conversation you want to mute
1013
- * @param muteDuration ChatMuteDuration enum of the time you want this chat to be muted for.
1014
- * @return boolean true: worked or error code or message
1015
- */
1016
- muteChat(chatId: ChatId, muteDuration: ChatMuteDuration): Promise<boolean | string | number>;
1017
- /**
1018
- * Checks if a chat is muted
1019
- * @param chatId The id of the chat you want to check
1020
- * @returns boolean. `false` if the chat does not exist.
1021
- */
1022
- isChatMuted(chatId: ChatId): Promise<boolean>;
1023
- /**
1024
- *
1025
- * {@license:insiders@}
1026
- *
1027
- * Unmutes a conversation.
1028
- * @param id The id of the conversation you want to mute
1029
- * @return boolean true: worked or error code or message
1030
- */
1031
- unmuteChat(chatId: ChatId): Promise<boolean | string | number>;
1032
- /**
1033
- * Forward an array of messages to a specific chat using the message ids or Objects
1034
- *
1035
- * @param to '000000000000@c.us'
1036
- * @param messages this can be any mixture of message ids or message objects
1037
- * @param skipMyMessages This indicates whether or not to skip your own messages from the array
1038
- */
1039
- forwardMessages(to: ChatId, messages: MessageId | MessageId[], skipMyMessages: boolean): Promise<boolean | MessageId[]>;
1040
- /**
1041
- * Ghost forwarding is like a normal forward but as if it were sent from the host phone [i.e it doesn't show up as forwarded.]
1042
- * Any potential abuse of this method will see it become paywalled.
1043
- * @param to: Chat id to forward the message to
1044
- * @param messageId: message id of the message to forward. Please note that if it is not loaded, this will return false - even if it exists.
1045
- * @returns `Promise<MessageId | boolean>`
1046
- */
1047
- ghostForward(to: ChatId, messageId: MessageId): Promise<MessageId | boolean>;
1048
- /**
1049
- * Retrieves all contacts
1050
- * @returns array of [Contact]
1051
- */
1052
- getAllContacts(): Promise<Contact[]>;
1053
- getWAVersion(): Promise<string>;
1054
- /**
1055
- * Generate a pre-filled github issue link to easily report a bug
1056
- */
1057
- getIssueLink(): Promise<string>;
1058
- /**
1059
- * Retrieves if the phone is online. Please note that this may not be real time.
1060
- * @returns Boolean
1061
- */
1062
- isConnected(): Promise<boolean>;
1063
- /**
1064
- * Logs out from the session.
1065
- * @param preserveSessionData skip session.data.json file invalidation
1066
- * Please be careful when using this as it can exit the whole process depending on your config
1067
- */
1068
- logout(preserveSessionData?: boolean): Promise<boolean>;
1069
- /**
1070
- * @deprecated No longer works due to multi-device changes
1071
- * Retrieves Battery Level
1072
- * @returns Number
1073
- */
1074
- getBatteryLevel(): Promise<number>;
1075
- /**
1076
- * Retrieves whether or not phone is plugged in (i.e on charge)
1077
- * @returns Number
1078
- */
1079
- getIsPlugged(): Promise<boolean>;
1080
- /**
1081
- * Retrieves the host device number. Use this number when registering for a license key
1082
- * @returns Number
1083
- */
1084
- getHostNumber(): Promise<string>;
1085
- /**
1086
- * Returns the the type of license key used by the session.
1087
- * @returns
1088
- */
1089
- getLicenseType(): Promise<LicenseType | false>;
1090
- /**
1091
- * The EASY API uses this string to secure a subdomain on the openwa public tunnel service.
1092
- * @returns
1093
- */
1094
- getTunnelCode(): Promise<string>;
1095
- /**
1096
- * Get an array of chatIds with their respective last message's timestamp.
1097
- *
1098
- * This is useful for determining what chats are old/stale and need to be deleted.
1099
- */
1100
- getLastMsgTimestamps(): Promise<{
1101
- id: ChatId;
1102
- /**
1103
- * Epoch timestamp (no need to x 1000), works with new Date(t)
1104
- */
1105
- t: number;
1106
- }[]>;
1107
- /**
1108
- * Retrieves all chats
1109
- * @returns array of [Chat]
1110
- */
1111
- getAllChats(withNewMessageOnly?: boolean): Promise<Chat[]>;
1112
- /**
1113
- * retrieves all Chat Ids
1114
- * @returns array of [ChatId]
1115
- */
1116
- getAllChatIds(): Promise<ChatId[]>;
1117
- /**
1118
- * retrieves an array of IDs of accounts blocked by the host account.
1119
- * @returns `Promise<ChatId[]>`
1120
- */
1121
- getBlockedIds(): Promise<ChatId[]>;
1122
- /**
1123
- * @deprecated
1124
- *
1125
- * Retrieves all chats with messages
1126
- *
1127
- * Please use `getAllUnreadMessages` instead of this to see all messages indicated by the green dots in the chat.
1128
- *
1129
- * @returns array of [Chat]
1130
- */
1131
- getAllChatsWithMessages(withNewMessageOnly?: boolean): Promise<Chat[]>;
1132
- /**
1133
- * Returns a properly formatted array of messages from to send to the openai api
1134
- *
1135
- * @param last The amount of previous messages to retrieve. Defaults to 10
1136
- * @returns
1137
- */
1138
- getGptArray(chatId: ChatId, last?: number): Promise<{
1139
- role: "user" | "assistant";
1140
- content: string;
1141
- }[]>;
1142
- /**
1143
- * Retrieve all groups
1144
- * @returns array of groups
1145
- */
1146
- getAllGroups(withNewMessagesOnly?: boolean): Promise<Chat[]>;
1147
- /**
1148
- * Retrieve all commmunity Ids
1149
- * @returns array of group ids
1150
- */
1151
- getAllCommunities(): Promise<GroupId[]>;
1152
- /**
1153
- * Retrieves group members as [Id] objects
1154
- * @param groupId group id
1155
- */
1156
- getGroupMembersId(groupId: GroupChatId): Promise<ContactId[]>;
1157
- /**
1158
- * Returns the title and description of a given group id.
1159
- * @param groupId group id
1160
- */
1161
- getGroupInfo(groupId: GroupChatId): Promise<any>;
1162
- /**
1163
- * Returns the community metadata. Like group metadata but with a `subGroups` property which is the group metadata of the community subgroups.
1164
- * @param communityId community id
1165
- */
1166
- getCommunityInfo(communityId: GroupChatId): Promise<GroupMetadata & {
1167
- subGroups: GroupMetadata[];
1168
- }>;
1169
- /**
1170
- *
1171
- * Accepts a request from a recipient to join a group. Takes the message ID of the request message.
1172
- *
1173
- * @param {string} messageId
1174
- */
1175
- acceptGroupJoinRequest(messageId: MessageId): Promise<boolean>;
1176
- /**
1177
- * Retrieves community members Ids
1178
- * @param communityId community id
1179
- */
1180
- getCommunityParticipantIds(communityId: GroupChatId): Promise<{
1181
- id: GroupChatId;
1182
- participants: ContactId[];
1183
- subgroup: boolean;
1184
- }[]>;
1185
- /**
1186
- * Retrieves community admin Ids
1187
- * @param communityId community id
1188
- */
1189
- getCommunityAdminIds(communityId: GroupChatId): Promise<{
1190
- id: GroupChatId;
1191
- admins: ContactId[];
1192
- subgroup: boolean;
1193
- }[]>;
1194
- /**
1195
- * Retrieves community members as Contact objects
1196
- * @param communityId community id
1197
- */
1198
- getCommunityParticipants(communityId: GroupChatId): Promise<{
1199
- id: GroupChatId;
1200
- participants: Contact[];
1201
- subgroup: boolean;
1202
- }[]>;
1203
- /**
1204
- * Retrieves community admins as Contact objects
1205
- * @param communityId community id
1206
- */
1207
- getCommunityAdmins(communityId: GroupChatId): Promise<{
1208
- id: GroupChatId;
1209
- admins: Contact[];
1210
- subgroup: boolean;
1211
- }[]>;
1212
- /** Joins a group via the invite link, code, or message
1213
- * @param link This param is the string which includes the invite link or code. The following work:
1214
- * - Follow this link to join my WA group: https://chat.whatsapp.com/DHTGJUfFJAV9MxOpZO1fBZ
1215
- * - https://chat.whatsapp.com/DHTGJUfFJAV9MxOpZO1fBZ
1216
- * - DHTGJUfFJAV9MxOpZO1fBZ
1217
- *
1218
- * If you have been removed from the group previously, it will return `401`
1219
- *
1220
- * @param returnChatObj boolean When this is set to true and if the group was joined successfully, it will return a serialzed Chat object which includes group information and metadata. This is useful when you want to immediately do something with group metadata.
1221
- *
1222
- *
1223
- * @returns `Promise<string | boolean | number>` Either false if it didn't work, or the group id.
1224
- */
1225
- joinGroupViaLink(link: string, returnChatObj?: boolean): Promise<string | boolean | number | Chat>;
1226
- /**
1227
- * Block contact
1228
- * @param {string} id '000000000000@c.us'
1229
- */
1230
- contactBlock(id: ContactId): Promise<boolean>;
1231
- /**
1232
- * {@license:restricted@}
1233
- *
1234
- * Report a contact for spam, block them and attempt to clear chat.
1235
- *
1236
- * @param {string} id '000000000000@c.us'
1237
- */
1238
- reportSpam(id: ContactId | ChatId): Promise<boolean>;
1239
- /**
1240
- * Unblock contact
1241
- * @param {string} id '000000000000@c.us'
1242
- */
1243
- contactUnblock(id: ContactId): Promise<boolean>;
1244
- /**
1245
- * Removes the host device from the group
1246
- * @param groupId group id
1247
- */
1248
- leaveGroup(groupId: GroupChatId): Promise<boolean>;
1249
- /**
1250
- * Extracts vcards from a message.This works on messages of typ `vcard` or `multi_vcard`
1251
- * @param msgId string id of the message to extract the vcards from
1252
- * @returns [vcard]
1253
- * ```
1254
- * [
1255
- * {
1256
- * displayName:"Contact name",
1257
- * vcard: "loong vcard string"
1258
- * }
1259
- * ]
1260
- * ```
1261
- * or false if no valid vcards found.
1262
- *
1263
- * Please use [vcf](https://www.npmjs.com/package/vcf) to convert a vcard string into a json object
1264
- */
1265
- getVCards(msgId: MessageId): Promise<string[]>;
1266
- /**
1267
- * Returns group members [Contact] objects
1268
- * @param groupId
1269
- */
1270
- getGroupMembers(groupId: GroupChatId): Promise<Contact[]>;
1271
- /**
1272
- * Retrieves contact detail object of given contact id
1273
- * @param contactId
1274
- * @returns contact detial as promise
1275
- */
1276
- getContact(contactId: ContactId): Promise<Contact>;
1277
- /**
1278
- * Retrieves chat object of given contact id
1279
- * @param contactId
1280
- * @returns contact detial as promise
1281
- */
1282
- getChatById(contactId: ContactId): Promise<Chat>;
1283
- /**
1284
- * Retrieves message object of given message id
1285
- * @param messageId
1286
- * @returns message object
1287
- */
1288
- getMessageById(messageId: MessageId): Promise<Message>;
1289
- /**
1290
- * {@license:insiders@}
1291
- *
1292
- * Get the detailed message info for a group message sent out by the host account.
1293
- * @param messageId The message Id
1294
- */
1295
- getMessageInfo(messageId: MessageId): Promise<MessageInfo>;
1296
- /**
1297
- * {@license:insiders@}
1298
- *
1299
- * Retrieves an order object
1300
- * @param messageId or OrderId
1301
- * @returns order object
1302
- */
1303
- getOrder(id: MessageId | string): Promise<Order>;
1304
- /**
1305
- * {@license:insiders@}
1306
- *
1307
- * Add a product to your catalog
1308
- *
1309
- * @param {string} name The name of the product
1310
- * @param {number} price The price of the product
1311
- * @param {string} currency The 3-letter currenct code for the product
1312
- * @param {string[]} images An array of dataurl or base64 strings of product images, the first image will be used as the main image. At least one image is required.
1313
- * @param {string} description optional, the description of the product
1314
- * @param {string} url The url of the product for more information
1315
- * @param {string} internalId The internal/backoffice id of the product
1316
- * @param {boolean} isHidden Whether or not the product is shown publicly in your catalog
1317
- * @returns product object
1318
- */
1319
- createNewProduct(name: string, price: number, currency: string, images: string[], description: string, url?: string, internalId?: string, isHidden?: boolean): Promise<Product>;
1320
- /**
1321
- * {@license:insiders@}
1322
- *
1323
- * Edit a product in your catalog
1324
- *
1325
- * @param {string} productId The catalog ID of the product
1326
- * @param {string} name The name of the product
1327
- * @param {number} price The price of the product
1328
- * @param {string} currency The 3-letter currenct code for the product
1329
- * @param {string[]} images An array of dataurl or base64 strings of product images, the first image will be used as the main image. At least one image is required.
1330
- * @param {string} description optional, the description of the product
1331
- * @param {string} url The url of the product for more information
1332
- * @param {string} internalId The internal/backoffice id of the product
1333
- * @param {boolean} isHidden Whether or not the product is shown publicly in your catalog
1334
- * @returns product object
1335
- */
1336
- editProduct(productId: string, name?: string, price?: number, currency?: string, images?: DataURL[], description?: string, url?: string, internalId?: string, isHidden?: boolean): Promise<Product>;
1337
- /**
1338
- * {@license:insiders@}
1339
- *
1340
- * Send a product to a chat
1341
- *
1342
- * @param {string} chatId The chatId
1343
- * @param {string} productId The id of the product
1344
- * @returns MessageID
1345
- */
1346
- sendProduct(chatId: ChatId, productId: string): Promise<MessageId>;
1347
- /**
1348
- *
1349
- * Remove a product from the host account's catalog
1350
- *
1351
- * @param {string} productId The id of the product
1352
- * @returns boolean
1353
- */
1354
- removeProduct(productId: string): Promise<boolean>;
1355
- /**
1356
- * Retrieves the last message sent by the host account in any given chat or globally.
1357
- * @param chatId This is optional. If no chat Id is set then the last message sent by the host account will be returned.
1358
- * @returns message object or `undefined` if the host account's last message could not be found.
1359
- */
1360
- getMyLastMessage(chatId?: ChatId): Promise<Message | undefined>;
1361
- /**
1362
- * Retrieves the starred messages in a given chat
1363
- * @param chatId Chat ID to filter starred messages by
1364
- * @returns message object
1365
- */
1366
- getStarredMessages(chatId?: ChatId): Promise<Message[]>;
1367
- /**
1368
- * Star a message
1369
- * @param messageId Message ID of the message you want to star
1370
- * @returns `true`
1371
- */
1372
- starMessage(messageId: MessageId): Promise<boolean>;
1373
- /**
1374
- * Unstar a message
1375
- * @param messageId Message ID of the message you want to unstar
1376
- * @returns `true`
1377
- */
1378
- unstarMessage(messageId: MessageId): Promise<boolean>;
1379
- /**
1380
- * React to a message
1381
- * @param messageId Message ID of the message you want to react to
1382
- * @param emoji 1 single emoji to add to the message as a reacion
1383
- * @returns boolean
1384
- */
1385
- react(messageId: MessageId, emoji: string): Promise<boolean>;
1386
- /**
1387
- * @deprecated
1388
- *
1389
- * Retrieves a message object which results in a valid sticker instead of a blank one. This also works with animated stickers.
1390
- *
1391
- * If you run this without a valid insiders key, it will return false and cause an error upon decryption.
1392
- *
1393
- * @param messageId The message ID `message.id`
1394
- * @returns message object OR `false`
1395
- */
1396
- getStickerDecryptable(messageId: MessageId): Promise<Message | false>;
1397
- /**
1398
- *
1399
- * {@license:insiders@}
1400
- *
1401
- * If a file is old enough, it will 404 if you try to decrypt it. This will allow you to force the host account to re upload the file and return a decryptable message.
1402
- *
1403
- * if you run this without a valid insiders key, it will return false and cause an error upon decryption.
1404
- *
1405
- * @param messageId
1406
- * @returns [[Message]] OR `false`
1407
- */
1408
- forceStaleMediaUpdate(messageId: MessageId): Promise<Message | false>;
1409
- /**
1410
- * Retrieves chat object of given contact id
1411
- * @param contactId
1412
- * @returns contact detial as promise
1413
- */
1414
- getChat(contactId: ContactId): Promise<Chat>;
1415
- /**
1416
- * {@license:insiders@}
1417
- *
1418
- * Retrieves the groups that you have in common with a contact
1419
- * @param contactId
1420
- */
1421
- getCommonGroups(contactId: ContactId): Promise<{
1422
- id: string;
1423
- title: string;
1424
- }[]>;
1425
- /**
1426
- * Retrieves the epoch timestamp of the time the contact was last seen. This will not work if:
1427
- * 1. They have set it so you cannot see their last seen via privacy settings.
1428
- * 2. You do not have an existing chat with the contact.
1429
- * 3. The chatId is for a group
1430
- * In both of those instances this method will return undefined.
1431
- * @param chatId The id of the chat.
1432
- * @returns number timestamp when chat was last online or undefined.
1433
- */
1434
- getLastSeen(chatId: ChatId): Promise<number | boolean>;
1435
- /**
1436
- * Retrieves chat picture
1437
- * @param chatId
1438
- * @returns Url of the chat picture or undefined if there is no picture for the chat.
1439
- */
1440
- getProfilePicFromServer(chatId: ChatId): Promise<string>;
1441
- /**
1442
- * Sets a chat status to seen. Marks all messages as ack: 3
1443
- * @param chatId chat id: `xxxxx@c.us`
1444
- */
1445
- sendSeen(chatId: ChatId): Promise<boolean>;
1446
- /**
1447
- * Runs sendSeen on all chats
1448
- */
1449
- markAllRead(): Promise<boolean>;
1450
- /**
1451
- * Sets a chat status to unread. May be useful to get host's attention
1452
- * @param chatId chat id: `xxxxx@c.us`
1453
- */
1454
- markAsUnread(chatId: ChatId): Promise<boolean>;
1455
- /**
1456
- * Checks if a chat contact is online. Not entirely sure if this works with groups.
1457
- *
1458
- * It will return `true` if the chat is `online`, `false` if the chat is `offline`, `PRIVATE` if the privacy settings of the contact do not allow you to see their status and `NO_CHAT` if you do not currently have a chat with that contact.
1459
- *
1460
- * @param chatId chat id: `xxxxx@c.us`
1461
- */
1462
- isChatOnline(chatId: ChatId): Promise<boolean | string>;
1463
- /**
1464
- * Load more messages in chat object from server. Use this in a while loop. This should return up to 50 messages at a time
1465
- * @param contactId
1466
- * @returns Message []
1467
- */
1468
- loadEarlierMessages(contactId: ContactId): Promise<Message[]>;
1469
- /**
1470
- * Get the status of a contact
1471
- * @param contactId to '000000000000@c.us'
1472
- */
1473
- getStatus(contactId: ContactId): Promise<{
1474
- id: string;
1475
- status: string;
1476
- }>;
1477
- /**
1478
- *
1479
- * {@license:insiders@}
1480
- *
1481
- * :::danger
1482
- *
1483
- * Buttons are broken for the foreseeable future. Please DO NOT get a license solely for access to buttons. They are no longer reliable due to recent changes at WA.
1484
- *
1485
- * :::
1486
- *
1487
- * Use a raw payload within your open-wa session
1488
- *
1489
- * @example
1490
- * If there is a code block, then both TypeDoc and VSCode will treat
1491
- * text outside of the code block as regular text.
1492
- *
1493
- * ```ts
1494
- * await B('44123456789@c.us', {
1495
- * test: 1
1496
- * })
1497
- * ```
1498
- * {@link loadAllEarlierMessages}
1499
- * @param chatId
1500
- * @param payload
1501
- * returns: MessageId
1502
- */
1503
- B(chatId: ChatId, payload: {
1504
- [k: string]: any;
1505
- }): Promise<MessageId>;
1506
- /**
1507
- * Load all messages in chat object from server.
1508
- * @param contactId
1509
- * @returns Message[]
1510
- */
1511
- loadAllEarlierMessages(contactId: ContactId): Promise<Message[]>;
1512
- /**
1513
- * Load all messages until a given timestamp in chat object from server.
1514
- * @param contactId
1515
- * @param timestamp in seconds
1516
- * @returns Message[]
1517
- */
1518
- loadEarlierMessagesTillDate(contactId: ContactId, timestamp: number): Promise<Message[]>;
1519
- /**
1520
- * Delete the conversation from your WA
1521
- * @param chatId
1522
- * @returns boolean
1523
- */
1524
- deleteChat(chatId: ChatId): Promise<boolean>;
1525
- /**
1526
- * Delete all messages from the chat.
1527
- * @param chatId
1528
- * @returns boolean
1529
- */
1530
- clearChat(chatId: ChatId): Promise<boolean>;
1531
- /**
1532
- * Retrieves an invite link for a group chat. returns false if chat is not a group.
1533
- * @param chatId
1534
- * @returns `Promise<string>`
1535
- */
1536
- getGroupInviteLink(chatId: ChatId): Promise<string>;
1537
- /**
1538
- * Get the details of a group through the invite link
1539
- * @param link This can be an invite link or invite code
1540
- * @returns
1541
- */
1542
- inviteInfo(link: string): Promise<any>;
1543
- /**
1544
- * Set/Unset a sticker as a fav.
1545
- * @param msgId The message Id related to the sticker you want to fav
1546
- * @param fav set this to true to fav a sticker, set it to false to remove the sticker from favorites. default true
1547
- * @returns favId The ID (filehash) of the fav sticker
1548
- */
1549
- favSticker(msgId: MessageId, fav?: boolean): Promise<string>;
1550
- /**
1551
- * Set/Unset a sticker as a fav.
1552
- * @param chatId The chat in which you want to send the sticker
1553
- * @param favId set this to true to favourite a sticker, set it to false to remove the sticker from favorites
1554
- * @returns MessageId of the sent sticker message
1555
- */
1556
- sendFavSticker(chatId: ChatId, favId: string): Promise<MessageId>;
1557
- /**
1558
- * Get an array of fav'ed stickers
1559
- */
1560
- getFavStickers(): Promise<Partial<Message>>;
1561
- /**
1562
- * Revokes the current invite link for a group chat. Any previous links will stop working
1563
- * @param chatId
1564
- * @returns `Promise<boolean>`
1565
- */
1566
- revokeGroupInviteLink(chatId: ChatId): Promise<boolean | string>;
1567
- /**
1568
- * Gets the contact IDs of members requesting approval to join the group
1569
- * @param groupChatId
1570
- * @returns `Promise<ContactId[]>`
1571
- */
1572
- getGroupApprovalRequests(groupChatId: GroupChatId): Promise<ContactId[]>;
1573
- /**
1574
- * Approves a group join request
1575
- * @param groupChatId The group chat id
1576
- * @param contactId The contact id of the person who is requesting to join the group
1577
- * @returns `Promise<boolean>`
1578
- */
1579
- approveGroupJoinRequest(groupChatId: GroupChatId, contactId: ContactId): Promise<boolean | string>;
1580
- /**
1581
- * Rejects a group join request
1582
- * @param groupChatId The group chat id
1583
- * @param contactId The contact id of the person who is requesting to join the group
1584
- * @returns `Promise<boolean>`
1585
- */
1586
- rejectGroupJoinRequest(groupChatId: GroupChatId, contactId: ContactId): Promise<boolean | string>;
1587
- /**
1588
- * Deletes message of given message id
1589
- * @param chatId The chat id from which to delete the message.
1590
- * @param messageId The specific message id of the message to be deleted
1591
- * @param onlyLocal If it should only delete locally (message remains on the other recipienct's phone). Defaults to false.
1592
- * @returns nothing
1593
- */
1594
- deleteMessage(chatId: ChatId, messageId: MessageId[] | MessageId, onlyLocal?: boolean): Promise<void>;
1595
- /**
1596
- * Checks if a number is a valid WA number
1597
- * @param contactId, you need to include the @c.us at the end.
1598
- */
1599
- checkNumberStatus(contactId: ContactId): Promise<NumberCheck>;
1600
- /**
1601
- * Retrieves all unread Messages
1602
- * @param includeMe
1603
- * @param includeNotifications
1604
- * @param use_unread_count
1605
- * @returns any
1606
- */
1607
- getUnreadMessages(includeMe: boolean, includeNotifications: boolean, use_unread_count: boolean): Promise<Chat & {
1608
- messages: Message[];
1609
- }[]>;
1610
- /**
1611
- * Retrieves all new Messages. where isNewMsg==true
1612
- * @returns list of messages
1613
- */
1614
- getAllNewMessages(): Promise<Message[]>;
1615
- /**
1616
- * Retrieves all unread Messages. where ack==-1
1617
- * @returns list of messages
1618
- */
1619
- getAllUnreadMessages(): Promise<Message[]>;
1620
- /**
1621
- * Retrieves all unread Messages as indicated by the red dots in WA web. This returns an array of objects and are structured like so:
1622
- * ```javascript
1623
- * [{
1624
- * "id": "000000000000@g.us", //the id of the chat
1625
- * "indicatedNewMessages": [] //array of messages, not including any messages by the host phone
1626
- * }]
1627
- * ```
1628
- * @returns list of messages
1629
- */
1630
- getIndicatedNewMessages(): Promise<Message[]>;
1631
- /**
1632
- * Fires all unread messages to the onMessage listener.
1633
- * Make sure to call this AFTER setting your listeners.
1634
- * @returns array of message IDs
1635
- */
1636
- emitUnreadMessages(): Promise<MessageId[]>;
1637
- /**
1638
- * Retrieves all Messages in a chat that have been loaded within the WA web instance.
1639
- *
1640
- * This does not load every single message in the chat history.
1641
- *
1642
- * @param chatId, the chat to get the messages from
1643
- * @param includeMe, include my own messages? boolean
1644
- * @param includeNotifications
1645
- * @returns Message[]
1646
- */
1647
- getAllMessagesInChat(chatId: ChatId, includeMe: boolean, includeNotifications: boolean): Promise<Message[]>;
1648
- /**
1649
- * loads and Retrieves all Messages in a chat
1650
- * @param chatId, the chat to get the messages from
1651
- * @param includeMe, include my own messages? boolean
1652
- * @param includeNotifications
1653
- * @returns any
1654
- */
1655
- loadAndGetAllMessagesInChat(chatId: ChatId, includeMe: boolean, includeNotifications: boolean): Promise<Message[]>;
1656
- /**
1657
- * Create a group and add contacts to it
1658
- *
1659
- * @param groupName group name: 'New group'
1660
- * @param contacts: A single contact id or an array of contact ids.
1661
- */
1662
- createGroup(groupName: string, contacts: ContactId | ContactId[]): Promise<GroupChatCreationResponse>;
1663
- /**
1664
- * {@license:insiders@}
1665
- *
1666
- * Create a new community
1667
- *
1668
- * @param communityName The community name
1669
- * @param communitySubject: The community subject line
1670
- * @param icon DataURL of a 1:1 ratio jpeg for the community icon
1671
- * @param existingGroups An array of existing group IDs, that are not already part of a community, to add to this new community.
1672
- * @param newGroups An array of new group objects that
1673
- */
1674
- createCommunity(communityName: string, communitySubject: string, icon: DataURL, existingGroups?: GroupChatId[], newGroups?: NewCommunityGroup[]): Promise<GroupId>;
1675
- /**
1676
- * Remove participant of Group
1677
- *
1678
- * If not a group chat, returns `NOT_A_GROUP_CHAT`.
1679
- *
1680
- * If the chat does not exist, returns `GROUP_DOES_NOT_EXIST`
1681
- *
1682
- * If the participantId does not exist in the group chat, returns `NOT_A_PARTICIPANT`
1683
- *
1684
- * If the host account is not an administrator, returns `INSUFFICIENT_PERMISSIONS`
1685
- *
1686
- * @param {*} groupId `0000000000-00000000@g.us`
1687
- * @param {*} participantId `000000000000@c.us`
1688
- */
1689
- removeParticipant(groupId: GroupChatId, participantId: ContactId): Promise<boolean>;
1690
- /** Change the icon for the group chat
1691
- * @param groupId 123123123123_1312313123@g.us The id of the group
1692
- * @param imgData 'data:image/jpeg;base64,...` The base 64 data url. Make sure this is a small img (128x128), otherwise it will fail.
1693
- * @returns boolean true if it was set, false if it didn't work. It usually doesn't work if the image file is too big.
1694
- */
1695
- setGroupIcon(groupId: GroupChatId, image: DataURL): Promise<boolean>;
1696
- /** Change the icon for the group chat
1697
- * @param groupId 123123123123_1312313123@g.us The id of the group
1698
- * @param url'https://upload.wikimedia.org/wikipedia/commons/3/38/JPEG_example_JPG_RIP_001.jpg' The url of the image. Make sure this is a small img (128x128), otherwise it will fail.
1699
- * @param requestConfig {} By default the request is a get request, however you can override that and many other options by sending this parameter. You can read more about this parameter here: https://github.com/axios/axios#request-config
1700
- * @returns boolean true if it was set, false if it didn't work. It usually doesn't work if the image file is too big.
1701
- */
1702
- setGroupIconByUrl(groupId: GroupChatId, url: string, requestConfig?: AxiosRequestConfig): Promise<boolean>;
1703
- /**
1704
- * Add participant to Group
1705
- *
1706
- * If not a group chat, returns `NOT_A_GROUP_CHAT`.
1707
- *
1708
- * If the chat does not exist, returns `GROUP_DOES_NOT_EXIST`
1709
- *
1710
- * If the participantId does not exist in the contacts, returns `NOT_A_CONTACT`
1711
- *
1712
- * If the host account is not an administrator, returns `INSUFFICIENT_PERMISSIONS`
1713
- *
1714
- * @param {*} groupId '0000000000-00000000@g.us'
1715
- * @param {*} participantId '000000000000@c.us'
1716
- *
1717
- */
1718
- addParticipant(groupId: GroupChatId, participantId: ContactId | ContactId[]): Promise<boolean>;
1719
- /**
1720
- * Promote Participant to Admin in Group
1721
- *
1722
- *
1723
- * If not a group chat, returns `NOT_A_GROUP_CHAT`.
1724
- *
1725
- * If the chat does not exist, returns `GROUP_DOES_NOT_EXIST`
1726
- *
1727
- * If the participantId does not exist in the group chat, returns `NOT_A_PARTICIPANT`
1728
- *
1729
- * If the host account is not an administrator, returns `INSUFFICIENT_PERMISSIONS`
1730
- *
1731
- * @param {*} groupId '0000000000-00000000@g.us'
1732
- * @param {*} participantId '000000000000@c.us'
1733
- */
1734
- promoteParticipant(groupId: GroupChatId, participantId: ContactId | ContactId[]): Promise<boolean>;
1735
- /**
1736
- * Demote Admin of Group
1737
- *
1738
- * If not a group chat, returns `NOT_A_GROUP_CHAT`.
1739
- *
1740
- * If the chat does not exist, returns `GROUP_DOES_NOT_EXIST`
1741
- *
1742
- * If the participantId does not exist in the group chat, returns `NOT_A_PARTICIPANT`
1743
- *
1744
- * If the host account is not an administrator, returns `INSUFFICIENT_PERMISSIONS`
1745
- *
1746
- * @param {*} groupId '0000000000-00000000@g.us'
1747
- * @param {*} participantId '000000000000@c.us'
1748
- */
1749
- demoteParticipant(groupId: GroupChatId, participantId: ContactId | ContactId[]): Promise<boolean>;
1750
- /**
1751
- *
1752
- * Change who can and cannot speak in a group
1753
- * @param groupId '0000000000-00000000@g.us' the group id.
1754
- * @param onlyAdmins boolean set to true if you want only admins to be able to speak in this group. false if you want to allow everyone to speak in the group
1755
- * @returns boolean true if action completed successfully.
1756
- */
1757
- setGroupToAdminsOnly(groupId: GroupChatId, onlyAdmins: boolean): Promise<boolean>;
1758
- /**
1759
- *
1760
- * Change who can and cannot edit a groups details
1761
- * @param groupId '0000000000-00000000@g.us' the group id.
1762
- * @param onlyAdmins boolean set to true if you want only admins to be able to speak in this group. false if you want to allow everyone to speak in the group
1763
- * @returns boolean true if action completed successfully.
1764
- */
1765
- setGroupEditToAdminsOnly(groupId: GroupChatId, onlyAdmins: boolean): Promise<boolean>;
1766
- /**
1767
- *
1768
- * Turn on or off the approval requirement for new members to join a group
1769
- * @param groupId '0000000000-00000000@g.us' the group id.
1770
- * @param requireApproval set to true to turn on the approval requirement, false to turn off
1771
- * @returns boolean true if action completed successfully.
1772
- */
1773
- setGroupApprovalMode(groupId: GroupChatId, requireApproval: boolean): Promise<boolean>;
1774
- /**
1775
- * Change the group chant description
1776
- * @param groupId '0000000000-00000000@g.us' the group id.
1777
- * @param description string The new group description
1778
- * @returns boolean true if action completed successfully.
1779
- */
1780
- setGroupDescription(groupId: GroupChatId, description: string): Promise<boolean>;
1781
- /**
1782
- * {@license:insiders@}
1783
- *
1784
- * Change the group chat title
1785
- * @param groupId '0000000000-00000000@g.us' the group id.
1786
- * @param title string The new group title
1787
- * @returns boolean true if action completed successfully.
1788
- */
1789
- setGroupTitle(groupId: GroupChatId, title: string): Promise<boolean>;
1790
- /**
1791
- * Get Admins of a Group
1792
- * @param {*} groupId '0000000000-00000000@g.us'
1793
- */
1794
- getGroupAdmins(groupId: GroupChatId): Promise<ContactId[]>;
1795
- /**
1796
- * {@license:insiders@}
1797
- *
1798
- * Set the wallpaper background colour
1799
- * @param {string} hex '#FFF123'
1800
- */
1801
- setChatBackgroundColourHex(hex: string): Promise<boolean>;
1802
- /**
1803
- * Join or leave the wa web beta program. Will return true of operation was successful.
1804
- *
1805
- * @param {boolean} join true to join the beta, false to leave
1806
- */
1807
- joinWebBeta(join: boolean): Promise<boolean>;
1808
- /**
1809
- *
1810
- * Start dark mode [NOW GENERALLY AVAILABLE]
1811
- * @param {boolean} activate true to activate dark mode, false to deactivate
1812
- */
1813
- darkMode(activate: boolean): Promise<boolean>;
1814
- /**
1815
- *
1816
- * Automatically reject calls on the host account device. Please note that the device that is calling you will continue to ring.
1817
- *
1818
- * Update: Due to the nature of MD, the host account will continue ringing.
1819
- *
1820
- * @param message optional message to send to the calling account when their call is detected and rejected
1821
- */
1822
- autoReject(message?: string): Promise<boolean>;
1823
- /**
1824
- * Returns an array of contacts that have read the message. If the message does not exist, it will return an empty array. If the host account has disabled read receipts this may not work!
1825
- * Each of these contact objects have a property `t` which represents the time at which that contact read the message.
1826
- * @param messageId The message id
1827
- */
1828
- getMessageReaders(messageId: MessageId): Promise<Contact[]>;
1829
- /**
1830
- * Returns poll data including results and votes.
1831
- *
1832
- * @param messageId The message id of the Poll
1833
- */
1834
- getPollData(messageId: MessageId): Promise<PollData>;
1835
- /**
1836
- * Sends a sticker (including GIF) from a given URL
1837
- * @param to: The recipient id.
1838
- * @param url: The url of the image
1839
- * @param requestConfig {} By default the request is a get request, however you can override that and many other options by sending this parameter. You can read more about this parameter here: https://github.com/axios/axios#request-config
1840
- *
1841
- * @returns `Promise<MessageId | boolean>`
1842
- */
1843
- sendStickerfromUrl(to: ChatId, url: string, requestConfig?: AxiosRequestConfig, stickerMetadata?: StickerMetadata): Promise<string | MessageId | boolean>;
1844
- /**
1845
- * {@license:insiders@}
1846
- *
1847
- * Sends a sticker from a given URL
1848
- * @param to The recipient id.
1849
- * @param url The url of the image
1850
- * @param messageId The id of the message to reply to
1851
- * @param requestConfig {} By default the request is a get request, however you can override that and many other options by sending this parameter. You can read more about this parameter here: https://github.com/axios/axios#request-config
1852
- *
1853
- * @returns `Promise<MessageId | boolean>`
1854
- */
1855
- sendStickerfromUrlAsReply(to: ChatId, url: string, messageId: MessageId, requestConfig?: AxiosRequestConfig, stickerMetadata?: StickerMetadata): Promise<MessageId | boolean>;
1856
- /**
1857
- * {@license:insiders@}
1858
- *
1859
- * This function takes an image and sends it as a sticker to the recipient as a reply to another message.
1860
- *
1861
- *
1862
- * @param to The recipient id.
1863
- * @param image: [[DataURL]], [[Base64]], URL (string GET), Relative filepath (string), or Buffer of the image
1864
- * @param messageId The id of the message to reply to
1865
- * @param stickerMetadata Sticker metadata
1866
- */
1867
- sendImageAsStickerAsReply(to: ChatId, image: DataURL | Buffer | Base64 | string, messageId: MessageId, stickerMetadata?: StickerMetadata): Promise<MessageId | boolean | string>;
1868
- /**
1869
- * This allows you to get a single property of a single object from the session. This limints the amouunt of data you need to sift through, reduces congestion between your process and the session and the flexibility to build your own specific getters.
1870
- *
1871
- * Example - get message read state (ack):
1872
- *
1873
- * ```javascript
1874
- * const ack = await client.getSingleProperty('Msg',"true_12345678912@c.us_9C4D0965EA5C09D591334AB6BDB07FEB",'ack')
1875
- * ```
1876
- * @param namespace
1877
- * @param id id of the object to get from the specific namespace
1878
- * @param property the single property key to get from the object.
1879
- * @returns any If the property or the id cannot be found, it will return a 404
1880
- */
1881
- getSingleProperty(namespace: namespace, id: string, property: string): Promise<any>;
1882
- private stickerServerRequest;
1883
- private prepareWebp;
1884
- /**
1885
- * This function takes an image (including animated GIF) and sends it as a sticker to the recipient. This is helpful for sending semi-ephemeral things like QR codes.
1886
- * The advantage is that it will not show up in the recipients gallery. This function automatiicaly converts images to the required webp format.
1887
- * @param to: The recipient id.
1888
- * @param image: [[DataURL]], [[Base64]], URL (string GET), Relative filepath (string), or Buffer of the image
1889
- */
1890
- sendImageAsSticker(to: ChatId, image: DataURL | Buffer | Base64 | string, stickerMetadata?: StickerMetadata): Promise<MessageId | string | boolean>;
1891
- /**
1892
- * Use this to send an mp4 file as a sticker. This can also be used to convert GIFs from the chat because GIFs in WA are actually tiny mp4 files.
1893
- *
1894
- * @param to ChatId The chat id you want to send the webp sticker to
1895
- * @param file [[DataURL]], [[Base64]], URL (string GET), Relative filepath (string), or Buffer of the mp4 file
1896
- * @param messageId message id of the message you want this sticker to reply to. @license:insiders@
1897
- */
1898
- sendMp4AsSticker(to: ChatId, file: DataURL | Buffer | Base64 | string, processOptions?: Mp4StickerConversionProcessOptions, stickerMetadata?: StickerMetadata, messageId?: MessageId): Promise<MessageId | string | boolean>;
1899
- /**
1900
- * Send a discord emoji to a chat as a sticker
1901
- *
1902
- * @param to ChatId The chat id you want to send the webp sticker to
1903
- * @param emojiId The discord emoji id without indentifying chars. In discord you would write `:who:`, here use `who`
1904
- * @param messageId message id of the message you want this sticker to reply to. @license:insiders@
1905
- */
1906
- sendEmoji(to: ChatId, emojiId: string, messageId?: MessageId): Promise<MessageId | boolean | string>;
1907
- /**
1908
- * You can use this to send a raw webp file.
1909
- * @param to ChatId The chat id you want to send the webp sticker to
1910
- * @param webpBase64 Base64 The base64 string of the webp file. Not DataURl
1911
- * @param animated Boolean Set to true if the webp is animated. Default `false`
1912
- */
1913
- sendRawWebpAsSticker(to: ChatId, webpBase64: Base64, animated?: boolean): Promise<MessageId | string | boolean>;
1914
- /**
1915
- * {@license:insiders@}
1916
- *
1917
- * You can use this to send a raw webp file.
1918
- * @param to ChatId The chat id you want to send the webp sticker to
1919
- * @param messageId MessageId Message ID of the message to reply to
1920
- * @param webpBase64 Base64 The base64 string of the webp file. Not DataURl
1921
- * @param animated Boolean Set to true if the webp is animated. Default `false`
1922
- */
1923
- sendRawWebpAsStickerAsReply(to: ChatId, messageId: MessageId, webpBase64: Base64, animated?: boolean): Promise<MessageId | string | boolean>;
1924
- /**
1925
- * {@license:insiders@}
1926
- *
1927
- * Turn the ephemeral setting in a chat to on or off
1928
- * @param chatId The ID of the chat
1929
- * @param ephemeral `true` to turn on the ephemeral setting to 1 day, `false` to turn off the ephemeral setting. Other options: `604800 | 7776000`
1930
- * @returns `Promise<boolean>` true if the setting was set, `false` if the chat does not exist
1931
- */
1932
- setChatEphemeral(chatId: ChatId, ephemeral: EphemeralDuration | boolean): Promise<boolean>;
1933
- /**
1934
- * Send a giphy GIF as an animated sticker.
1935
- * @param to ChatId
1936
- * @param giphyMediaUrl URL | string This is the giphy media url and has to be in the format `https://media.giphy.com/media/RJKHjCAdsAfQPn03qQ/source.gif` or it can be just the id `RJKHjCAdsAfQPn03qQ`
1937
- */
1938
- sendGiphyAsSticker(to: ChatId, giphyMediaUrl: URL | string): Promise<MessageId | string | boolean>;
1939
- /**
1940
- * {@license:restricted@}
1941
- *
1942
- * Sends a formatted text story.
1943
- * @param text The text to be displayed in the story
1944
- * @param textRgba The colour of the text in the story in hex format, make sure to add the alpha value also. E.g "#FF00F4F2"
1945
- * @param backgroundRgba The colour of the background in the story in hex format, make sure to add the alpha value also. E.g "#4FF31FF2"
1946
- * @param font The font of the text to be used in the story. This has to be a number. Each number refers to a specific predetermined font. Here are the fonts you can choose from:
1947
- * 0: Sans Serif
1948
- * 1: Serif
1949
- * 2: [Norican Regular](https://fonts.google.com/specimen/Norican)
1950
- * 3: [Bryndan Write](https://www.dafontfree.net/freefonts-bryndan-write-f160189.htm)
1951
- * 4: [Bebasneue Regular](https://www.dafont.com/bebas-neue.font)
1952
- * 5: [Oswald Heavy](https://www.fontsquirrel.com/fonts/oswald)
1953
- * @returns `Promise<string | boolean>` returns status id if it worked, false if it didn't
1954
- */
1955
- postTextStatus(text: Content, textRgba: string, backgroundRgba: string, font: number): Promise<MessageId | string | boolean>;
1956
- /**
1957
- * {@license:restricted@}
1958
- *
1959
- * Sends a formatted text story with a thumbnail.
1960
- * @param url The URL to share in the story
1961
- * @param text The text to be displayed in the story
1962
- * @param textRgba The colour of the text in the story in hex format, make sure to add the alpha value also. E.g "#FF00F4F2"
1963
- * @param backgroundRgba The colour of the background in the story in hex format, make sure to add the alpha value also. E.g "#4FF31FF2"
1964
- * @param font The font of the text to be used in the story. This has to be a number. Each number refers to a specific predetermined font. Here are the fonts you can choose from:
1965
- * @param thumbnail base64 thumbnail override, if not provided the link server will try to figure it out.
1966
- * 0: Sans Serif
1967
- * 1: Serif
1968
- * 2: [Norican Regular](https://fonts.google.com/specimen/Norican)
1969
- * 3: [Bryndan Write](https://www.dafontfree.net/freefonts-bryndan-write-f160189.htm)
1970
- * @returns `Promise<MessageId>` returns status id if it worked, false if it didn't
1971
- */
1972
- postThumbnailStatus(url: string, text: Content, textRgba: string, backgroundRgba: string, font: number, thumbnail?: Base64): Promise<MessageId>;
1973
- /**
1974
- * {@license:restricted@}
1975
- *
1976
- * Posts an image story.
1977
- * @param data data url string `data:[<MIME-type>][;charset=<encoding>][;base64],<data>`
1978
- * @param caption The caption for the story
1979
- * @returns `Promise<string | boolean>` returns status id if it worked, false if it didn't
1980
- */
1981
- postImageStatus(data: DataURL, caption: Content): Promise<MessageId | string | boolean>;
1982
- /**
1983
- * {@license:restricted@}
1984
- *
1985
- * Posts a video story.
1986
- * @param data data url string `data:[<MIME-type>][;charset=<encoding>][;base64],<data>`
1987
- * @param caption The caption for the story
1988
- * @returns `Promise<string | boolean>` returns status id if it worked, false if it didn't
1989
- */
1990
- postVideoStatus(data: DataURL, caption: Content): Promise<MessageId | string | boolean>;
1991
- /**
1992
- * {@license:restricted@}
1993
- *
1994
- * Consumes a list of id strings of stories to delete.
1995
- *
1996
- * @param statusesToDelete string [] | string an array of ids of stories to delete.
1997
- * @returns boolean. True if it worked.
1998
- */
1999
- deleteStory(statusesToDelete: string | string[]): Promise<boolean>;
2000
- /**
2001
- * Alias for deleteStory
2002
- */
2003
- deleteStatus(statusesToDelete: string | string[]): Promise<boolean>;
2004
- /**
2005
- * {@license:restricted@}
2006
- *
2007
- * Deletes all your existing stories.
2008
- * @returns boolean. True if it worked.
2009
- */
2010
- deleteAllStories(): Promise<boolean>;
2011
- /**
2012
- * Alias for deleteStory
2013
- */
2014
- deleteAllStatus(): Promise<boolean>;
2015
- /**
2016
- * {@license:restricted@}
2017
- *
2018
- * Retrieves all existing stories.
2019
- *
2020
- * Only works with a Story License Key
2021
- */
2022
- getMyStoryArray(): Promise<Message[]>;
2023
- /**
2024
- * Alias for deleteStory
2025
- */
2026
- getMyStatusArray(): Promise<Message[]>;
2027
- /**
2028
- * {@license:restricted@}
2029
- *
2030
- * Retrieves an array of user ids that have 'read' your story.
2031
- *
2032
- * @param id string The id of the story
2033
- *
2034
- */
2035
- getStoryViewers(id?: string): Promise<ContactId[] | {
2036
- [k: MessageId]: ContactId[];
2037
- }>;
2038
- /**
2039
- * Clears all chats of all messages. This does not delete chats. Please be careful with this as it will remove all messages from whatsapp web and the host device. This feature is great for privacy focussed bots.
2040
- *
2041
- * @param ts number A chat that has had a message after ts (epoch timestamp) will not be cleared.
2042
- *
2043
- */
2044
- clearAllChats(ts?: number): Promise<boolean>;
2045
- /**
2046
- * This simple function halves the amount of messages in your session message cache. This does not delete messages off your phone. If over a day you've processed 4000 messages this will possibly result in 4000 messages being present in your session.
2047
- * Calling this method will cut the message cache to 2000 messages, therefore reducing the memory usage of your process.
2048
- * You should use this in conjunction with `getAmountOfLoadedMessages` to intelligently control the session message cache.
2049
- */
2050
- cutMsgCache(): Promise<number>;
2051
- /**
2052
- * This simple function halves the amount of chats in your session message cache. This does not delete messages off your phone. If over a day you've processed 4000 messages this will possibly result in 4000 messages being present in your session.
2053
- * Calling this method will cut the message cache as much as possible, reducing the memory usage of your process.
2054
- * You should use this in conjunction with `getAmountOfLoadedMessages` to intelligently control the session message cache.
2055
- */
2056
- cutChatCache(): Promise<{
2057
- before: {
2058
- msgs: number;
2059
- chats: number;
2060
- };
2061
- after: {
2062
- msgs: number;
2063
- chats: number;
2064
- };
2065
- }>;
2066
- /**
2067
- * Deletes chats from a certain index (default 1000). E.g if this startingFrom param is `100` then all chats from index `100` onwards will be deleted.
2068
- *
2069
- * @param startingFrom the chat index to start from. Please do not set this to anything less than 10 @default: `1000`
2070
- */
2071
- deleteStaleChats(startingFrom?: number): Promise<boolean>;
2072
- /**
2073
- * Download profile pics from the message object.
2074
- * ```javascript
2075
- * const filename = `profilepic_${message.from}.jpeg`;
2076
- * const data = await client.downloadProfilePicFromMessage(message);
2077
- * const dataUri = `data:image/jpeg;base64,${data}`;
2078
- * fs.writeFile(filename, mData, 'base64', function(err) {
2079
- * if (err) {
2080
- * return console.log(err);
2081
- * }
2082
- * console.log('The file was saved!');
2083
- * });
2084
- * ```
2085
- */
2086
- downloadProfilePicFromMessage(message: Message): Promise<Base64>;
2087
- /**
2088
- * Download via the browsers authenticated session via URL.
2089
- * @returns base64 string (non-data url)
2090
- */
2091
- downloadFileWithCredentials(url: string): Promise<Base64>;
2092
- /**
2093
- *
2094
- * Sets the profile pic of the host number.
2095
- * @param data string data url image string.
2096
- * @returns `Promise<boolean>` success if true
2097
- */
2098
- setProfilePic(data: DataURL): Promise<boolean>;
2099
- /**
2100
- * This exposes a simple express middlware that will allow users to quickly boot up an api based off this client. Checkout demo/index.ts for an example
2101
- * How to use the middleware:
2102
- *
2103
- * ```javascript
2104
- *
2105
- * import { create } from '@open-wa/wa-automate';
2106
- * const express = require('express')
2107
- * const app = express()
2108
- * app.use(express.json())
2109
- * const PORT = 8082;
2110
- *
2111
- * function start(client){
2112
- * app.use(client.middleware()); //or client.middleware(true) if you require the session id to be part of the path (so localhost:8082/sendText beccomes localhost:8082/sessionId/sendText)
2113
- * app.listen(PORT, function () {
2114
- * console.log(`\n• Listening on port ${PORT}!`);
2115
- * });
2116
- * ...
2117
- * }
2118
- *
2119
- *
2120
- * create({
2121
- * sessionId:'session1'
2122
- * }).then(start)
2123
- *
2124
- * ```
2125
- *
2126
- * All requests need to be `POST` requests. You use the API the same way you would with `client`. The method can be the path or the method param in the post body. The arguments for the method should be properly ordered in the args array in the JSON post body.
2127
- *
2128
- * Example:
2129
- *
2130
- * ```javascript
2131
- * await client.sendText('4477777777777@c.us','test')
2132
- * //returns "true_4477777777777@c.us_3EB0645E623D91006252"
2133
- * ```
2134
- * as a request with a path:
2135
- *
2136
- * ```javascript
2137
- * const axios = require('axios').default;
2138
- * axios.post('localhost:8082/sendText', {
2139
- * args: [
2140
- * "4477777777777@c.us",
2141
- * "test"
2142
- * ]
2143
- * })
2144
- * ```
2145
- *
2146
- * or as a request without a path:
2147
- *
2148
- * ```javascript
2149
- * const axios = require('axios').default;
2150
- * axios.post('localhost:8082', {
2151
- * method:'sendText',
2152
- * args: [
2153
- * "4477777777777@c.us",
2154
- * "test"
2155
- * ]
2156
- * })
2157
- * ```
2158
- *
2159
- * As of 1.9.69, you can also send the argyments as an object with the keys mirroring the paramater names of the relative client functions
2160
- *
2161
- * Example:
2162
- *
2163
- * ```javascript
2164
- * const axios = require('axios').default;
2165
- * axios.post('localhost:8082', {
2166
- * method:'sendText',
2167
- * args: {
2168
- * "to":"4477777777777@c.us",
2169
- * "content":"test"
2170
- * }
2171
- * })
2172
- * ```
2173
- * @param useSessionIdInPath boolean Set this to true if you want to keep each session in it's own path.
2174
- *
2175
- * For example, if you have a session with id `host` if you set useSessionIdInPath to true, then all requests will need to be prefixed with the path `host`. E.g `localhost:8082/sendText` becomes `localhost:8082/host/sendText`
2176
- */
2177
- middleware: (useSessionIdInPath?: boolean, PORT?: number) => (req: Request, res: Response, next: NextFunction) => Promise<any>;
2178
- /**
2179
- * Retreives an array of webhook objects
2180
- */
2181
- listWebhooks(): Promise<Webhook[]>;
2182
- /**
2183
- * Removes a webhook.
2184
- *
2185
- * Returns `true` if the webhook was found and removed. `false` if the webhook was not found and therefore could not be removed. This does not unregister any listeners off of other webhooks.
2186
- *
2187
- *
2188
- * @param webhookId The ID of the webhook
2189
- * @retruns boolean
2190
- */
2191
- removeWebhook(webhookId: string): Promise<boolean>;
2192
- /**
2193
- * Update registered events for a specific webhook. This will override all existing events. If you'd like to remove all listeners from a webhook, consider using [[removeWebhook]].
2194
- *
2195
- * In order to update authentication details for a webhook, remove it completely and then reregister it with the correct credentials.
2196
- */
2197
- updateWebhook(webhookId: string, events: SimpleListener[] | 'all'): Promise<Webhook | false>;
2198
- /**
2199
- * The client can now automatically handle webhooks. Use this method to register webhooks.
2200
- *
2201
- * @param event use [[SimpleListener]] enum
2202
- * @param url The webhook url
2203
- * @param requestConfig {} By default the request is a post request, however you can override that and many other options by sending this parameter. You can read more about this parameter here: https://github.com/axios/axios#request-config
2204
- * @param concurrency the amount of concurrent requests to be handled by the built in queue. Default is 5.
2205
- */
2206
- private _setupWebhooksOnListeners;
2207
- /**
2208
- * The client can now automatically handle webhooks. Use this method to register webhooks.
2209
- *
2210
- * @param url The webhook url
2211
- * @param events An array of [[SimpleListener]] enums or `all` (to register all possible listeners)
2212
- * @param requestConfig {} By default the request is a post request, however you can override that and many other options by sending this parameter. You can read more about this parameter here: https://github.com/axios/axios#request-config
2213
- * @param concurrency the amount of concurrent requests to be handled by the built in queue. Default is 5.
2214
- * @returns A webhook object. This will include a webhook ID and an array of all successfully registered Listeners.
2215
- */
2216
- registerWebhook(url: string, events: SimpleListener[] | 'all', requestConfig?: AxiosRequestConfig, concurrency?: number): Promise<Webhook | false>;
2217
- prepEventData(data: JsonObject, event: SimpleListener, extras?: JsonObject): EventPayload;
2218
- getEventSignature(simpleListener?: SimpleListener): string;
2219
- private registerEv;
2220
- /**
2221
- * Every time this is called, it returns one less number. This is used to sort out queue priority.
2222
- */
2223
- private tickPriority;
2224
- /**
2225
- * Get the INSTANCE_ID of the current session
2226
- */
2227
- getInstanceId(): string;
2228
- /**
2229
- * Returns a new message collector for the chat which is related to the first parameter c
2230
- * @param c The Mesasge/Chat or Chat Id to base this message colletor on
2231
- * @param filter A function that consumes a [Message] and returns a boolean which determines whether or not the message shall be collected.
2232
- * @param options The options for the collector. For example, how long the collector shall run for, how many messages it should collect, how long between messages before timing out, etc.
2233
- */
2234
- createMessageCollector(c: Message | ChatId | Chat, filter: CollectorFilter<[Message]>, options: CollectorOptions): MessageCollector;
2235
- /**
2236
- * [FROM DISCORDJS]
2237
- * Similar to createMessageCollector but in promise form.
2238
- * Resolves with a collection of messages that pass the specified filter.
2239
- * @param c The Mesasge/Chat or Chat Id to base this message colletor on
2240
- * @param {CollectorFilter} filter The filter function to use
2241
- * @param {AwaitMessagesOptions} [options={}] Optional options to pass to the internal collector
2242
- * @returns {Promise<Collection<string, Message>>}
2243
- * @example
2244
- * ```javascript
2245
- * // Await !vote messages
2246
- * const filter = m => m.body.startsWith('!vote');
2247
- * // Errors: ['time'] treats ending because of the time limit as an error
2248
- * channel.awaitMessages(filter, { max: 4, time: 60000, errors: ['time'] })
2249
- * .then(collected => console.log(collected.size))
2250
- * .catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`));
2251
- * ```
2252
- */
2253
- awaitMessages(c: Message | ChatId | Chat, filter: CollectorFilter<[Message]>, options?: AwaitMessagesOptions): Promise<Collection<string, Message>>;
2254
- }
2255
- export { useragent } from '../config/puppeteer.config';