botcast-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +257 -0
  3. package/dist/client.cjs +91 -0
  4. package/dist/client.d.ts +64 -0
  5. package/dist/client.d.ts.map +1 -0
  6. package/dist/client.js +87 -0
  7. package/dist/errors.cjs +59 -0
  8. package/dist/errors.d.ts +25 -0
  9. package/dist/errors.d.ts.map +1 -0
  10. package/dist/errors.js +49 -0
  11. package/dist/index.cjs +26 -0
  12. package/dist/index.d.ts +7 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +7 -0
  15. package/dist/modules/base.cjs +113 -0
  16. package/dist/modules/base.d.ts +22 -0
  17. package/dist/modules/base.d.ts.map +1 -0
  18. package/dist/modules/base.js +109 -0
  19. package/dist/modules/broadcast.cjs +30 -0
  20. package/dist/modules/broadcast.d.ts +27 -0
  21. package/dist/modules/broadcast.d.ts.map +1 -0
  22. package/dist/modules/broadcast.js +26 -0
  23. package/dist/modules/chats.cjs +113 -0
  24. package/dist/modules/chats.d.ts +106 -0
  25. package/dist/modules/chats.d.ts.map +1 -0
  26. package/dist/modules/chats.js +109 -0
  27. package/dist/modules/groups.cjs +200 -0
  28. package/dist/modules/groups.d.ts +139 -0
  29. package/dist/modules/groups.d.ts.map +1 -0
  30. package/dist/modules/groups.js +196 -0
  31. package/dist/modules/instances.cjs +138 -0
  32. package/dist/modules/instances.d.ts +91 -0
  33. package/dist/modules/instances.d.ts.map +1 -0
  34. package/dist/modules/instances.js +134 -0
  35. package/dist/modules/messages.cjs +217 -0
  36. package/dist/modules/messages.d.ts +155 -0
  37. package/dist/modules/messages.d.ts.map +1 -0
  38. package/dist/modules/messages.js +213 -0
  39. package/dist/modules/profile.cjs +129 -0
  40. package/dist/modules/profile.d.ts +92 -0
  41. package/dist/modules/profile.d.ts.map +1 -0
  42. package/dist/modules/profile.js +125 -0
  43. package/dist/types/chats.cjs +2 -0
  44. package/dist/types/chats.d.ts +62 -0
  45. package/dist/types/chats.d.ts.map +1 -0
  46. package/dist/types/chats.js +1 -0
  47. package/dist/types/groups.cjs +2 -0
  48. package/dist/types/groups.d.ts +47 -0
  49. package/dist/types/groups.d.ts.map +1 -0
  50. package/dist/types/groups.js +1 -0
  51. package/dist/types/index.cjs +22 -0
  52. package/dist/types/index.d.ts +34 -0
  53. package/dist/types/index.d.ts.map +1 -0
  54. package/dist/types/index.js +6 -0
  55. package/dist/types/instances.cjs +2 -0
  56. package/dist/types/instances.d.ts +65 -0
  57. package/dist/types/instances.d.ts.map +1 -0
  58. package/dist/types/instances.js +1 -0
  59. package/dist/types/messages.cjs +2 -0
  60. package/dist/types/messages.d.ts +86 -0
  61. package/dist/types/messages.d.ts.map +1 -0
  62. package/dist/types/messages.js +1 -0
  63. package/dist/types/profile.cjs +2 -0
  64. package/dist/types/profile.d.ts +25 -0
  65. package/dist/types/profile.d.ts.map +1 -0
  66. package/dist/types/profile.js +1 -0
  67. package/dist/types/webhooks.cjs +2 -0
  68. package/dist/types/webhooks.d.ts +17 -0
  69. package/dist/types/webhooks.d.ts.map +1 -0
  70. package/dist/types/webhooks.js +1 -0
  71. package/dist/webhooks/index.cjs +71 -0
  72. package/dist/webhooks/index.d.ts +26 -0
  73. package/dist/webhooks/index.d.ts.map +1 -0
  74. package/dist/webhooks/index.js +67 -0
  75. package/package.json +61 -0
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InstancesModule = void 0;
4
+ const base_js_1 = require("./base.js");
5
+ class InstancesModule extends base_js_1.BaseModule {
6
+ /**
7
+ * Retrieves the current live status of the WhatsApp instance.
8
+ */
9
+ async getStatus() {
10
+ return this.request({
11
+ method: 'GET',
12
+ path: this.buildPath('status'),
13
+ });
14
+ }
15
+ /**
16
+ * Fetches or generates a QR code string for device pairing.
17
+ */
18
+ async getQR() {
19
+ return this.request({
20
+ method: 'GET',
21
+ path: this.buildPath('qr'),
22
+ });
23
+ }
24
+ /**
25
+ * Generates an 8-digit phone pairing code for headless WhatsApp linking without scanning QR.
26
+ *
27
+ * @param phoneNumber Recipient phone number with country code (e.g. `201000000000` or `15551234567`)
28
+ */
29
+ async pairWithCode(phoneNumber) {
30
+ return this.request({
31
+ method: 'POST',
32
+ path: this.buildPath('pair-code'),
33
+ body: { phoneNumber },
34
+ });
35
+ }
36
+ /**
37
+ * Boots up the WhatsApp socket connection.
38
+ *
39
+ * @param force Force restart if already running
40
+ */
41
+ async start(force = false) {
42
+ return this.request({
43
+ method: 'POST',
44
+ path: this.buildPath('start'),
45
+ body: { force },
46
+ });
47
+ }
48
+ /**
49
+ * Stops the active WhatsApp socket session.
50
+ */
51
+ async stop() {
52
+ return this.request({
53
+ method: 'POST',
54
+ path: this.buildPath('stop'),
55
+ });
56
+ }
57
+ /**
58
+ * Logs out from WhatsApp and clears session keys.
59
+ */
60
+ async logout() {
61
+ return this.request({
62
+ method: 'POST',
63
+ path: this.buildPath('logout'),
64
+ });
65
+ }
66
+ /**
67
+ * Gets the list of allowed sandbox recipient phone numbers (for Dev instances).
68
+ */
69
+ async getAllowedNumbers() {
70
+ return this.request({
71
+ method: 'GET',
72
+ path: this.buildPath('allowed-numbers'),
73
+ });
74
+ }
75
+ /**
76
+ * Sets allowed sandbox phone numbers for a Dev instance.
77
+ *
78
+ * @param allowedNumbers Array of up to 3 phone numbers
79
+ */
80
+ async setAllowedNumbers(allowedNumbers) {
81
+ return this.request({
82
+ method: 'POST',
83
+ path: this.buildPath('allowed-numbers'),
84
+ body: { allowed_numbers: allowedNumbers },
85
+ });
86
+ }
87
+ /**
88
+ * Verifies if a phone number exists on WhatsApp and gets their JID / avatar.
89
+ *
90
+ * @param phoneNumber The phone number to check (with country code)
91
+ */
92
+ async checkNumber(phoneNumber) {
93
+ return this.request({
94
+ method: 'POST',
95
+ path: this.buildPath('check-number'),
96
+ body: { phone: phoneNumber },
97
+ });
98
+ }
99
+ /**
100
+ * Sets presence status (typing, recording audio, online/offline).
101
+ */
102
+ async setPresence(options) {
103
+ return this.request({
104
+ method: 'POST',
105
+ path: this.buildPath('presence'),
106
+ body: options,
107
+ });
108
+ }
109
+ /**
110
+ * Gets the instance's daily rate limits configuration.
111
+ */
112
+ async getLimits() {
113
+ return this.request({
114
+ method: 'GET',
115
+ path: this.buildPath('limits'),
116
+ });
117
+ }
118
+ /**
119
+ * Updates safety daily message limits and new contact limits.
120
+ */
121
+ async updateLimits(limits) {
122
+ return this.request({
123
+ method: 'POST',
124
+ path: this.buildPath('limits'),
125
+ body: limits,
126
+ });
127
+ }
128
+ /**
129
+ * Triggers contact & message sync from WhatsApp.
130
+ */
131
+ async sync() {
132
+ return this.request({
133
+ method: 'POST',
134
+ path: this.buildPath('sync'),
135
+ });
136
+ }
137
+ }
138
+ exports.InstancesModule = InstancesModule;
@@ -0,0 +1,91 @@
1
+ import { BaseModule } from './base.js';
2
+ import { InstanceStatusResponse, InstanceQRResponse, PairCodeResponse, AllowedNumbersResponse, SetAllowedNumbersResponse, CheckNumberResponse, PresenceOptions, InstanceLimitsResponse, UpdateLimitsPayload } from '../types/index.js';
3
+ export declare class InstancesModule extends BaseModule {
4
+ /**
5
+ * Retrieves the current live status of the WhatsApp instance.
6
+ */
7
+ getStatus(): Promise<InstanceStatusResponse>;
8
+ /**
9
+ * Fetches or generates a QR code string for device pairing.
10
+ */
11
+ getQR(): Promise<InstanceQRResponse>;
12
+ /**
13
+ * Generates an 8-digit phone pairing code for headless WhatsApp linking without scanning QR.
14
+ *
15
+ * @param phoneNumber Recipient phone number with country code (e.g. `201000000000` or `15551234567`)
16
+ */
17
+ pairWithCode(phoneNumber: string): Promise<PairCodeResponse>;
18
+ /**
19
+ * Boots up the WhatsApp socket connection.
20
+ *
21
+ * @param force Force restart if already running
22
+ */
23
+ start(force?: boolean): Promise<{
24
+ success: boolean;
25
+ instanceId: string;
26
+ status: string;
27
+ message: string;
28
+ }>;
29
+ /**
30
+ * Stops the active WhatsApp socket session.
31
+ */
32
+ stop(): Promise<{
33
+ success: boolean;
34
+ instanceId: string;
35
+ status: string;
36
+ message: string;
37
+ }>;
38
+ /**
39
+ * Logs out from WhatsApp and clears session keys.
40
+ */
41
+ logout(): Promise<{
42
+ success: boolean;
43
+ instanceId: string;
44
+ status: string;
45
+ message: string;
46
+ }>;
47
+ /**
48
+ * Gets the list of allowed sandbox recipient phone numbers (for Dev instances).
49
+ */
50
+ getAllowedNumbers(): Promise<AllowedNumbersResponse>;
51
+ /**
52
+ * Sets allowed sandbox phone numbers for a Dev instance.
53
+ *
54
+ * @param allowedNumbers Array of up to 3 phone numbers
55
+ */
56
+ setAllowedNumbers(allowedNumbers: string[]): Promise<SetAllowedNumbersResponse>;
57
+ /**
58
+ * Verifies if a phone number exists on WhatsApp and gets their JID / avatar.
59
+ *
60
+ * @param phoneNumber The phone number to check (with country code)
61
+ */
62
+ checkNumber(phoneNumber: string): Promise<CheckNumberResponse>;
63
+ /**
64
+ * Sets presence status (typing, recording audio, online/offline).
65
+ */
66
+ setPresence(options: PresenceOptions): Promise<{
67
+ success: boolean;
68
+ message: string;
69
+ }>;
70
+ /**
71
+ * Gets the instance's daily rate limits configuration.
72
+ */
73
+ getLimits(): Promise<InstanceLimitsResponse>;
74
+ /**
75
+ * Updates safety daily message limits and new contact limits.
76
+ */
77
+ updateLimits(limits: UpdateLimitsPayload): Promise<{
78
+ success: boolean;
79
+ message: string;
80
+ limits: any;
81
+ }>;
82
+ /**
83
+ * Triggers contact & message sync from WhatsApp.
84
+ */
85
+ sync(): Promise<{
86
+ success: boolean;
87
+ message: string;
88
+ contactsCount?: number;
89
+ }>;
90
+ }
91
+ //# sourceMappingURL=instances.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instances.d.ts","sourceRoot":"","sources":["../../../src/modules/instances.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,yBAAyB,EACzB,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,eAAgB,SAAQ,UAAU;IAC7C;;OAEG;IACU,SAAS,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAKxD;IAED;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAKhD;IAED;;;;OAIG;IACU,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAMxE;IAED;;;;OAIG;IACU,KAAK,CAAC,KAAK,GAAE,OAAe,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAM7H;IAED;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAKtG;IAED;;OAEG;IACU,MAAM,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAKxG;IAED;;OAEG;IACU,iBAAiB,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAKhE;IAED;;;;OAIG;IACU,iBAAiB,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAM3F;IAED;;;;OAIG;IACU,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAM1E;IAED;;OAEG;IACU,WAAW,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAMjG;IAED;;OAEG;IACU,SAAS,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAKxD;IAED;;OAEG;IACU,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,GAAG,CAAA;KAAE,CAAC,CAMlH;IAED;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAK1F;CACF"}
@@ -0,0 +1,134 @@
1
+ import { BaseModule } from './base.js';
2
+ export class InstancesModule extends BaseModule {
3
+ /**
4
+ * Retrieves the current live status of the WhatsApp instance.
5
+ */
6
+ async getStatus() {
7
+ return this.request({
8
+ method: 'GET',
9
+ path: this.buildPath('status'),
10
+ });
11
+ }
12
+ /**
13
+ * Fetches or generates a QR code string for device pairing.
14
+ */
15
+ async getQR() {
16
+ return this.request({
17
+ method: 'GET',
18
+ path: this.buildPath('qr'),
19
+ });
20
+ }
21
+ /**
22
+ * Generates an 8-digit phone pairing code for headless WhatsApp linking without scanning QR.
23
+ *
24
+ * @param phoneNumber Recipient phone number with country code (e.g. `201000000000` or `15551234567`)
25
+ */
26
+ async pairWithCode(phoneNumber) {
27
+ return this.request({
28
+ method: 'POST',
29
+ path: this.buildPath('pair-code'),
30
+ body: { phoneNumber },
31
+ });
32
+ }
33
+ /**
34
+ * Boots up the WhatsApp socket connection.
35
+ *
36
+ * @param force Force restart if already running
37
+ */
38
+ async start(force = false) {
39
+ return this.request({
40
+ method: 'POST',
41
+ path: this.buildPath('start'),
42
+ body: { force },
43
+ });
44
+ }
45
+ /**
46
+ * Stops the active WhatsApp socket session.
47
+ */
48
+ async stop() {
49
+ return this.request({
50
+ method: 'POST',
51
+ path: this.buildPath('stop'),
52
+ });
53
+ }
54
+ /**
55
+ * Logs out from WhatsApp and clears session keys.
56
+ */
57
+ async logout() {
58
+ return this.request({
59
+ method: 'POST',
60
+ path: this.buildPath('logout'),
61
+ });
62
+ }
63
+ /**
64
+ * Gets the list of allowed sandbox recipient phone numbers (for Dev instances).
65
+ */
66
+ async getAllowedNumbers() {
67
+ return this.request({
68
+ method: 'GET',
69
+ path: this.buildPath('allowed-numbers'),
70
+ });
71
+ }
72
+ /**
73
+ * Sets allowed sandbox phone numbers for a Dev instance.
74
+ *
75
+ * @param allowedNumbers Array of up to 3 phone numbers
76
+ */
77
+ async setAllowedNumbers(allowedNumbers) {
78
+ return this.request({
79
+ method: 'POST',
80
+ path: this.buildPath('allowed-numbers'),
81
+ body: { allowed_numbers: allowedNumbers },
82
+ });
83
+ }
84
+ /**
85
+ * Verifies if a phone number exists on WhatsApp and gets their JID / avatar.
86
+ *
87
+ * @param phoneNumber The phone number to check (with country code)
88
+ */
89
+ async checkNumber(phoneNumber) {
90
+ return this.request({
91
+ method: 'POST',
92
+ path: this.buildPath('check-number'),
93
+ body: { phone: phoneNumber },
94
+ });
95
+ }
96
+ /**
97
+ * Sets presence status (typing, recording audio, online/offline).
98
+ */
99
+ async setPresence(options) {
100
+ return this.request({
101
+ method: 'POST',
102
+ path: this.buildPath('presence'),
103
+ body: options,
104
+ });
105
+ }
106
+ /**
107
+ * Gets the instance's daily rate limits configuration.
108
+ */
109
+ async getLimits() {
110
+ return this.request({
111
+ method: 'GET',
112
+ path: this.buildPath('limits'),
113
+ });
114
+ }
115
+ /**
116
+ * Updates safety daily message limits and new contact limits.
117
+ */
118
+ async updateLimits(limits) {
119
+ return this.request({
120
+ method: 'POST',
121
+ path: this.buildPath('limits'),
122
+ body: limits,
123
+ });
124
+ }
125
+ /**
126
+ * Triggers contact & message sync from WhatsApp.
127
+ */
128
+ async sync() {
129
+ return this.request({
130
+ method: 'POST',
131
+ path: this.buildPath('sync'),
132
+ });
133
+ }
134
+ }
@@ -0,0 +1,217 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MessagesModule = void 0;
4
+ const base_js_1 = require("./base.js");
5
+ class MessagesModule extends base_js_1.BaseModule {
6
+ /**
7
+ * Sends a raw message payload to the Botcast gateway.
8
+ */
9
+ async send(payload) {
10
+ return this.request({
11
+ method: 'POST',
12
+ path: this.buildPath('send'),
13
+ body: payload,
14
+ });
15
+ }
16
+ /**
17
+ * Sends a plain text message.
18
+ *
19
+ * @param recipient Target phone number or JID
20
+ * @param text The message text
21
+ * @param options Additional options (mentions, quoted message, etc.)
22
+ */
23
+ async sendText(recipient, text, options) {
24
+ return this.send({
25
+ recipient,
26
+ type: 'text',
27
+ text,
28
+ ...options,
29
+ });
30
+ }
31
+ /**
32
+ * Sends an automated OTP verification code.
33
+ *
34
+ * @param recipient Target phone number
35
+ * @param options OTP configuration (code, app name, expiry minutes)
36
+ */
37
+ async sendOTP(recipient, options) {
38
+ return this.request({
39
+ method: 'POST',
40
+ path: this.buildPath('otp'),
41
+ body: {
42
+ recipient,
43
+ ...options,
44
+ },
45
+ });
46
+ }
47
+ /**
48
+ * Sends an image from a URL or Base64 string.
49
+ */
50
+ async sendImage(recipient, imageSource, options) {
51
+ return this.send({
52
+ recipient,
53
+ type: 'image',
54
+ ...imageSource,
55
+ ...options,
56
+ });
57
+ }
58
+ /**
59
+ * Sends a video from a URL or Base64 string.
60
+ */
61
+ async sendVideo(recipient, videoSource, options) {
62
+ return this.send({
63
+ recipient,
64
+ type: 'video',
65
+ ...videoSource,
66
+ ...options,
67
+ });
68
+ }
69
+ /**
70
+ * Sends an audio file from a URL or Base64 string.
71
+ */
72
+ async sendAudio(recipient, audioSource, options) {
73
+ return this.send({
74
+ recipient,
75
+ type: 'audio',
76
+ ...audioSource,
77
+ ...options,
78
+ });
79
+ }
80
+ /**
81
+ * Sends a voice note (push-to-talk waveform audio).
82
+ */
83
+ async sendVoice(recipient, audioSource, options) {
84
+ return this.send({
85
+ recipient,
86
+ type: 'voice',
87
+ ptt: true,
88
+ ...audioSource,
89
+ ...options,
90
+ });
91
+ }
92
+ /**
93
+ * Sends a document / PDF / file from a URL or Base64 string.
94
+ */
95
+ async sendDocument(recipient, docSource, options) {
96
+ return this.send({
97
+ recipient,
98
+ type: 'document',
99
+ ...docSource,
100
+ ...options,
101
+ });
102
+ }
103
+ /**
104
+ * Sends an animated or static sticker.
105
+ */
106
+ async sendSticker(recipient, stickerSource, options) {
107
+ return this.send({
108
+ recipient,
109
+ type: 'sticker',
110
+ ...stickerSource,
111
+ ...options,
112
+ });
113
+ }
114
+ /**
115
+ * Sends GPS location coordinates.
116
+ */
117
+ async sendLocation(recipient, location, options) {
118
+ return this.send({
119
+ recipient,
120
+ type: 'location',
121
+ ...location,
122
+ ...options,
123
+ });
124
+ }
125
+ /**
126
+ * Sends a contact vCard card.
127
+ */
128
+ async sendContact(recipient, contact, options) {
129
+ return this.request({
130
+ method: 'POST',
131
+ path: this.buildPath('messages/contact'),
132
+ body: {
133
+ recipient,
134
+ ...contact,
135
+ ...options,
136
+ },
137
+ });
138
+ }
139
+ /**
140
+ * Sends an interactive single/multiple choice poll.
141
+ */
142
+ async sendPoll(recipient, poll, options) {
143
+ return this.send({
144
+ recipient,
145
+ type: 'poll',
146
+ poll,
147
+ ...options,
148
+ });
149
+ }
150
+ /**
151
+ * Forwards an existing message to another chat.
152
+ */
153
+ async forward(recipient, message) {
154
+ return this.request({
155
+ method: 'POST',
156
+ path: this.buildPath('messages/forward'),
157
+ body: { recipient, message },
158
+ });
159
+ }
160
+ /**
161
+ * Edits the text content of a previously sent message.
162
+ */
163
+ async edit(recipient, key, newText) {
164
+ return this.request({
165
+ method: 'POST',
166
+ path: this.buildPath('messages/edit'),
167
+ body: { recipient, key, text: newText },
168
+ });
169
+ }
170
+ /**
171
+ * Deletes a message for everyone in the chat.
172
+ */
173
+ async delete(recipient, key) {
174
+ return this.request({
175
+ method: 'POST',
176
+ path: this.buildPath('messages/delete'),
177
+ body: { recipient, key },
178
+ });
179
+ }
180
+ /**
181
+ * Marks one or more messages as read (sends blue double tick).
182
+ */
183
+ async markAsRead(keys) {
184
+ const keyList = Array.isArray(keys) ? keys : [keys];
185
+ return this.request({
186
+ method: 'POST',
187
+ path: this.buildPath('messages/read'),
188
+ body: { keys: keyList },
189
+ });
190
+ }
191
+ /**
192
+ * Sends an emoji reaction to a message (pass empty string `""` to remove reaction).
193
+ */
194
+ async react(recipient, key, emoji) {
195
+ return this.request({
196
+ method: 'POST',
197
+ path: this.buildPath('messages/reaction'),
198
+ body: { recipient, key, emoji },
199
+ });
200
+ }
201
+ /**
202
+ * Pins a message in a conversation.
203
+ *
204
+ * @param recipient Target chat
205
+ * @param key Message key
206
+ * @param type 1 to pin, 0 to unpin (default: 1)
207
+ * @param duration Duration in seconds (e.g. 86400 for 24h, 604800 for 7d, 2592000 for 30d)
208
+ */
209
+ async pin(recipient, key, type = 1, duration = 86400) {
210
+ return this.request({
211
+ method: 'POST',
212
+ path: this.buildPath('messages/pin'),
213
+ body: { recipient, key, type, time: duration },
214
+ });
215
+ }
216
+ }
217
+ exports.MessagesModule = MessagesModule;