@open-wa/schema 5.0.0 → 5.2.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/dist/generated/index.cjs +8 -2
- package/dist/generated/index.cjs.map +1 -1
- package/dist/generated/index.d.cts +7868 -994
- package/dist/generated/index.d.cts.map +1 -1
- package/dist/generated/index.d.mts +7868 -994
- package/dist/generated/index.d.mts.map +1 -1
- package/dist/generated/index.mjs +8 -2
- package/dist/generated/index.mjs.map +1 -1
- package/dist/index-C9Ad0lEr.d.cts +4729 -0
- package/dist/index-C9Ad0lEr.d.cts.map +1 -0
- package/dist/index-D0QN2PaW.d.mts +4729 -0
- package/dist/index-D0QN2PaW.d.mts.map +1 -0
- package/dist/index.cjs +109 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +53 -2
- package/dist/index.mjs.map +1 -1
- package/dist/methods/index.cjs +6 -1
- package/dist/methods/index.d.cts +2 -2
- package/dist/methods/index.d.mts +2 -2
- package/dist/methods/index.mjs +2 -2
- package/dist/{methods-Dizm7Fn9.cjs → methods-BGmdzjd3.cjs} +904 -76
- package/dist/methods-BGmdzjd3.cjs.map +1 -0
- package/dist/{methods-CZqeUhKy.mjs → methods-BhLsQNtL.mjs} +587 -77
- package/dist/methods-BhLsQNtL.mjs.map +1 -0
- package/package.json +4 -3
- package/src/__tests__/generators.contract.test.ts +181 -0
- package/src/__tests__/registry.contract.test.ts +81 -0
- package/src/client-config.ts +30 -0
- package/src/codecs.test.ts +41 -0
- package/src/codecs.ts +191 -0
- package/src/common-types.ts +287 -0
- package/src/config.ts +47 -0
- package/src/enums.ts +63 -0
- package/src/events/groups.ts +33 -0
- package/src/events/index.ts +4 -0
- package/src/events/messaging.ts +86 -0
- package/src/events/registry.ts +124 -0
- package/src/events/state.ts +59 -0
- package/src/generated/AliasMap.ts +216 -0
- package/src/generated/BaseClient.ts +878 -0
- package/src/generated/BaseNamespacedClient.ts +214 -0
- package/src/generated/index.ts +5 -0
- package/src/generated/openapi.json +30049 -0
- package/src/generated/types.ts +383 -0
- package/src/http-manifest.ts +97 -0
- package/src/implementor.test.ts +88 -0
- package/src/implementor.ts +75 -0
- package/src/index.ts +46 -0
- package/src/interactive.ts +151 -0
- package/src/methods/business.ts +52 -0
- package/src/methods/chats.ts +264 -0
- package/src/methods/communities.ts +121 -0
- package/src/methods/contacts.ts +160 -0
- package/src/methods/groups.ts +378 -0
- package/src/methods/index.ts +34 -0
- package/src/methods/interactive.ts +21 -0
- package/src/methods/labels.ts +88 -0
- package/src/methods/media.ts +36 -0
- package/src/methods/messaging.ts +836 -0
- package/src/methods/session.ts +262 -0
- package/src/methods/status.ts +122 -0
- package/src/output-json-schema.ts +27 -0
- package/src/parameters.ts +237 -0
- package/src/registry.test.ts +30 -0
- package/src/registry.ts +601 -0
- package/src/return-types.ts +125 -0
- package/dist/index-BHcd0h7x.d.mts +0 -1265
- package/dist/index-BHcd0h7x.d.mts.map +0 -1
- package/dist/index-ChYFQM1K.d.cts +0 -1265
- package/dist/index-ChYFQM1K.d.cts.map +0 -1
- package/dist/methods-CZqeUhKy.mjs.map +0 -1
- package/dist/methods-Dizm7Fn9.cjs.map +0 -1
|
@@ -0,0 +1,836 @@
|
|
|
1
|
+
import { MessageIdReturnSchema, MessageSchema } from '../common-types';
|
|
2
|
+
import { LLMMessageSchema, MessageInfoSchema } from '../return-types';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { defineMethodV2 } from '../registry';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
chatIdParam,
|
|
8
|
+
toParam,
|
|
9
|
+
contentParam,
|
|
10
|
+
messageOptionsParam,
|
|
11
|
+
imageDataParam,
|
|
12
|
+
filenameParam,
|
|
13
|
+
captionParam,
|
|
14
|
+
messageIdParam,
|
|
15
|
+
waitForIdParam,
|
|
16
|
+
messageIdsParam,
|
|
17
|
+
skipMyMessagesParam,
|
|
18
|
+
latitudeParam,
|
|
19
|
+
longitudeParam,
|
|
20
|
+
locationNameParam,
|
|
21
|
+
contactIdParam,
|
|
22
|
+
mentionedJidListParam,
|
|
23
|
+
fileDataParam,
|
|
24
|
+
audioDataParam,
|
|
25
|
+
videoDataParam
|
|
26
|
+
} from '../parameters';
|
|
27
|
+
|
|
28
|
+
// ============================================================================
|
|
29
|
+
// Messaging Methods
|
|
30
|
+
// ============================================================================
|
|
31
|
+
|
|
32
|
+
/** The normalized serialized message key returned by the public sendText client. */
|
|
33
|
+
export const SendTextResultSchema = z.string()
|
|
34
|
+
.regex(/^(true|false)_[^\s_]+@[^\s_]+_[^\s]+$/)
|
|
35
|
+
.brand('MessageId')
|
|
36
|
+
.describe('Validated serialized message ID. This confirms the send returned an ID, not delivery or reading.');
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Sends a text message to a chat
|
|
40
|
+
*/
|
|
41
|
+
export const sendText = defineMethodV2('sendText', {
|
|
42
|
+
meta: {
|
|
43
|
+
description: 'Sends a text message and returns a validated serialized message ID. The in-process Client throws SendTextError on failure. An unknown outcome means the message may have been sent: check the chat before retrying. Starting a chat with a new number requires an applied restricted or premium license.',
|
|
44
|
+
action: 'send',
|
|
45
|
+
namespace: 'messages',
|
|
46
|
+
license: 'none',
|
|
47
|
+
functionality: 'both',
|
|
48
|
+
httpMethod: 'POST',
|
|
49
|
+
},
|
|
50
|
+
input: z.object({
|
|
51
|
+
to: toParam,
|
|
52
|
+
content: contentParam,
|
|
53
|
+
options: messageOptionsParam
|
|
54
|
+
}),
|
|
55
|
+
parameterOrder: ['to', 'content', 'options'],
|
|
56
|
+
output: SendTextResultSchema
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Sends a text message with mentions
|
|
61
|
+
*/
|
|
62
|
+
export const sendTextWithMentions = defineMethodV2('sendTextWithMentions', {
|
|
63
|
+
meta: {
|
|
64
|
+
description: 'Sends a text message that includes @mentions',
|
|
65
|
+
action: 'send',
|
|
66
|
+
namespace: 'messages',
|
|
67
|
+
license: 'none',
|
|
68
|
+
functionality: 'both',
|
|
69
|
+
httpMethod: 'POST',
|
|
70
|
+
},
|
|
71
|
+
input: z.object({
|
|
72
|
+
to: toParam,
|
|
73
|
+
content: contentParam,
|
|
74
|
+
hideTags: z.boolean().optional().describe('Removes all tags within the message'),
|
|
75
|
+
mentions: mentionedJidListParam
|
|
76
|
+
}),
|
|
77
|
+
parameterOrder: ['to', 'content', 'hideTags', 'mentions'],
|
|
78
|
+
output: MessageIdReturnSchema.or(z.boolean())
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Sends a reply with mentions
|
|
83
|
+
*/
|
|
84
|
+
export const sendReplyWithMentions = defineMethodV2('sendReplyWithMentions', {
|
|
85
|
+
meta: {
|
|
86
|
+
description: 'Sends a reply to a message that includes @mentions',
|
|
87
|
+
action: 'send',
|
|
88
|
+
namespace: 'messages',
|
|
89
|
+
license: 'none',
|
|
90
|
+
functionality: 'both',
|
|
91
|
+
httpMethod: 'POST',
|
|
92
|
+
},
|
|
93
|
+
input: z.object({
|
|
94
|
+
to: toParam,
|
|
95
|
+
content: contentParam,
|
|
96
|
+
replyMessageId: messageIdParam,
|
|
97
|
+
hideTags: z.boolean().optional().describe('Removes all tags within the message'),
|
|
98
|
+
mentions: mentionedJidListParam
|
|
99
|
+
}),
|
|
100
|
+
parameterOrder: ['to', 'content', 'replyMessageId', 'hideTags', 'mentions'],
|
|
101
|
+
output: MessageIdReturnSchema.or(z.boolean())
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Sends a payment request
|
|
106
|
+
*/
|
|
107
|
+
export const sendPaymentRequest = defineMethodV2('sendPaymentRequest', {
|
|
108
|
+
meta: {
|
|
109
|
+
description: 'Sends a payment request message',
|
|
110
|
+
action: 'send',
|
|
111
|
+
namespace: 'messages',
|
|
112
|
+
license: 'none',
|
|
113
|
+
functionality: 'both',
|
|
114
|
+
httpMethod: 'POST',
|
|
115
|
+
},
|
|
116
|
+
input: z.object({
|
|
117
|
+
to: toParam,
|
|
118
|
+
amount: z.number().describe('Amount in 1000 format (e.g £10 => 10000)'),
|
|
119
|
+
currency: z.string().length(3).describe('3 letter currency code'),
|
|
120
|
+
message: z.string().optional().describe('Optional message')
|
|
121
|
+
}),
|
|
122
|
+
parameterOrder: ['to', 'amount', 'currency', 'message'],
|
|
123
|
+
output: MessageIdReturnSchema.or(z.boolean())
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Sends an image to a chat
|
|
128
|
+
*/
|
|
129
|
+
export const sendImage = defineMethodV2('sendImage', {
|
|
130
|
+
meta: {
|
|
131
|
+
description: 'Sends an image to a chat',
|
|
132
|
+
action: 'send',
|
|
133
|
+
namespace: 'messages',
|
|
134
|
+
license: 'none',
|
|
135
|
+
functionality: 'both',
|
|
136
|
+
httpMethod: 'POST',
|
|
137
|
+
},
|
|
138
|
+
input: z.object({
|
|
139
|
+
to: toParam,
|
|
140
|
+
imgData: imageDataParam,
|
|
141
|
+
filename: filenameParam,
|
|
142
|
+
caption: captionParam,
|
|
143
|
+
id: messageIdParam.optional(),
|
|
144
|
+
waitForId: waitForIdParam
|
|
145
|
+
}),
|
|
146
|
+
parameterOrder: ['to', 'imgData', 'filename', 'caption', 'id', 'waitForId'],
|
|
147
|
+
output: MessageIdReturnSchema.or(z.boolean()).or(z.string())
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Sends a file/document
|
|
152
|
+
*/
|
|
153
|
+
export const sendFile = defineMethodV2('sendFile', {
|
|
154
|
+
meta: {
|
|
155
|
+
description: 'Sends a file or document to a chat',
|
|
156
|
+
action: 'send',
|
|
157
|
+
namespace: 'messages',
|
|
158
|
+
license: 'none',
|
|
159
|
+
functionality: 'both',
|
|
160
|
+
httpMethod: 'POST',
|
|
161
|
+
},
|
|
162
|
+
input: z.object({
|
|
163
|
+
to: toParam,
|
|
164
|
+
file: fileDataParam,
|
|
165
|
+
filename: filenameParam,
|
|
166
|
+
caption: captionParam
|
|
167
|
+
}),
|
|
168
|
+
parameterOrder: ['to', 'file', 'filename', 'caption'],
|
|
169
|
+
output: MessageIdReturnSchema.or(z.string())
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Sends an audio file
|
|
174
|
+
*/
|
|
175
|
+
export const sendAudio = defineMethodV2('sendAudio', {
|
|
176
|
+
meta: {
|
|
177
|
+
description: 'Sends an audio file to a chat',
|
|
178
|
+
action: 'send',
|
|
179
|
+
namespace: 'messages',
|
|
180
|
+
license: 'none',
|
|
181
|
+
functionality: 'both',
|
|
182
|
+
httpMethod: 'POST',
|
|
183
|
+
},
|
|
184
|
+
input: z.object({
|
|
185
|
+
to: toParam,
|
|
186
|
+
file: audioDataParam,
|
|
187
|
+
filename: filenameParam,
|
|
188
|
+
quotedMsgId: messageIdParam.optional()
|
|
189
|
+
}),
|
|
190
|
+
parameterOrder: ['to', 'file', 'filename', 'quotedMsgId'],
|
|
191
|
+
output: MessageIdReturnSchema.or(z.boolean())
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Sends a voice note (PTT)
|
|
196
|
+
*/
|
|
197
|
+
export const sendPtt = defineMethodV2('sendPtt', {
|
|
198
|
+
meta: {
|
|
199
|
+
description: 'Sends a voice note (push-to-talk) to a chat',
|
|
200
|
+
action: 'send',
|
|
201
|
+
namespace: 'messages',
|
|
202
|
+
license: 'none',
|
|
203
|
+
functionality: 'both',
|
|
204
|
+
httpMethod: 'POST',
|
|
205
|
+
aliases: {
|
|
206
|
+
explicit: ['sendVoiceNote'],
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
input: z.object({
|
|
210
|
+
to: toParam,
|
|
211
|
+
file: audioDataParam,
|
|
212
|
+
quotedMsgId: messageIdParam.optional()
|
|
213
|
+
}),
|
|
214
|
+
parameterOrder: ['to', 'file', 'quotedMsgId'],
|
|
215
|
+
output: MessageIdReturnSchema.or(z.boolean())
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Sends a video as GIF
|
|
220
|
+
*/
|
|
221
|
+
export const sendVideoAsGif = defineMethodV2('sendVideoAsGif', {
|
|
222
|
+
meta: {
|
|
223
|
+
description: 'Sends a video as an animated GIF',
|
|
224
|
+
action: 'send',
|
|
225
|
+
namespace: 'messages',
|
|
226
|
+
license: 'none',
|
|
227
|
+
functionality: 'both',
|
|
228
|
+
httpMethod: 'POST',
|
|
229
|
+
},
|
|
230
|
+
input: z.object({
|
|
231
|
+
to: toParam,
|
|
232
|
+
file: videoDataParam,
|
|
233
|
+
filename: filenameParam,
|
|
234
|
+
caption: captionParam,
|
|
235
|
+
quotedMsgId: messageIdParam.optional()
|
|
236
|
+
}),
|
|
237
|
+
parameterOrder: ['to', 'file', 'filename', 'caption', 'quotedMsgId'],
|
|
238
|
+
output: MessageIdReturnSchema.or(z.boolean())
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Sends a location
|
|
243
|
+
*/
|
|
244
|
+
export const sendLocation = defineMethodV2('sendLocation', {
|
|
245
|
+
meta: {
|
|
246
|
+
description: 'Sends a location to a chat',
|
|
247
|
+
action: 'send',
|
|
248
|
+
namespace: 'messages',
|
|
249
|
+
license: 'none',
|
|
250
|
+
functionality: 'both',
|
|
251
|
+
httpMethod: 'POST',
|
|
252
|
+
},
|
|
253
|
+
input: z.object({
|
|
254
|
+
to: toParam,
|
|
255
|
+
lat: latitudeParam,
|
|
256
|
+
lng: longitudeParam,
|
|
257
|
+
loc: locationNameParam,
|
|
258
|
+
address: z.string().optional().describe('Address text'),
|
|
259
|
+
url: z.string().url().optional().describe('Address link')
|
|
260
|
+
}),
|
|
261
|
+
parameterOrder: ['to', 'lat', 'lng', 'loc', 'address', 'url'],
|
|
262
|
+
output: MessageIdReturnSchema.or(z.boolean())
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Sends a vCard
|
|
267
|
+
*/
|
|
268
|
+
export const sendVCard = defineMethodV2('sendVCard', {
|
|
269
|
+
meta: {
|
|
270
|
+
description: 'Sends a contact card (vCard)',
|
|
271
|
+
action: 'send',
|
|
272
|
+
namespace: 'messages',
|
|
273
|
+
license: 'none',
|
|
274
|
+
functionality: 'both',
|
|
275
|
+
httpMethod: 'POST',
|
|
276
|
+
},
|
|
277
|
+
input: z.object({
|
|
278
|
+
to: toParam,
|
|
279
|
+
vcard: z.string().describe('vCard string'),
|
|
280
|
+
contactName: z.string().optional().describe('Contact display name'),
|
|
281
|
+
contactNumber: z.string().optional().describe('Contact number with country code')
|
|
282
|
+
}),
|
|
283
|
+
parameterOrder: ['to', 'vcard', 'contactName', 'contactNumber'],
|
|
284
|
+
output: z.boolean()
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Sends a contact
|
|
289
|
+
*/
|
|
290
|
+
export const sendContact = defineMethodV2('sendContact', {
|
|
291
|
+
meta: {
|
|
292
|
+
description: 'Sends a single contact',
|
|
293
|
+
action: 'send',
|
|
294
|
+
namespace: 'messages',
|
|
295
|
+
license: 'none',
|
|
296
|
+
functionality: 'both',
|
|
297
|
+
httpMethod: 'POST',
|
|
298
|
+
},
|
|
299
|
+
input: z.object({
|
|
300
|
+
to: toParam,
|
|
301
|
+
contactId: contactIdParam.or(z.array(contactIdParam))
|
|
302
|
+
}),
|
|
303
|
+
parameterOrder: ['to', 'contactId'],
|
|
304
|
+
output: MessageIdReturnSchema.or(z.boolean()).or(z.void())
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Sends multiple contacts
|
|
309
|
+
*/
|
|
310
|
+
export const sendMultipleContacts = defineMethodV2('sendMultipleContacts', {
|
|
311
|
+
meta: {
|
|
312
|
+
description: 'Sends multiple contacts',
|
|
313
|
+
action: 'send',
|
|
314
|
+
namespace: 'messages',
|
|
315
|
+
license: 'none',
|
|
316
|
+
functionality: 'both',
|
|
317
|
+
httpMethod: 'POST',
|
|
318
|
+
aliases: {
|
|
319
|
+
explicit: ['sendContacts'],
|
|
320
|
+
namespacedName: 'sendContacts',
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
input: z.object({
|
|
324
|
+
to: toParam,
|
|
325
|
+
contactIds: z.array(contactIdParam)
|
|
326
|
+
}),
|
|
327
|
+
parameterOrder: ['to', 'contactIds'],
|
|
328
|
+
output: MessageIdReturnSchema.or(z.boolean())
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Sends button message
|
|
333
|
+
*/
|
|
334
|
+
export const sendButtons = defineMethodV2('sendButtons', {
|
|
335
|
+
meta: {
|
|
336
|
+
description: 'Sends a button message (deprecated)',
|
|
337
|
+
action: 'send',
|
|
338
|
+
namespace: 'messages',
|
|
339
|
+
license: 'insiders',
|
|
340
|
+
functionality: 'both',
|
|
341
|
+
httpMethod: 'POST',
|
|
342
|
+
},
|
|
343
|
+
input: z.object({
|
|
344
|
+
to: toParam,
|
|
345
|
+
body: z.union([z.string(), z.any()]).describe('Message body or location'),
|
|
346
|
+
buttons: z.array(z.any()).max(3).describe('Array of buttons (max 3)'),
|
|
347
|
+
title: z.string().optional().describe('Message title'),
|
|
348
|
+
footer: z.string().optional().describe('Message footer')
|
|
349
|
+
}),
|
|
350
|
+
parameterOrder: ['to', 'body', 'buttons', 'title', 'footer'],
|
|
351
|
+
output: MessageIdReturnSchema.or(z.boolean())
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Sends advanced button message
|
|
356
|
+
*/
|
|
357
|
+
export const sendAdvancedButtons = defineMethodV2('sendAdvancedButtons', {
|
|
358
|
+
meta: {
|
|
359
|
+
description: 'Sends an advanced button message with media (deprecated)',
|
|
360
|
+
action: 'send',
|
|
361
|
+
namespace: 'messages',
|
|
362
|
+
license: 'insiders',
|
|
363
|
+
functionality: 'both',
|
|
364
|
+
httpMethod: 'POST',
|
|
365
|
+
},
|
|
366
|
+
input: z.object({
|
|
367
|
+
to: toParam,
|
|
368
|
+
body: z.union([z.string(), z.any()]).describe('Message body, location, or media'),
|
|
369
|
+
buttons: z.array(z.any()).max(3).describe('Array of advanced buttons (max 3)'),
|
|
370
|
+
text: z.string().describe('Message text'),
|
|
371
|
+
footer: z.string().describe('Message footer'),
|
|
372
|
+
filename: z.string().describe('Filename if body is a file')
|
|
373
|
+
}),
|
|
374
|
+
parameterOrder: ['to', 'body', 'buttons', 'text', 'footer', 'filename'],
|
|
375
|
+
output: MessageIdReturnSchema.or(z.boolean())
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Sends list message
|
|
380
|
+
*/
|
|
381
|
+
export const sendListMessage = defineMethodV2('sendListMessage', {
|
|
382
|
+
meta: {
|
|
383
|
+
description: 'Sends a list/menu message (deprecated)',
|
|
384
|
+
action: 'send',
|
|
385
|
+
namespace: 'messages',
|
|
386
|
+
license: 'insiders',
|
|
387
|
+
functionality: 'both',
|
|
388
|
+
httpMethod: 'POST',
|
|
389
|
+
aliases: {
|
|
390
|
+
explicit: ['sendList'],
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
input: z.object({
|
|
394
|
+
to: toParam,
|
|
395
|
+
sections: z.array(z.any()).describe('List sections'),
|
|
396
|
+
title: z.string().describe('List title'),
|
|
397
|
+
description: z.string().describe('List description'),
|
|
398
|
+
actionText: z.string().describe('Action button text')
|
|
399
|
+
}),
|
|
400
|
+
parameterOrder: ['to', 'sections', 'title', 'description', 'actionText'],
|
|
401
|
+
output: MessageIdReturnSchema.or(z.boolean())
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Sends a poll
|
|
406
|
+
*/
|
|
407
|
+
export const sendPoll = defineMethodV2('sendPoll', {
|
|
408
|
+
meta: {
|
|
409
|
+
description: 'Sends a poll message',
|
|
410
|
+
action: 'send',
|
|
411
|
+
namespace: 'messages',
|
|
412
|
+
license: 'none',
|
|
413
|
+
functionality: 'both',
|
|
414
|
+
httpMethod: 'POST',
|
|
415
|
+
},
|
|
416
|
+
input: z.object({
|
|
417
|
+
to: toParam,
|
|
418
|
+
name: z.string().describe('Poll question'),
|
|
419
|
+
options: z.array(z.string()).min(2).max(12).describe('Poll options (2-12)'),
|
|
420
|
+
selectableCount: z.number().optional().default(1).describe('Number of selectable options')
|
|
421
|
+
}),
|
|
422
|
+
parameterOrder: ['to', 'name', 'options', 'selectableCount'],
|
|
423
|
+
output: MessageIdReturnSchema.or(z.boolean())
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Sends a banner image
|
|
428
|
+
*/
|
|
429
|
+
export const sendBanner = defineMethodV2('sendBanner', {
|
|
430
|
+
meta: {
|
|
431
|
+
description: 'Sends a banner image',
|
|
432
|
+
action: 'send',
|
|
433
|
+
namespace: 'messages',
|
|
434
|
+
license: 'none',
|
|
435
|
+
functionality: 'both',
|
|
436
|
+
httpMethod: 'POST',
|
|
437
|
+
},
|
|
438
|
+
input: z.object({
|
|
439
|
+
to: toParam,
|
|
440
|
+
base64: z.string().describe('Base64 encoded JPEG')
|
|
441
|
+
}),
|
|
442
|
+
parameterOrder: ['to', 'base64'],
|
|
443
|
+
output: MessageIdReturnSchema.or(z.boolean())
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Sends YouTube link with preview
|
|
448
|
+
*/
|
|
449
|
+
export const sendYouTubeLink = defineMethodV2('sendYouTubeLink', {
|
|
450
|
+
meta: {
|
|
451
|
+
description: 'Sends a YouTube link with auto-generated preview',
|
|
452
|
+
action: 'send',
|
|
453
|
+
namespace: 'messages',
|
|
454
|
+
license: 'none',
|
|
455
|
+
functionality: 'both',
|
|
456
|
+
httpMethod: 'POST',
|
|
457
|
+
aliases: {
|
|
458
|
+
deprecated: ['sendYoutubeLink'],
|
|
459
|
+
},
|
|
460
|
+
wapiOverride: 'sendYoutubeLink',
|
|
461
|
+
},
|
|
462
|
+
input: z.object({
|
|
463
|
+
to: toParam,
|
|
464
|
+
url: z.string().url().describe('YouTube URL'),
|
|
465
|
+
text: contentParam.optional().default(''),
|
|
466
|
+
thumbnail: z.string().optional().describe('Base64 thumbnail override'),
|
|
467
|
+
quotedMsgId: messageIdParam.optional(),
|
|
468
|
+
customSize: z.object({
|
|
469
|
+
height: z.number(),
|
|
470
|
+
width: z.number()
|
|
471
|
+
}).optional().describe('Custom thumbnail size')
|
|
472
|
+
}),
|
|
473
|
+
parameterOrder: ['to', 'url', 'text', 'thumbnail', 'quotedMsgId', 'customSize'],
|
|
474
|
+
output: MessageIdReturnSchema.or(z.boolean())
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Sends link with auto preview
|
|
479
|
+
*/
|
|
480
|
+
export const sendLinkWithAutoPreview = defineMethodV2('sendLinkWithAutoPreview', {
|
|
481
|
+
meta: {
|
|
482
|
+
description: 'Sends a link with auto-generated preview',
|
|
483
|
+
action: 'send',
|
|
484
|
+
namespace: 'messages',
|
|
485
|
+
license: 'none',
|
|
486
|
+
functionality: 'both',
|
|
487
|
+
httpMethod: 'POST',
|
|
488
|
+
aliases: {
|
|
489
|
+
explicit: ['sendLink'],
|
|
490
|
+
},
|
|
491
|
+
},
|
|
492
|
+
input: z.object({
|
|
493
|
+
to: toParam,
|
|
494
|
+
url: z.string().url().describe('Link URL'),
|
|
495
|
+
text: contentParam.optional(),
|
|
496
|
+
thumbnail: z.string().optional().describe('Base64 thumbnail override'),
|
|
497
|
+
quotedMsgId: messageIdParam.optional(),
|
|
498
|
+
customSize: z.object({
|
|
499
|
+
height: z.number(),
|
|
500
|
+
width: z.number()
|
|
501
|
+
}).optional().describe('Custom thumbnail size')
|
|
502
|
+
}),
|
|
503
|
+
parameterOrder: ['to', 'url', 'text', 'thumbnail', 'quotedMsgId', 'customSize'],
|
|
504
|
+
output: MessageIdReturnSchema.or(z.boolean())
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Sends message with custom thumbnail
|
|
509
|
+
*/
|
|
510
|
+
export const sendMessageWithThumb = defineMethodV2('sendMessageWithThumb', {
|
|
511
|
+
meta: {
|
|
512
|
+
description: 'Sends a link preview message with custom thumbnail',
|
|
513
|
+
action: 'send',
|
|
514
|
+
namespace: 'messages',
|
|
515
|
+
license: 'none',
|
|
516
|
+
functionality: 'both',
|
|
517
|
+
httpMethod: 'POST',
|
|
518
|
+
aliases: {
|
|
519
|
+
explicit: ['sendLinkWithThumbnail'],
|
|
520
|
+
namespacedName: 'sendLinkWithThumbnail',
|
|
521
|
+
},
|
|
522
|
+
},
|
|
523
|
+
input: z.object({
|
|
524
|
+
thumb: z.string().describe('Base64 thumbnail (max 200x200px)'),
|
|
525
|
+
url: z.string().url().describe('Link URL'),
|
|
526
|
+
title: z.string().describe('Link title'),
|
|
527
|
+
description: z.string().describe('Link description'),
|
|
528
|
+
content: contentParam,
|
|
529
|
+
to: toParam,
|
|
530
|
+
quotedMsgId: messageIdParam.optional(),
|
|
531
|
+
customSize: z.object({
|
|
532
|
+
height: z.number(),
|
|
533
|
+
width: z.number()
|
|
534
|
+
}).optional().describe('Custom thumbnail size')
|
|
535
|
+
}),
|
|
536
|
+
parameterOrder: ['thumb', 'url', 'title', 'description', 'content', 'to', 'quotedMsgId', 'customSize'],
|
|
537
|
+
output: MessageIdReturnSchema.or(z.boolean())
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Forwards messages to a chat
|
|
542
|
+
*/
|
|
543
|
+
export const forwardMessages = defineMethodV2('forwardMessages', {
|
|
544
|
+
meta: {
|
|
545
|
+
description: 'Forwards messages to a chat',
|
|
546
|
+
action: 'send',
|
|
547
|
+
namespace: 'messages',
|
|
548
|
+
license: 'none',
|
|
549
|
+
functionality: 'both',
|
|
550
|
+
httpMethod: 'POST',
|
|
551
|
+
aliases: {
|
|
552
|
+
namespacedName: 'forward',
|
|
553
|
+
},
|
|
554
|
+
},
|
|
555
|
+
input: z.object({
|
|
556
|
+
to: toParam,
|
|
557
|
+
messages: messageIdsParam,
|
|
558
|
+
skipMyMessages: skipMyMessagesParam
|
|
559
|
+
}),
|
|
560
|
+
parameterOrder: ['to', 'messages', 'skipMyMessages'],
|
|
561
|
+
output: z.array(MessageIdReturnSchema).or(z.boolean())
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Deletes a message
|
|
566
|
+
*/
|
|
567
|
+
export const deleteMessage = defineMethodV2('deleteMessage', {
|
|
568
|
+
meta: {
|
|
569
|
+
description: 'Deletes a message',
|
|
570
|
+
action: 'delete',
|
|
571
|
+
namespace: 'messages',
|
|
572
|
+
license: 'none',
|
|
573
|
+
functionality: 'both',
|
|
574
|
+
httpMethod: 'DELETE',
|
|
575
|
+
aliases: {
|
|
576
|
+
namespacedName: 'delete',
|
|
577
|
+
},
|
|
578
|
+
},
|
|
579
|
+
input: z.object({
|
|
580
|
+
chatId: chatIdParam,
|
|
581
|
+
messageId: messageIdsParam,
|
|
582
|
+
onlyLocal: z.boolean().optional().default(false).describe('Delete only locally')
|
|
583
|
+
}),
|
|
584
|
+
parameterOrder: ['chatId', 'messageId', 'onlyLocal'],
|
|
585
|
+
output: z.boolean()
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Retrieves a specific message by ID
|
|
590
|
+
*/
|
|
591
|
+
export const getMessageById = defineMethodV2('getMessageById', {
|
|
592
|
+
meta: {
|
|
593
|
+
description: 'Retrieves a specific message by ID',
|
|
594
|
+
action: 'read',
|
|
595
|
+
namespace: 'messages',
|
|
596
|
+
license: 'none',
|
|
597
|
+
functionality: 'both',
|
|
598
|
+
httpMethod: 'GET',
|
|
599
|
+
aliases: {
|
|
600
|
+
explicit: ['getMessage'],
|
|
601
|
+
namespacedName: 'get',
|
|
602
|
+
},
|
|
603
|
+
},
|
|
604
|
+
input: z.object({
|
|
605
|
+
messageId: messageIdParam
|
|
606
|
+
}),
|
|
607
|
+
parameterOrder: ['messageId'],
|
|
608
|
+
output: MessageSchema.nullable().or(z.literal(false)),
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Retrieves all messages in the session
|
|
613
|
+
*/
|
|
614
|
+
export const getAllMessages = defineMethodV2('getAllMessages', {
|
|
615
|
+
meta: {
|
|
616
|
+
description: 'Retrieves all messages in the session',
|
|
617
|
+
action: 'read',
|
|
618
|
+
namespace: 'messages',
|
|
619
|
+
license: 'none',
|
|
620
|
+
functionality: 'both',
|
|
621
|
+
httpMethod: 'GET',
|
|
622
|
+
},
|
|
623
|
+
input: z.object({
|
|
624
|
+
chatId: chatIdParam.optional(),
|
|
625
|
+
includeMe: z.boolean().optional().default(true).describe('Include own messages'),
|
|
626
|
+
includeNotifications: z.boolean().optional().default(false).describe('Include notification messages'),
|
|
627
|
+
}),
|
|
628
|
+
parameterOrder: ['chatId', 'includeMe', 'includeNotifications'],
|
|
629
|
+
output: z.array(MessageSchema),
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
export const getMyLastMessage = defineMethodV2('getMyLastMessage', {
|
|
633
|
+
meta: {
|
|
634
|
+
description: 'Get last message sent by host',
|
|
635
|
+
action: 'read',
|
|
636
|
+
namespace: 'messages',
|
|
637
|
+
license: 'none',
|
|
638
|
+
functionality: 'both',
|
|
639
|
+
httpMethod: 'GET',
|
|
640
|
+
},
|
|
641
|
+
input: z.object({
|
|
642
|
+
chatId: chatIdParam.optional(),
|
|
643
|
+
}),
|
|
644
|
+
parameterOrder: ['chatId'],
|
|
645
|
+
output: MessageSchema.optional(),
|
|
646
|
+
});
|
|
647
|
+
|
|
648
|
+
export const getStarredMessages = defineMethodV2('getStarredMessages', {
|
|
649
|
+
meta: {
|
|
650
|
+
description: 'Get starred messages',
|
|
651
|
+
action: 'read',
|
|
652
|
+
namespace: 'messages',
|
|
653
|
+
license: 'insiders',
|
|
654
|
+
functionality: 'both',
|
|
655
|
+
httpMethod: 'GET',
|
|
656
|
+
},
|
|
657
|
+
input: z.object({
|
|
658
|
+
chatId: chatIdParam.optional(),
|
|
659
|
+
}),
|
|
660
|
+
parameterOrder: ['chatId'],
|
|
661
|
+
output: z.array(MessageSchema),
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
export const getUnsentMessages = defineMethodV2('getUnsentMessages', {
|
|
665
|
+
meta: {
|
|
666
|
+
description: 'Get unsent/pending messages',
|
|
667
|
+
action: 'read',
|
|
668
|
+
namespace: 'messages',
|
|
669
|
+
license: 'none',
|
|
670
|
+
functionality: 'both',
|
|
671
|
+
httpMethod: 'GET',
|
|
672
|
+
},
|
|
673
|
+
input: z.object({}),
|
|
674
|
+
parameterOrder: [],
|
|
675
|
+
output: z.array(MessageSchema),
|
|
676
|
+
});
|
|
677
|
+
|
|
678
|
+
export const getMessageInfo = defineMethodV2('getMessageInfo', {
|
|
679
|
+
meta: {
|
|
680
|
+
description: 'Get message delivery info',
|
|
681
|
+
action: 'read',
|
|
682
|
+
namespace: 'messages',
|
|
683
|
+
license: 'none',
|
|
684
|
+
functionality: 'both',
|
|
685
|
+
httpMethod: 'GET',
|
|
686
|
+
},
|
|
687
|
+
input: z.object({
|
|
688
|
+
messageId: messageIdParam,
|
|
689
|
+
}),
|
|
690
|
+
parameterOrder: ['messageId'],
|
|
691
|
+
output: MessageInfoSchema,
|
|
692
|
+
});
|
|
693
|
+
|
|
694
|
+
export const getVCards = defineMethodV2('getVCards', {
|
|
695
|
+
meta: {
|
|
696
|
+
description: 'Extract vCards from message',
|
|
697
|
+
action: 'read',
|
|
698
|
+
namespace: 'messages',
|
|
699
|
+
license: 'none',
|
|
700
|
+
functionality: 'both',
|
|
701
|
+
httpMethod: 'GET',
|
|
702
|
+
},
|
|
703
|
+
input: z.object({
|
|
704
|
+
messageId: messageIdParam,
|
|
705
|
+
}),
|
|
706
|
+
parameterOrder: ['messageId'],
|
|
707
|
+
output: z.array(z.string()),
|
|
708
|
+
});
|
|
709
|
+
|
|
710
|
+
export const getMessagesForLLM = defineMethodV2('getMessagesForLLM', {
|
|
711
|
+
meta: {
|
|
712
|
+
description: 'Get messages formatted for LLMs',
|
|
713
|
+
action: 'read',
|
|
714
|
+
namespace: 'messages',
|
|
715
|
+
license: 'none',
|
|
716
|
+
functionality: 'both',
|
|
717
|
+
httpMethod: 'GET',
|
|
718
|
+
aliases: {
|
|
719
|
+
deprecated: ['getGptArray'],
|
|
720
|
+
},
|
|
721
|
+
wapiOverride: 'getGptArray',
|
|
722
|
+
},
|
|
723
|
+
input: z.object({
|
|
724
|
+
chatId: chatIdParam,
|
|
725
|
+
last: z.number().optional().default(10),
|
|
726
|
+
}),
|
|
727
|
+
parameterOrder: ['chatId', 'last'],
|
|
728
|
+
output: z.array(LLMMessageSchema),
|
|
729
|
+
});
|
|
730
|
+
|
|
731
|
+
export const starMessage = defineMethodV2('starMessage', {
|
|
732
|
+
meta: {
|
|
733
|
+
description: 'Star a message',
|
|
734
|
+
action: 'update',
|
|
735
|
+
namespace: 'messages',
|
|
736
|
+
license: 'none',
|
|
737
|
+
functionality: 'both',
|
|
738
|
+
httpMethod: 'PUT',
|
|
739
|
+
},
|
|
740
|
+
input: z.object({
|
|
741
|
+
messageId: messageIdParam,
|
|
742
|
+
}),
|
|
743
|
+
parameterOrder: ['messageId'],
|
|
744
|
+
output: z.boolean(),
|
|
745
|
+
});
|
|
746
|
+
|
|
747
|
+
export const unstarMessage = defineMethodV2('unstarMessage', {
|
|
748
|
+
meta: {
|
|
749
|
+
description: 'Unstar a message',
|
|
750
|
+
action: 'update',
|
|
751
|
+
namespace: 'messages',
|
|
752
|
+
license: 'none',
|
|
753
|
+
functionality: 'both',
|
|
754
|
+
httpMethod: 'PUT',
|
|
755
|
+
},
|
|
756
|
+
input: z.object({
|
|
757
|
+
messageId: messageIdParam,
|
|
758
|
+
}),
|
|
759
|
+
parameterOrder: ['messageId'],
|
|
760
|
+
output: z.boolean(),
|
|
761
|
+
});
|
|
762
|
+
|
|
763
|
+
export const react = defineMethodV2('react', {
|
|
764
|
+
meta: {
|
|
765
|
+
description: 'React to message with emoji',
|
|
766
|
+
action: 'send',
|
|
767
|
+
namespace: 'messages',
|
|
768
|
+
license: 'none',
|
|
769
|
+
functionality: 'both',
|
|
770
|
+
httpMethod: 'POST',
|
|
771
|
+
},
|
|
772
|
+
input: z.object({
|
|
773
|
+
messageId: messageIdParam,
|
|
774
|
+
emoji: z.string().describe('Emoji reaction'),
|
|
775
|
+
}),
|
|
776
|
+
parameterOrder: ['messageId', 'emoji'],
|
|
777
|
+
output: z.boolean(),
|
|
778
|
+
});
|
|
779
|
+
|
|
780
|
+
export const sendSeen = defineMethodV2('sendSeen', {
|
|
781
|
+
meta: {
|
|
782
|
+
description: 'Mark message as seen',
|
|
783
|
+
action: 'update',
|
|
784
|
+
namespace: 'messages',
|
|
785
|
+
license: 'none',
|
|
786
|
+
functionality: 'both',
|
|
787
|
+
httpMethod: 'PUT',
|
|
788
|
+
},
|
|
789
|
+
input: z.object({
|
|
790
|
+
chatId: chatIdParam,
|
|
791
|
+
}),
|
|
792
|
+
parameterOrder: ['chatId'],
|
|
793
|
+
output: z.boolean(),
|
|
794
|
+
});
|
|
795
|
+
|
|
796
|
+
export const loadEarlierMessages = defineMethodV2('loadEarlierMessages', {
|
|
797
|
+
meta: {
|
|
798
|
+
description: 'Loads earlier messages from a chat',
|
|
799
|
+
action: 'read',
|
|
800
|
+
namespace: 'messages',
|
|
801
|
+
license: 'none',
|
|
802
|
+
functionality: 'both',
|
|
803
|
+
httpMethod: 'POST',
|
|
804
|
+
aliases: {
|
|
805
|
+
explicit: ['loadOlderMessages'],
|
|
806
|
+
namespacedName: 'loadEarlier',
|
|
807
|
+
},
|
|
808
|
+
},
|
|
809
|
+
input: z.object({
|
|
810
|
+
chatId: chatIdParam,
|
|
811
|
+
count: z.number().positive().optional().describe('Number of messages to load (default: 20)'),
|
|
812
|
+
includeMe: z.boolean().optional().describe('Whether to include messages from the host account (default: false)'),
|
|
813
|
+
}),
|
|
814
|
+
parameterOrder: ['chatId', 'count', 'includeMe'],
|
|
815
|
+
output: z.array(MessageSchema),
|
|
816
|
+
});
|
|
817
|
+
|
|
818
|
+
export const sendFileFromUrl = defineMethodV2('sendFileFromUrl', {
|
|
819
|
+
meta: {
|
|
820
|
+
description: 'Downloads a file from a URL and sends it to a chat',
|
|
821
|
+
action: 'send',
|
|
822
|
+
namespace: 'messages',
|
|
823
|
+
license: 'none',
|
|
824
|
+
functionality: 'both',
|
|
825
|
+
httpMethod: 'POST',
|
|
826
|
+
},
|
|
827
|
+
input: z.object({
|
|
828
|
+
to: toParam,
|
|
829
|
+
url: z.string().url().describe('URL of the file to download'),
|
|
830
|
+
filename: z.string().describe('Filename for the sent file'),
|
|
831
|
+
caption: z.string().optional().describe('Caption for the file'),
|
|
832
|
+
headers: z.record(z.string(), z.string()).optional().describe('HTTP headers for the download request'),
|
|
833
|
+
}),
|
|
834
|
+
parameterOrder: ['to', 'url', 'filename', 'caption', 'headers'],
|
|
835
|
+
output: z.string().or(z.boolean()).describe('Message ID or success status'),
|
|
836
|
+
});
|