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.
- package/LICENSE +21 -0
- package/README.md +257 -0
- package/dist/client.cjs +91 -0
- package/dist/client.d.ts +64 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +87 -0
- package/dist/errors.cjs +59 -0
- package/dist/errors.d.ts +25 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +49 -0
- package/dist/index.cjs +26 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/modules/base.cjs +113 -0
- package/dist/modules/base.d.ts +22 -0
- package/dist/modules/base.d.ts.map +1 -0
- package/dist/modules/base.js +109 -0
- package/dist/modules/broadcast.cjs +30 -0
- package/dist/modules/broadcast.d.ts +27 -0
- package/dist/modules/broadcast.d.ts.map +1 -0
- package/dist/modules/broadcast.js +26 -0
- package/dist/modules/chats.cjs +113 -0
- package/dist/modules/chats.d.ts +106 -0
- package/dist/modules/chats.d.ts.map +1 -0
- package/dist/modules/chats.js +109 -0
- package/dist/modules/groups.cjs +200 -0
- package/dist/modules/groups.d.ts +139 -0
- package/dist/modules/groups.d.ts.map +1 -0
- package/dist/modules/groups.js +196 -0
- package/dist/modules/instances.cjs +138 -0
- package/dist/modules/instances.d.ts +91 -0
- package/dist/modules/instances.d.ts.map +1 -0
- package/dist/modules/instances.js +134 -0
- package/dist/modules/messages.cjs +217 -0
- package/dist/modules/messages.d.ts +155 -0
- package/dist/modules/messages.d.ts.map +1 -0
- package/dist/modules/messages.js +213 -0
- package/dist/modules/profile.cjs +129 -0
- package/dist/modules/profile.d.ts +92 -0
- package/dist/modules/profile.d.ts.map +1 -0
- package/dist/modules/profile.js +125 -0
- package/dist/types/chats.cjs +2 -0
- package/dist/types/chats.d.ts +62 -0
- package/dist/types/chats.d.ts.map +1 -0
- package/dist/types/chats.js +1 -0
- package/dist/types/groups.cjs +2 -0
- package/dist/types/groups.d.ts +47 -0
- package/dist/types/groups.d.ts.map +1 -0
- package/dist/types/groups.js +1 -0
- package/dist/types/index.cjs +22 -0
- package/dist/types/index.d.ts +34 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/instances.cjs +2 -0
- package/dist/types/instances.d.ts +65 -0
- package/dist/types/instances.d.ts.map +1 -0
- package/dist/types/instances.js +1 -0
- package/dist/types/messages.cjs +2 -0
- package/dist/types/messages.d.ts +86 -0
- package/dist/types/messages.d.ts.map +1 -0
- package/dist/types/messages.js +1 -0
- package/dist/types/profile.cjs +2 -0
- package/dist/types/profile.d.ts +25 -0
- package/dist/types/profile.d.ts.map +1 -0
- package/dist/types/profile.js +1 -0
- package/dist/types/webhooks.cjs +2 -0
- package/dist/types/webhooks.d.ts +17 -0
- package/dist/types/webhooks.d.ts.map +1 -0
- package/dist/types/webhooks.js +1 -0
- package/dist/webhooks/index.cjs +71 -0
- package/dist/webhooks/index.d.ts +26 -0
- package/dist/webhooks/index.d.ts.map +1 -0
- package/dist/webhooks/index.js +67 -0
- package/package.json +61 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { BaseModule } from './base.js';
|
|
2
|
+
import { SendMessageResponse, SendOTPOptions, MessageKey, BaseMessageOptions } from '../types/index.js';
|
|
3
|
+
export declare class MessagesModule extends BaseModule {
|
|
4
|
+
/**
|
|
5
|
+
* Sends a raw message payload to the Botcast gateway.
|
|
6
|
+
*/
|
|
7
|
+
send(payload: Record<string, any>): Promise<SendMessageResponse>;
|
|
8
|
+
/**
|
|
9
|
+
* Sends a plain text message.
|
|
10
|
+
*
|
|
11
|
+
* @param recipient Target phone number or JID
|
|
12
|
+
* @param text The message text
|
|
13
|
+
* @param options Additional options (mentions, quoted message, etc.)
|
|
14
|
+
*/
|
|
15
|
+
sendText(recipient: string, text: string, options?: BaseMessageOptions): Promise<SendMessageResponse>;
|
|
16
|
+
/**
|
|
17
|
+
* Sends an automated OTP verification code.
|
|
18
|
+
*
|
|
19
|
+
* @param recipient Target phone number
|
|
20
|
+
* @param options OTP configuration (code, app name, expiry minutes)
|
|
21
|
+
*/
|
|
22
|
+
sendOTP(recipient: string, options?: SendOTPOptions): Promise<SendMessageResponse & {
|
|
23
|
+
codeSent: string;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Sends an image from a URL or Base64 string.
|
|
27
|
+
*/
|
|
28
|
+
sendImage(recipient: string, imageSource: {
|
|
29
|
+
url?: string;
|
|
30
|
+
base64?: string;
|
|
31
|
+
caption?: string;
|
|
32
|
+
}, options?: BaseMessageOptions): Promise<SendMessageResponse>;
|
|
33
|
+
/**
|
|
34
|
+
* Sends a video from a URL or Base64 string.
|
|
35
|
+
*/
|
|
36
|
+
sendVideo(recipient: string, videoSource: {
|
|
37
|
+
url?: string;
|
|
38
|
+
base64?: string;
|
|
39
|
+
caption?: string;
|
|
40
|
+
}, options?: BaseMessageOptions): Promise<SendMessageResponse>;
|
|
41
|
+
/**
|
|
42
|
+
* Sends an audio file from a URL or Base64 string.
|
|
43
|
+
*/
|
|
44
|
+
sendAudio(recipient: string, audioSource: {
|
|
45
|
+
url?: string;
|
|
46
|
+
base64?: string;
|
|
47
|
+
mimetype?: string;
|
|
48
|
+
}, options?: BaseMessageOptions): Promise<SendMessageResponse>;
|
|
49
|
+
/**
|
|
50
|
+
* Sends a voice note (push-to-talk waveform audio).
|
|
51
|
+
*/
|
|
52
|
+
sendVoice(recipient: string, audioSource: {
|
|
53
|
+
url?: string;
|
|
54
|
+
base64?: string;
|
|
55
|
+
}, options?: BaseMessageOptions): Promise<SendMessageResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* Sends a document / PDF / file from a URL or Base64 string.
|
|
58
|
+
*/
|
|
59
|
+
sendDocument(recipient: string, docSource: {
|
|
60
|
+
url?: string;
|
|
61
|
+
base64?: string;
|
|
62
|
+
fileName?: string;
|
|
63
|
+
mimetype?: string;
|
|
64
|
+
caption?: string;
|
|
65
|
+
}, options?: BaseMessageOptions): Promise<SendMessageResponse>;
|
|
66
|
+
/**
|
|
67
|
+
* Sends an animated or static sticker.
|
|
68
|
+
*/
|
|
69
|
+
sendSticker(recipient: string, stickerSource: {
|
|
70
|
+
url?: string;
|
|
71
|
+
base64?: string;
|
|
72
|
+
}, options?: BaseMessageOptions): Promise<SendMessageResponse>;
|
|
73
|
+
/**
|
|
74
|
+
* Sends GPS location coordinates.
|
|
75
|
+
*/
|
|
76
|
+
sendLocation(recipient: string, location: {
|
|
77
|
+
latitude: number;
|
|
78
|
+
longitude: number;
|
|
79
|
+
name?: string;
|
|
80
|
+
address?: string;
|
|
81
|
+
}, options?: BaseMessageOptions): Promise<SendMessageResponse>;
|
|
82
|
+
/**
|
|
83
|
+
* Sends a contact vCard card.
|
|
84
|
+
*/
|
|
85
|
+
sendContact(recipient: string, contact: {
|
|
86
|
+
displayName: string;
|
|
87
|
+
vcard?: string;
|
|
88
|
+
contacts?: Array<{
|
|
89
|
+
displayName: string;
|
|
90
|
+
vcard: string;
|
|
91
|
+
}>;
|
|
92
|
+
}, options?: BaseMessageOptions): Promise<SendMessageResponse>;
|
|
93
|
+
/**
|
|
94
|
+
* Sends an interactive single/multiple choice poll.
|
|
95
|
+
*/
|
|
96
|
+
sendPoll(recipient: string, poll: {
|
|
97
|
+
name: string;
|
|
98
|
+
values: string[];
|
|
99
|
+
selectableCount?: number;
|
|
100
|
+
}, options?: BaseMessageOptions): Promise<SendMessageResponse>;
|
|
101
|
+
/**
|
|
102
|
+
* Forwards an existing message to another chat.
|
|
103
|
+
*/
|
|
104
|
+
forward(recipient: string, message: any): Promise<{
|
|
105
|
+
success: boolean;
|
|
106
|
+
message: string;
|
|
107
|
+
result?: any;
|
|
108
|
+
}>;
|
|
109
|
+
/**
|
|
110
|
+
* Edits the text content of a previously sent message.
|
|
111
|
+
*/
|
|
112
|
+
edit(recipient: string, key: MessageKey, newText: string): Promise<{
|
|
113
|
+
success: boolean;
|
|
114
|
+
message: string;
|
|
115
|
+
result?: any;
|
|
116
|
+
}>;
|
|
117
|
+
/**
|
|
118
|
+
* Deletes a message for everyone in the chat.
|
|
119
|
+
*/
|
|
120
|
+
delete(recipient: string, key: MessageKey): Promise<{
|
|
121
|
+
success: boolean;
|
|
122
|
+
message: string;
|
|
123
|
+
result?: any;
|
|
124
|
+
}>;
|
|
125
|
+
/**
|
|
126
|
+
* Marks one or more messages as read (sends blue double tick).
|
|
127
|
+
*/
|
|
128
|
+
markAsRead(keys: MessageKey | MessageKey[]): Promise<{
|
|
129
|
+
success: boolean;
|
|
130
|
+
message: string;
|
|
131
|
+
result?: any;
|
|
132
|
+
}>;
|
|
133
|
+
/**
|
|
134
|
+
* Sends an emoji reaction to a message (pass empty string `""` to remove reaction).
|
|
135
|
+
*/
|
|
136
|
+
react(recipient: string, key: MessageKey, emoji: string): Promise<{
|
|
137
|
+
success: boolean;
|
|
138
|
+
message: string;
|
|
139
|
+
result?: any;
|
|
140
|
+
}>;
|
|
141
|
+
/**
|
|
142
|
+
* Pins a message in a conversation.
|
|
143
|
+
*
|
|
144
|
+
* @param recipient Target chat
|
|
145
|
+
* @param key Message key
|
|
146
|
+
* @param type 1 to pin, 0 to unpin (default: 1)
|
|
147
|
+
* @param duration Duration in seconds (e.g. 86400 for 24h, 604800 for 7d, 2592000 for 30d)
|
|
148
|
+
*/
|
|
149
|
+
pin(recipient: string, key: MessageKey, type?: 1 | 0, duration?: number): Promise<{
|
|
150
|
+
success: boolean;
|
|
151
|
+
message: string;
|
|
152
|
+
result?: any;
|
|
153
|
+
}>;
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/modules/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EACL,mBAAmB,EAMnB,cAAc,EACd,U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A;KAAE,CAAC,CAO9D;IAED;;OAEG;IACU,KAAK,CAChB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC,CAM9D;IAED;;;;;;;OAOG;IACU,GAAG,CACd,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,UAAU,EACf,IAAI,GAAE,CAAC,GAAG,CAAK,EACf,QAAQ,GAAE,MAAc,GACvB,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC,CAM9D;CACF"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { BaseModule } from './base.js';
|
|
2
|
+
export class MessagesModule extends BaseModule {
|
|
3
|
+
/**
|
|
4
|
+
* Sends a raw message payload to the Botcast gateway.
|
|
5
|
+
*/
|
|
6
|
+
async send(payload) {
|
|
7
|
+
return this.request({
|
|
8
|
+
method: 'POST',
|
|
9
|
+
path: this.buildPath('send'),
|
|
10
|
+
body: payload,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Sends a plain text message.
|
|
15
|
+
*
|
|
16
|
+
* @param recipient Target phone number or JID
|
|
17
|
+
* @param text The message text
|
|
18
|
+
* @param options Additional options (mentions, quoted message, etc.)
|
|
19
|
+
*/
|
|
20
|
+
async sendText(recipient, text, options) {
|
|
21
|
+
return this.send({
|
|
22
|
+
recipient,
|
|
23
|
+
type: 'text',
|
|
24
|
+
text,
|
|
25
|
+
...options,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Sends an automated OTP verification code.
|
|
30
|
+
*
|
|
31
|
+
* @param recipient Target phone number
|
|
32
|
+
* @param options OTP configuration (code, app name, expiry minutes)
|
|
33
|
+
*/
|
|
34
|
+
async sendOTP(recipient, options) {
|
|
35
|
+
return this.request({
|
|
36
|
+
method: 'POST',
|
|
37
|
+
path: this.buildPath('otp'),
|
|
38
|
+
body: {
|
|
39
|
+
recipient,
|
|
40
|
+
...options,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Sends an image from a URL or Base64 string.
|
|
46
|
+
*/
|
|
47
|
+
async sendImage(recipient, imageSource, options) {
|
|
48
|
+
return this.send({
|
|
49
|
+
recipient,
|
|
50
|
+
type: 'image',
|
|
51
|
+
...imageSource,
|
|
52
|
+
...options,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Sends a video from a URL or Base64 string.
|
|
57
|
+
*/
|
|
58
|
+
async sendVideo(recipient, videoSource, options) {
|
|
59
|
+
return this.send({
|
|
60
|
+
recipient,
|
|
61
|
+
type: 'video',
|
|
62
|
+
...videoSource,
|
|
63
|
+
...options,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Sends an audio file from a URL or Base64 string.
|
|
68
|
+
*/
|
|
69
|
+
async sendAudio(recipient, audioSource, options) {
|
|
70
|
+
return this.send({
|
|
71
|
+
recipient,
|
|
72
|
+
type: 'audio',
|
|
73
|
+
...audioSource,
|
|
74
|
+
...options,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Sends a voice note (push-to-talk waveform audio).
|
|
79
|
+
*/
|
|
80
|
+
async sendVoice(recipient, audioSource, options) {
|
|
81
|
+
return this.send({
|
|
82
|
+
recipient,
|
|
83
|
+
type: 'voice',
|
|
84
|
+
ptt: true,
|
|
85
|
+
...audioSource,
|
|
86
|
+
...options,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Sends a document / PDF / file from a URL or Base64 string.
|
|
91
|
+
*/
|
|
92
|
+
async sendDocument(recipient, docSource, options) {
|
|
93
|
+
return this.send({
|
|
94
|
+
recipient,
|
|
95
|
+
type: 'document',
|
|
96
|
+
...docSource,
|
|
97
|
+
...options,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Sends an animated or static sticker.
|
|
102
|
+
*/
|
|
103
|
+
async sendSticker(recipient, stickerSource, options) {
|
|
104
|
+
return this.send({
|
|
105
|
+
recipient,
|
|
106
|
+
type: 'sticker',
|
|
107
|
+
...stickerSource,
|
|
108
|
+
...options,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Sends GPS location coordinates.
|
|
113
|
+
*/
|
|
114
|
+
async sendLocation(recipient, location, options) {
|
|
115
|
+
return this.send({
|
|
116
|
+
recipient,
|
|
117
|
+
type: 'location',
|
|
118
|
+
...location,
|
|
119
|
+
...options,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Sends a contact vCard card.
|
|
124
|
+
*/
|
|
125
|
+
async sendContact(recipient, contact, options) {
|
|
126
|
+
return this.request({
|
|
127
|
+
method: 'POST',
|
|
128
|
+
path: this.buildPath('messages/contact'),
|
|
129
|
+
body: {
|
|
130
|
+
recipient,
|
|
131
|
+
...contact,
|
|
132
|
+
...options,
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Sends an interactive single/multiple choice poll.
|
|
138
|
+
*/
|
|
139
|
+
async sendPoll(recipient, poll, options) {
|
|
140
|
+
return this.send({
|
|
141
|
+
recipient,
|
|
142
|
+
type: 'poll',
|
|
143
|
+
poll,
|
|
144
|
+
...options,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Forwards an existing message to another chat.
|
|
149
|
+
*/
|
|
150
|
+
async forward(recipient, message) {
|
|
151
|
+
return this.request({
|
|
152
|
+
method: 'POST',
|
|
153
|
+
path: this.buildPath('messages/forward'),
|
|
154
|
+
body: { recipient, message },
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Edits the text content of a previously sent message.
|
|
159
|
+
*/
|
|
160
|
+
async edit(recipient, key, newText) {
|
|
161
|
+
return this.request({
|
|
162
|
+
method: 'POST',
|
|
163
|
+
path: this.buildPath('messages/edit'),
|
|
164
|
+
body: { recipient, key, text: newText },
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Deletes a message for everyone in the chat.
|
|
169
|
+
*/
|
|
170
|
+
async delete(recipient, key) {
|
|
171
|
+
return this.request({
|
|
172
|
+
method: 'POST',
|
|
173
|
+
path: this.buildPath('messages/delete'),
|
|
174
|
+
body: { recipient, key },
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Marks one or more messages as read (sends blue double tick).
|
|
179
|
+
*/
|
|
180
|
+
async markAsRead(keys) {
|
|
181
|
+
const keyList = Array.isArray(keys) ? keys : [keys];
|
|
182
|
+
return this.request({
|
|
183
|
+
method: 'POST',
|
|
184
|
+
path: this.buildPath('messages/read'),
|
|
185
|
+
body: { keys: keyList },
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Sends an emoji reaction to a message (pass empty string `""` to remove reaction).
|
|
190
|
+
*/
|
|
191
|
+
async react(recipient, key, emoji) {
|
|
192
|
+
return this.request({
|
|
193
|
+
method: 'POST',
|
|
194
|
+
path: this.buildPath('messages/reaction'),
|
|
195
|
+
body: { recipient, key, emoji },
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Pins a message in a conversation.
|
|
200
|
+
*
|
|
201
|
+
* @param recipient Target chat
|
|
202
|
+
* @param key Message key
|
|
203
|
+
* @param type 1 to pin, 0 to unpin (default: 1)
|
|
204
|
+
* @param duration Duration in seconds (e.g. 86400 for 24h, 604800 for 7d, 2592000 for 30d)
|
|
205
|
+
*/
|
|
206
|
+
async pin(recipient, key, type = 1, duration = 86400) {
|
|
207
|
+
return this.request({
|
|
208
|
+
method: 'POST',
|
|
209
|
+
path: this.buildPath('messages/pin'),
|
|
210
|
+
body: { recipient, key, type, time: duration },
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProfileModule = void 0;
|
|
4
|
+
const base_js_1 = require("./base.js");
|
|
5
|
+
class ProfileModule extends base_js_1.BaseModule {
|
|
6
|
+
/**
|
|
7
|
+
* Fetches the bio / text status of a phone number or the current instance.
|
|
8
|
+
*/
|
|
9
|
+
async getStatus(targetPhoneOrJid) {
|
|
10
|
+
return this.request({
|
|
11
|
+
method: 'GET',
|
|
12
|
+
path: this.buildPath('profile/status'),
|
|
13
|
+
query: targetPhoneOrJid ? { phone: targetPhoneOrJid } : undefined,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Updates the about / bio status of the connected WhatsApp instance.
|
|
18
|
+
*/
|
|
19
|
+
async setStatus(status) {
|
|
20
|
+
return this.request({
|
|
21
|
+
method: 'POST',
|
|
22
|
+
path: this.buildPath('profile/status'),
|
|
23
|
+
body: { status },
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Updates the public display name of the instance.
|
|
28
|
+
*/
|
|
29
|
+
async setName(name) {
|
|
30
|
+
return this.request({
|
|
31
|
+
method: 'POST',
|
|
32
|
+
path: this.buildPath('profile/name'),
|
|
33
|
+
body: { name },
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Fetches the profile picture URL of a contact or group.
|
|
38
|
+
*/
|
|
39
|
+
async getPicture(targetPhoneOrJid, highRes = false) {
|
|
40
|
+
return this.request({
|
|
41
|
+
method: 'GET',
|
|
42
|
+
path: this.buildPath('profile/picture'),
|
|
43
|
+
query: {
|
|
44
|
+
phone: targetPhoneOrJid,
|
|
45
|
+
highRes,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Updates the profile picture for the instance or a group.
|
|
51
|
+
*/
|
|
52
|
+
async setPicture(imageSource, targetJid) {
|
|
53
|
+
return this.request({
|
|
54
|
+
method: 'POST',
|
|
55
|
+
path: this.buildPath('profile/picture'),
|
|
56
|
+
body: { jid: targetJid, ...imageSource },
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Removes the profile picture.
|
|
61
|
+
*/
|
|
62
|
+
async removePicture(targetJid) {
|
|
63
|
+
return this.request({
|
|
64
|
+
method: 'DELETE',
|
|
65
|
+
path: this.buildPath('profile/picture'),
|
|
66
|
+
body: { jid: targetJid },
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Fetches WhatsApp Business profile information (category, email, hours).
|
|
71
|
+
*/
|
|
72
|
+
async getBusinessProfile(targetPhoneOrJid) {
|
|
73
|
+
return this.request({
|
|
74
|
+
method: 'GET',
|
|
75
|
+
path: this.buildPath('profile/business'),
|
|
76
|
+
query: { phone: targetPhoneOrJid },
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Blocks a user on WhatsApp.
|
|
81
|
+
*/
|
|
82
|
+
async block(targetPhoneOrJid) {
|
|
83
|
+
return this.request({
|
|
84
|
+
method: 'POST',
|
|
85
|
+
path: this.buildPath('privacy/block'),
|
|
86
|
+
body: { phone: targetPhoneOrJid, action: 'block' },
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Unblocks a previously blocked user.
|
|
91
|
+
*/
|
|
92
|
+
async unblock(targetPhoneOrJid) {
|
|
93
|
+
return this.request({
|
|
94
|
+
method: 'POST',
|
|
95
|
+
path: this.buildPath('privacy/block'),
|
|
96
|
+
body: { phone: targetPhoneOrJid, action: 'unblock' },
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Fetches the full blocklist.
|
|
101
|
+
*/
|
|
102
|
+
async getBlocklist() {
|
|
103
|
+
return this.request({
|
|
104
|
+
method: 'GET',
|
|
105
|
+
path: this.buildPath('privacy/blocklist'),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Fetches WhatsApp privacy settings.
|
|
110
|
+
*/
|
|
111
|
+
async getPrivacySettings(force = false) {
|
|
112
|
+
return this.request({
|
|
113
|
+
method: 'GET',
|
|
114
|
+
path: this.buildPath('privacy/settings'),
|
|
115
|
+
query: { force },
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Updates a WhatsApp privacy configuration (lastSeen, online, profilePicture, status, readReceipts).
|
|
120
|
+
*/
|
|
121
|
+
async updatePrivacySetting(type, value) {
|
|
122
|
+
return this.request({
|
|
123
|
+
method: 'POST',
|
|
124
|
+
path: this.buildPath('privacy/update'),
|
|
125
|
+
body: { type, value },
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.ProfileModule = ProfileModule;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { BaseModule } from './base.js';
|
|
2
|
+
import { BusinessProfile, PrivacySettings, PrivacySettingType, PrivacyValue } from '../types/index.js';
|
|
3
|
+
export declare class ProfileModule extends BaseModule {
|
|
4
|
+
/**
|
|
5
|
+
* Fetches the bio / text status of a phone number or the current instance.
|
|
6
|
+
*/
|
|
7
|
+
getStatus(targetPhoneOrJid?: string): Promise<{
|
|
8
|
+
target: string;
|
|
9
|
+
status: string;
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Updates the about / bio status of the connected WhatsApp instance.
|
|
13
|
+
*/
|
|
14
|
+
setStatus(status: string): Promise<{
|
|
15
|
+
success: boolean;
|
|
16
|
+
message: string;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Updates the public display name of the instance.
|
|
20
|
+
*/
|
|
21
|
+
setName(name: string): Promise<{
|
|
22
|
+
success: boolean;
|
|
23
|
+
message: string;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Fetches the profile picture URL of a contact or group.
|
|
27
|
+
*/
|
|
28
|
+
getPicture(targetPhoneOrJid?: string, highRes?: boolean): Promise<{
|
|
29
|
+
target: string;
|
|
30
|
+
profilePictureUrl: string | null;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Updates the profile picture for the instance or a group.
|
|
34
|
+
*/
|
|
35
|
+
setPicture(imageSource: {
|
|
36
|
+
url?: string;
|
|
37
|
+
base64?: string;
|
|
38
|
+
}, targetJid?: string): Promise<{
|
|
39
|
+
success: boolean;
|
|
40
|
+
message: string;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Removes the profile picture.
|
|
44
|
+
*/
|
|
45
|
+
removePicture(targetJid?: string): Promise<{
|
|
46
|
+
success: boolean;
|
|
47
|
+
message: string;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Fetches WhatsApp Business profile information (category, email, hours).
|
|
51
|
+
*/
|
|
52
|
+
getBusinessProfile(targetPhoneOrJid: string): Promise<{
|
|
53
|
+
target: string;
|
|
54
|
+
businessProfile: BusinessProfile;
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Blocks a user on WhatsApp.
|
|
58
|
+
*/
|
|
59
|
+
block(targetPhoneOrJid: string): Promise<{
|
|
60
|
+
success: boolean;
|
|
61
|
+
message: string;
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* Unblocks a previously blocked user.
|
|
65
|
+
*/
|
|
66
|
+
unblock(targetPhoneOrJid: string): Promise<{
|
|
67
|
+
success: boolean;
|
|
68
|
+
message: string;
|
|
69
|
+
}>;
|
|
70
|
+
/**
|
|
71
|
+
* Fetches the full blocklist.
|
|
72
|
+
*/
|
|
73
|
+
getBlocklist(): Promise<{
|
|
74
|
+
success: boolean;
|
|
75
|
+
blocklist: string[];
|
|
76
|
+
}>;
|
|
77
|
+
/**
|
|
78
|
+
* Fetches WhatsApp privacy settings.
|
|
79
|
+
*/
|
|
80
|
+
getPrivacySettings(force?: boolean): Promise<{
|
|
81
|
+
success: boolean;
|
|
82
|
+
privacySettings: PrivacySettings;
|
|
83
|
+
}>;
|
|
84
|
+
/**
|
|
85
|
+
* Updates a WhatsApp privacy configuration (lastSeen, online, profilePicture, status, readReceipts).
|
|
86
|
+
*/
|
|
87
|
+
updatePrivacySetting(type: PrivacySettingType, value: PrivacyValue): Promise<{
|
|
88
|
+
success: boolean;
|
|
89
|
+
message: string;
|
|
90
|
+
}>;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../../src/modules/profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EACL,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,YAAY,EACb,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,aAAc,SAAQ,UAAU;IAC3C;;OAEG;IACU,SAAS,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAM7F;IAED;;OAEG;IACU,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAMrF;IAED;;OAEG;IACU,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,O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