@kyyinfinite/baileys 1.0.0 → 2.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/README.md +408 -64
- package/WAProto/WAProto.proto +360 -916
- package/WAProto/fix-imports.js +22 -18
- package/WAProto/index.d.ts +14015 -0
- package/WAProto/index.js +47122 -81757
- package/engine-requirements.js +10 -0
- package/lib/Defaults/index.d.ts +15 -14
- package/lib/Defaults/index.d.ts.map +1 -1
- package/lib/Defaults/index.js +99 -107
- package/lib/Defaults/index.js.map +1 -1
- package/lib/Kyyinfinite/AIRich.js +2041 -0
- package/lib/Kyyinfinite/BaseBuilder.js +64 -0
- package/lib/Kyyinfinite/Button.js +341 -0
- package/lib/Kyyinfinite/ButtonV2.js +175 -0
- package/lib/Kyyinfinite/Carousel.js +125 -0
- package/lib/Kyyinfinite/Foad.js +542 -0
- package/lib/Kyyinfinite/Foad2.js +466 -0
- package/lib/Kyyinfinite/Simple/AIBuilder.js +18 -0
- package/lib/Kyyinfinite/Simple/BuilderFactories.js +17 -0
- package/lib/Kyyinfinite/Simple/ButtonBuilder.js +107 -0
- package/lib/Kyyinfinite/Simple/CardBuilder.js +179 -0
- package/lib/Kyyinfinite/Simple/CarouselBuilder.js +97 -0
- package/lib/Kyyinfinite/Simple/FoadBuilder.js +18 -0
- package/lib/Kyyinfinite/Simple/MediaBuilder.js +35 -0
- package/lib/Kyyinfinite/Simple/MessageBuilder.js +41 -0
- package/lib/Kyyinfinite/Simple/MessageTypesBuilder.js +3 -0
- package/lib/Kyyinfinite/Simple/SimpleBuilder.js +28 -0
- package/lib/Kyyinfinite/Simple/SimpleClient.js +83 -0
- package/lib/Kyyinfinite/Simple/TextBuilder.js +22 -0
- package/lib/Kyyinfinite/Simple/index.d.ts +141 -0
- package/lib/Kyyinfinite/Simple/index.js +31 -0
- package/lib/Kyyinfinite/Toolkit.js +453 -0
- package/lib/Kyyinfinite/constants.js +1 -0
- package/lib/Kyyinfinite/errors.js +39 -0
- package/lib/Kyyinfinite/index.d.ts +2 -0
- package/lib/Kyyinfinite/index.js +2 -0
- package/lib/Kyyinfinite/wrapper.d.ts +2 -0
- package/lib/Kyyinfinite/wrapper.js +10 -0
- package/lib/Signal/Group/group_cipher.js.map +1 -1
- package/lib/Signal/Group/keyhelper.d.ts.map +1 -1
- package/lib/Signal/Group/keyhelper.js.map +1 -1
- package/lib/Signal/Group/sender-chain-key.js.map +1 -1
- package/lib/Signal/Group/sender-key-message.js.map +1 -1
- package/lib/Signal/Group/sender-message-key.js.map +1 -1
- package/lib/Signal/libsignal.d.ts.map +1 -1
- package/lib/Signal/libsignal.js +45 -17
- package/lib/Signal/libsignal.js.map +1 -1
- package/lib/Signal/lid-mapping.d.ts +4 -0
- package/lib/Signal/lid-mapping.d.ts.map +1 -1
- package/lib/Signal/lid-mapping.js +6 -0
- package/lib/Signal/lid-mapping.js.map +1 -1
- package/lib/Socket/business.d.ts +213 -532
- package/lib/Socket/business.d.ts.map +1 -1
- package/lib/Socket/business.js +358 -401
- package/lib/Socket/chats.d.ts +16 -2
- package/lib/Socket/chats.d.ts.map +1 -1
- package/lib/Socket/chats.js +247 -40
- package/lib/Socket/chats.js.map +1 -1
- package/lib/Socket/communities.d.ts +269 -641
- package/lib/Socket/communities.d.ts.map +1 -1
- package/lib/Socket/groups.d.ts +13 -2
- package/lib/Socket/groups.d.ts.map +1 -1
- package/lib/Socket/groups.js +21 -1
- package/lib/Socket/groups.js.map +1 -1
- package/lib/Socket/index.d.ts +255 -631
- package/lib/Socket/index.d.ts.map +1 -1
- package/lib/Socket/index.js +9 -10
- package/lib/Socket/index.js.map +1 -1
- package/lib/Socket/messages-recv.d.ts +23 -58
- package/lib/Socket/messages-recv.d.ts.map +1 -1
- package/lib/Socket/messages-recv.js +645 -181
- package/lib/Socket/messages-recv.js.map +1 -1
- package/lib/Socket/messages-send.d.ts +195 -575
- package/lib/Socket/messages-send.d.ts.map +1 -1
- package/lib/Socket/messages-send.js +1099 -1549
- package/lib/Socket/messages-send.js.map +1 -1
- package/lib/Socket/mex.d.ts.map +1 -1
- package/lib/Socket/mex.js +2 -8
- package/lib/Socket/mex.js.map +1 -1
- package/lib/Socket/newsletter.d.ts +11 -18
- package/lib/Socket/newsletter.d.ts.map +1 -1
- package/lib/Socket/newsletter.js +167 -302
- package/lib/Socket/newsletter.js.map +1 -1
- package/lib/Socket/socket.d.ts +6 -2
- package/lib/Socket/socket.d.ts.map +1 -1
- package/lib/Socket/socket.js +59 -25
- package/lib/Socket/socket.js.map +1 -1
- package/lib/Types/Auth.d.ts +1 -0
- package/lib/Types/Auth.d.ts.map +1 -1
- package/lib/Types/Bussines.d.ts +22 -34
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Call.d.ts.map +1 -1
- package/lib/Types/Chat.d.ts +1 -0
- package/lib/Types/Chat.d.ts.map +1 -1
- package/lib/Types/Contact.d.ts +2 -0
- package/lib/Types/Contact.d.ts.map +1 -1
- package/lib/Types/Events.d.ts +20 -1
- package/lib/Types/Events.d.ts.map +1 -1
- package/lib/Types/GroupMetadata.d.ts +4 -1
- package/lib/Types/GroupMetadata.d.ts.map +1 -1
- package/lib/Types/Message.d.ts +239 -341
- package/lib/Types/Message.d.ts.map +1 -1
- package/lib/Types/Message.js.map +1 -1
- package/lib/Types/{Newsletter.d.ts → Mex.d.ts} +11 -5
- package/lib/Types/Mex.d.ts.map +1 -0
- package/lib/Types/{Newsletter.js → Mex.js} +9 -3
- package/lib/Types/Mex.js.map +1 -0
- package/lib/Types/Signal.d.ts +12 -1
- package/lib/Types/Signal.d.ts.map +1 -1
- package/lib/Types/Socket.d.ts +126 -148
- package/lib/Types/Socket.d.ts.map +1 -1
- package/lib/Types/State.d.ts +58 -0
- package/lib/Types/State.d.ts.map +1 -1
- package/lib/Types/State.js +43 -0
- package/lib/Types/State.js.map +1 -1
- package/lib/Types/index.d.ts +52 -52
- package/lib/Types/index.d.ts.map +1 -1
- package/lib/Types/index.js +23 -30
- package/lib/Types/index.js.map +1 -1
- package/lib/Utils/auth-utils.d.ts +5 -0
- package/lib/Utils/auth-utils.d.ts.map +1 -1
- package/lib/Utils/auth-utils.js +12 -0
- package/lib/Utils/auth-utils.js.map +1 -1
- package/lib/Utils/browser-utils.d.ts.map +1 -1
- package/lib/Utils/browser-utils.js +1 -0
- package/lib/Utils/browser-utils.js.map +1 -1
- package/lib/Utils/chat-utils.d.ts +34 -4
- package/lib/Utils/chat-utils.d.ts.map +1 -1
- package/lib/Utils/chat-utils.js +80 -20
- package/lib/Utils/chat-utils.js.map +1 -1
- package/lib/Utils/companion-reg-client-utils.d.ts +17 -0
- package/lib/Utils/companion-reg-client-utils.d.ts.map +1 -0
- package/lib/Utils/companion-reg-client-utils.js +35 -0
- package/lib/Utils/companion-reg-client-utils.js.map +1 -0
- package/lib/Utils/crypto.d.ts +12 -12
- package/lib/Utils/crypto.d.ts.map +1 -1
- package/lib/Utils/crypto.js.map +1 -1
- package/lib/Utils/decode-wa-message.d.ts +18 -0
- package/lib/Utils/decode-wa-message.d.ts.map +1 -1
- package/lib/Utils/decode-wa-message.js +34 -0
- package/lib/Utils/decode-wa-message.js.map +1 -1
- package/lib/Utils/event-buffer.d.ts +2 -0
- package/lib/Utils/event-buffer.d.ts.map +1 -1
- package/lib/Utils/event-buffer.js +49 -1
- package/lib/Utils/event-buffer.js.map +1 -1
- package/lib/Utils/generics.d.ts +3 -2
- package/lib/Utils/generics.d.ts.map +1 -1
- package/lib/Utils/generics.js +10 -1
- package/lib/Utils/generics.js.map +1 -1
- package/lib/Utils/history.d.ts +2 -0
- package/lib/Utils/history.d.ts.map +1 -1
- package/lib/Utils/history.js +12 -9
- package/lib/Utils/history.js.map +1 -1
- package/lib/Utils/identity-change-handler.d.ts +7 -0
- package/lib/Utils/identity-change-handler.d.ts.map +1 -1
- package/lib/Utils/identity-change-handler.js +1 -0
- package/lib/Utils/identity-change-handler.js.map +1 -1
- package/lib/Utils/index.d.ts +22 -25
- package/lib/Utils/index.d.ts.map +1 -1
- package/lib/Utils/index.js +2 -4
- package/lib/Utils/index.js.map +1 -1
- package/lib/Utils/link-preview.js +2 -2
- package/lib/Utils/link-preview.js.map +1 -1
- package/lib/Utils/logger.d.ts +1 -2
- package/lib/Utils/logger.d.ts.map +1 -1
- package/lib/Utils/message-retry-manager.d.ts +5 -0
- package/lib/Utils/message-retry-manager.d.ts.map +1 -1
- package/lib/Utils/message-retry-manager.js +40 -0
- package/lib/Utils/message-retry-manager.js.map +1 -1
- package/lib/Utils/messages-media.d.ts +16 -13
- package/lib/Utils/messages-media.d.ts.map +1 -1
- package/lib/Utils/messages-media.js +85 -79
- package/lib/Utils/messages-media.js.map +1 -1
- package/lib/Utils/messages.d.ts +1 -1
- package/lib/Utils/messages.d.ts.map +1 -1
- package/lib/Utils/messages.js +751 -1096
- package/lib/Utils/messages.js.map +1 -1
- package/lib/Utils/noise-handler.d.ts +1 -1
- package/lib/Utils/process-message.d.ts.map +1 -1
- package/lib/Utils/process-message.js +103 -1
- package/lib/Utils/process-message.js.map +1 -1
- package/lib/Utils/signal.d.ts +13 -0
- package/lib/Utils/signal.d.ts.map +1 -1
- package/lib/Utils/signal.js +42 -0
- package/lib/Utils/signal.js.map +1 -1
- package/lib/Utils/sync-action-utils.d.ts.map +1 -1
- package/lib/Utils/sync-action-utils.js +1 -0
- package/lib/Utils/sync-action-utils.js.map +1 -1
- package/lib/Utils/tc-token-utils.d.ts +26 -1
- package/lib/Utils/tc-token-utils.d.ts.map +1 -1
- package/lib/Utils/tc-token-utils.js +151 -5
- package/lib/Utils/tc-token-utils.js.map +1 -1
- package/lib/Utils/validate-connection.d.ts.map +1 -1
- package/lib/Utils/validate-connection.js +12 -2
- package/lib/Utils/validate-connection.js.map +1 -1
- package/lib/WABinary/decode.d.ts +1 -1
- package/lib/WABinary/decode.d.ts.map +1 -1
- package/lib/WABinary/generic-utils.d.ts +1 -3
- package/lib/WABinary/generic-utils.d.ts.map +1 -1
- package/lib/WABinary/generic-utils.js +0 -78
- package/lib/WABinary/generic-utils.js.map +1 -1
- package/lib/WAM/encode.d.ts +1 -1
- package/lib/WAM/encode.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +26 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +25 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/index.d.ts +1 -0
- package/lib/WAUSync/Protocols/index.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/index.js +1 -0
- package/lib/WAUSync/Protocols/index.js.map +1 -1
- package/lib/WAUSync/USyncQuery.d.ts +1 -0
- package/lib/WAUSync/USyncQuery.d.ts.map +1 -1
- package/lib/WAUSync/USyncQuery.js +6 -2
- package/lib/WAUSync/USyncQuery.js.map +1 -1
- package/lib/WAUSync/USyncUser.d.ts +4 -0
- package/lib/WAUSync/USyncUser.d.ts.map +1 -1
- package/lib/WAUSync/USyncUser.js +8 -0
- package/lib/WAUSync/USyncUser.js.map +1 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +13 -12
- package/lib/index.js.map +1 -1
- package/package.json +93 -23
- package/LICENSE +0 -21
- package/lib/Socket/dugong.d.ts +0 -130
- package/lib/Socket/dugong.d.ts.map +0 -1
- package/lib/Socket/dugong.js +0 -768
- package/lib/Socket/dugong.js.map +0 -1
- package/lib/Types/Newsletter.d.ts.map +0 -1
- package/lib/Types/Newsletter.js.map +0 -1
- package/lib/Utils/kyy-features.d.ts +0 -158
- package/lib/Utils/kyy-features.js +0 -365
- package/lib/Utils/rich-messages.d.ts +0 -277
- package/lib/Utils/rich-messages.d.ts.map +0 -1
- package/lib/Utils/rich-messages.js +0 -1144
- package/lib/Utils/rich-messages.js.map +0 -1
- package/lib/Utils/sticker-pack.d.ts +0 -10
- package/lib/Utils/sticker-pack.js +0 -111
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { prepareWAMessageMedia } from '../../Utils/messages.js'
|
|
2
|
+
|
|
3
|
+
export class CardBuilder {
|
|
4
|
+
constructor(parent, options = {}) {
|
|
5
|
+
this.parent = parent
|
|
6
|
+
this.card = {
|
|
7
|
+
header: {
|
|
8
|
+
hasMediaAttachment: false
|
|
9
|
+
},
|
|
10
|
+
body: { text: '' },
|
|
11
|
+
footer: { text: '' },
|
|
12
|
+
nativeFlowMessage: { buttons: [] }
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (options && typeof options === 'object') {
|
|
16
|
+
if (options.image !== undefined) this.image(options.image, options.imageOptions || {})
|
|
17
|
+
if (options.video !== undefined) this.video(options.video, options.videoOptions || {})
|
|
18
|
+
this.payload(options)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
title(value) {
|
|
23
|
+
this.card.header.title = String(value ?? '')
|
|
24
|
+
return this
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
body(value) {
|
|
28
|
+
this.card.body.text = String(value ?? '')
|
|
29
|
+
return this
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
text(value) {
|
|
33
|
+
return this.body(value)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
footer(value) {
|
|
37
|
+
this.card.footer.text = String(value ?? '')
|
|
38
|
+
return this
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
image(media, options = {}) {
|
|
42
|
+
this.card._media = { type: 'image', media, options }
|
|
43
|
+
return this
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
video(media, options = {}) {
|
|
47
|
+
this.card._media = { type: 'video', media, options }
|
|
48
|
+
return this
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
media(type, media, options = {}) {
|
|
52
|
+
if (type !== 'image' && type !== 'video') {
|
|
53
|
+
throw new TypeError('Carousel card media must be image or video')
|
|
54
|
+
}
|
|
55
|
+
return this[type](media, options)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
button(displayText, id, options = {}) {
|
|
59
|
+
return this._button('quick_reply', {
|
|
60
|
+
display_text: displayText,
|
|
61
|
+
id,
|
|
62
|
+
...options
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
reply(displayText, id, options = {}) {
|
|
67
|
+
return this.button(displayText, id, options)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
quickReply(displayText, id, options = {}) {
|
|
71
|
+
return this.button(displayText, id, options)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
url(displayText, url, options = {}) {
|
|
75
|
+
return this._button('cta_url', {
|
|
76
|
+
display_text: displayText,
|
|
77
|
+
url,
|
|
78
|
+
...options
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
copy(displayText, copyCode, options = {}) {
|
|
83
|
+
return this._button('cta_copy', {
|
|
84
|
+
display_text: displayText,
|
|
85
|
+
copy_code: copyCode,
|
|
86
|
+
...options
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
coppy(displayText, copyCode, options = {}) {
|
|
91
|
+
return this.copy(displayText, copyCode, options)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
call(displayText, phone, options = {}) {
|
|
95
|
+
return this._button('cta_call', {
|
|
96
|
+
display_text: displayText,
|
|
97
|
+
id: phone,
|
|
98
|
+
...options
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
buttons(buttons = []) {
|
|
103
|
+
if (!Array.isArray(buttons)) {
|
|
104
|
+
throw new TypeError('Buttons must be an array')
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
this.card.nativeFlowMessage.buttons.push(...buttons)
|
|
108
|
+
return this
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
rawButton(button) {
|
|
112
|
+
if (!button || typeof button !== 'object' || Array.isArray(button)) {
|
|
113
|
+
throw new TypeError('Button must be a plain object')
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
this.card.nativeFlowMessage.buttons.push(button)
|
|
117
|
+
return this
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
context(value) {
|
|
121
|
+
this.card.contextInfo = value || {}
|
|
122
|
+
return this
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
payload(value) {
|
|
126
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
127
|
+
return this
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const { header, body, footer, nativeFlowMessage, image, video, imageOptions, videoOptions, ...extra } = value
|
|
131
|
+
|
|
132
|
+
Object.assign(this.card, extra)
|
|
133
|
+
if (header) Object.assign(this.card.header, header)
|
|
134
|
+
if (body) Object.assign(this.card.body, body)
|
|
135
|
+
if (footer) Object.assign(this.card.footer, footer)
|
|
136
|
+
if (nativeFlowMessage) Object.assign(this.card.nativeFlowMessage, nativeFlowMessage)
|
|
137
|
+
|
|
138
|
+
return this
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
_button(name, params) {
|
|
142
|
+
this.card.nativeFlowMessage.buttons.push({
|
|
143
|
+
name,
|
|
144
|
+
buttonParamsJson: JSON.stringify(params)
|
|
145
|
+
})
|
|
146
|
+
return this
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async build() {
|
|
150
|
+
const { _media, ...card } = this.card
|
|
151
|
+
|
|
152
|
+
if (!_media) {
|
|
153
|
+
throw new Error('Carousel card requires image() or video()')
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const media = {
|
|
157
|
+
[_media.type]: _media.media,
|
|
158
|
+
..._media.options
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const prepared = await prepareWAMessageMedia(media, {
|
|
162
|
+
upload: this.parent.sock.waUploadToServer
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
card.header.hasMediaAttachment = true
|
|
166
|
+
card.header[`${_media.type}Message`] = prepared[`${_media.type}Message`]
|
|
167
|
+
|
|
168
|
+
return card
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
add() {
|
|
172
|
+
this.parent._cards.push(this)
|
|
173
|
+
return this.parent
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
end() {
|
|
177
|
+
return this.add()
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Carousel } from '../Carousel.js'
|
|
2
|
+
import { CardBuilder } from './CardBuilder.js'
|
|
3
|
+
|
|
4
|
+
const aliases = {
|
|
5
|
+
title: 'setTitle',
|
|
6
|
+
subtitle: 'setSubtitle',
|
|
7
|
+
body: 'setBody',
|
|
8
|
+
text: 'setBody',
|
|
9
|
+
footer: 'setFooter',
|
|
10
|
+
context: 'setContextInfo',
|
|
11
|
+
payload: 'addPayload'
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class CarouselBuilder {
|
|
15
|
+
constructor(sock, ...args) {
|
|
16
|
+
if (!sock) throw new Error('Socket is required')
|
|
17
|
+
|
|
18
|
+
this.sock = sock
|
|
19
|
+
this.raw = new Carousel(sock, ...args)
|
|
20
|
+
this._cards = []
|
|
21
|
+
this._rawCards = []
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
card(options = {}) {
|
|
25
|
+
return new CardBuilder(this, options)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
addCard(card) {
|
|
29
|
+
if (card instanceof CardBuilder) {
|
|
30
|
+
if (!this._cards.includes(card)) this._cards.push(card)
|
|
31
|
+
return this
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
this._rawCards.push(card)
|
|
35
|
+
return this
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
cards(cards = []) {
|
|
39
|
+
if (!Array.isArray(cards)) {
|
|
40
|
+
throw new TypeError('Cards must be an array')
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
for (const card of cards) this.addCard(card)
|
|
44
|
+
return this
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
clear() {
|
|
48
|
+
this._cards = []
|
|
49
|
+
this._rawCards = []
|
|
50
|
+
this.raw._cards = []
|
|
51
|
+
return this
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async _prepareCards() {
|
|
55
|
+
this.raw._cards = []
|
|
56
|
+
|
|
57
|
+
for (const card of this._rawCards) {
|
|
58
|
+
this.raw.addCard(card)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
for (const card of this._cards) {
|
|
62
|
+
this.raw.addCard(await card.build())
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return this.raw
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async build(jid, options = {}) {
|
|
69
|
+
await this._prepareCards()
|
|
70
|
+
return this.raw.build(jid, options)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async send(jid, options = {}) {
|
|
74
|
+
await this._prepareCards()
|
|
75
|
+
return this.raw.send(jid, options)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
loadFrom(message) {
|
|
79
|
+
this.raw.loadFrom(message)
|
|
80
|
+
this._cards = []
|
|
81
|
+
this._rawCards = [...this.raw._cards]
|
|
82
|
+
return this
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
for (const [name, method] of Object.entries(aliases)) {
|
|
87
|
+
CarouselBuilder.prototype[name] = function (...args) {
|
|
88
|
+
const value = this.raw[method](...args)
|
|
89
|
+
return value === this.raw ? this : value
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export { Carousel, CardBuilder }
|
|
94
|
+
|
|
95
|
+
export function createCarouselBuilder(sock, ...args) {
|
|
96
|
+
return new CarouselBuilder(sock, ...args)
|
|
97
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Foad } from '../Foad.js'
|
|
2
|
+
import { Foad2 } from '../Foad2.js'
|
|
3
|
+
import { proxyBuilder } from './SimpleBuilder.js'
|
|
4
|
+
|
|
5
|
+
const foadAliases = {
|
|
6
|
+
title: 'addTitle',
|
|
7
|
+
html: 'addHtml'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function createFoadBuilder(sock, ...args) {
|
|
11
|
+
return proxyBuilder({ sock, raw: new Foad(sock, ...args) }, foadAliases)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function createFoad2Builder(sock, ...args) {
|
|
15
|
+
return proxyBuilder({ sock, raw: new Foad2(sock, ...args) }, foadAliases)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { Foad, Foad2 }
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export class MediaBuilder {
|
|
2
|
+
constructor(sock, type, media) {
|
|
3
|
+
this.sock = sock
|
|
4
|
+
this.type = type
|
|
5
|
+
this.content = { [type]: media }
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
caption(value) { this.content.caption = String(value ?? ''); return this }
|
|
9
|
+
fileName(value) { this.content.fileName = String(value ?? ''); return this }
|
|
10
|
+
mimetype(value) { this.content.mimetype = value; return this }
|
|
11
|
+
context(value) { this.content.contextInfo = value || {}; return this }
|
|
12
|
+
mentions(value) { this.content.mentions = Array.isArray(value) ? [...value] : []; return this }
|
|
13
|
+
payload(value) { Object.assign(this.content, value || {}); return this }
|
|
14
|
+
viewOnce(value = true) { this.content.viewOnce = Boolean(value); return this }
|
|
15
|
+
ptt(value = true) { this.content.ptt = Boolean(value); return this }
|
|
16
|
+
voice(value = true) { return this.ptt(value) }
|
|
17
|
+
ptv(value = true) { this.content.ptv = Boolean(value); return this }
|
|
18
|
+
videoNote(value = true) { return this.ptv(value) }
|
|
19
|
+
gif(value = true) { this.content.gifPlayback = Boolean(value); return this }
|
|
20
|
+
animated(value = true) { this.content.isAnimated = Boolean(value); return this }
|
|
21
|
+
dimensions(width, height) {
|
|
22
|
+
if (width != null) this.content.width = Number(width)
|
|
23
|
+
if (height != null) this.content.height = Number(height)
|
|
24
|
+
return this
|
|
25
|
+
}
|
|
26
|
+
thumbnail(value) { this.content.jpegThumbnail = value; return this }
|
|
27
|
+
|
|
28
|
+
build() {
|
|
29
|
+
return { ...this.content }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
send(jid, options = {}) {
|
|
33
|
+
return this.sock.sendMessage(jid, this.build(), options)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export class MessageBuilder {
|
|
2
|
+
constructor(sock, content = {}) {
|
|
3
|
+
if (!sock) throw new Error('Socket is required')
|
|
4
|
+
this.sock = sock
|
|
5
|
+
this.content = { ...content }
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
payload(value) {
|
|
9
|
+
if (!value || typeof value !== 'object') return this
|
|
10
|
+
Object.assign(this.content, value)
|
|
11
|
+
return this
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
context(value) {
|
|
15
|
+
this.content.contextInfo = value || {}
|
|
16
|
+
return this
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
mentions(value) {
|
|
20
|
+
this.content.mentions = Array.isArray(value) ? [...value] : []
|
|
21
|
+
return this
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
viewOnce(value = true) {
|
|
25
|
+
this.content.viewOnce = Boolean(value)
|
|
26
|
+
return this
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
edit(key) {
|
|
30
|
+
this.content.edit = key
|
|
31
|
+
return this
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
build() {
|
|
35
|
+
return { ...this.content }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
send(jid, options = {}) {
|
|
39
|
+
return this.sock.sendMessage(jid, this.build(), options)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export class SimpleBuilder {
|
|
2
|
+
constructor(client, factory) {
|
|
3
|
+
if (!client) throw new Error('Socket is required')
|
|
4
|
+
this.sock = client
|
|
5
|
+
this._factory = factory
|
|
6
|
+
this.raw = factory()
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
build(...args) { return this.raw.build(...args) }
|
|
10
|
+
send(...args) { return this.raw.send(...args) }
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function proxyBuilder(builder, aliases = {}) {
|
|
14
|
+
return new Proxy(builder, {
|
|
15
|
+
get(target, prop, receiver) {
|
|
16
|
+
if (prop in target) return Reflect.get(target, prop, receiver)
|
|
17
|
+
const mapped = aliases[prop] || prop
|
|
18
|
+
const raw = target.raw
|
|
19
|
+
if (raw && typeof raw[mapped] === 'function') {
|
|
20
|
+
return (...args) => {
|
|
21
|
+
const value = raw[mapped](...args)
|
|
22
|
+
return value === raw ? receiver : value
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return undefined
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { TextBuilder } from './TextBuilder.js'
|
|
2
|
+
import { MediaBuilder } from './MediaBuilder.js'
|
|
3
|
+
import { MessageBuilder } from './MessageBuilder.js'
|
|
4
|
+
import { createButtonBuilder, createButtonV2Builder } from './ButtonBuilder.js'
|
|
5
|
+
import { createCarouselBuilder } from './CarouselBuilder.js'
|
|
6
|
+
import { createAIBuilder } from './AIBuilder.js'
|
|
7
|
+
import { createFoadBuilder, createFoad2Builder } from './FoadBuilder.js'
|
|
8
|
+
import { Toolkit, Button, ButtonV2, Carousel, AIRich, Foad, Foad2 } from '../wrapper.js'
|
|
9
|
+
|
|
10
|
+
export class SimpleClient {
|
|
11
|
+
constructor(sock) {
|
|
12
|
+
if (!sock || (typeof sock !== 'object' && typeof sock !== 'function')) {
|
|
13
|
+
throw new TypeError('A Baileys socket is required')
|
|
14
|
+
}
|
|
15
|
+
this.sock = sock
|
|
16
|
+
this.raw = Object.freeze({ Toolkit, Button, ButtonV2, Carousel, AIRich, Foad, Foad2 })
|
|
17
|
+
this.wrapper = this.raw
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
text(text = '') { return new TextBuilder(this.sock, text) }
|
|
21
|
+
image(media) { return new MediaBuilder(this.sock, 'image', media) }
|
|
22
|
+
video(media) { return new MediaBuilder(this.sock, 'video', media) }
|
|
23
|
+
audio(media) { return new MediaBuilder(this.sock, 'audio', media) }
|
|
24
|
+
voice(media) { return new MediaBuilder(this.sock, 'audio', media).ptt(true) }
|
|
25
|
+
document(media) { return new MediaBuilder(this.sock, 'document', media) }
|
|
26
|
+
sticker(media) { return new MediaBuilder(this.sock, 'sticker', media) }
|
|
27
|
+
ptv(media) { return new MediaBuilder(this.sock, 'video', media).ptv(true) }
|
|
28
|
+
gif(media) { return new MediaBuilder(this.sock, 'video', media).gif(true) }
|
|
29
|
+
|
|
30
|
+
message(content = {}) { return new MessageBuilder(this.sock, content) }
|
|
31
|
+
poll(name, values = [], selectableCount = 1) {
|
|
32
|
+
return new MessageBuilder(this.sock, {
|
|
33
|
+
poll: { name, values, selectableCount }
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
event(options = {}) { return new MessageBuilder(this.sock, { event: options }) }
|
|
37
|
+
album(options = {}) { return new MessageBuilder(this.sock, { album: options }) }
|
|
38
|
+
contacts(displayName, contacts = []) {
|
|
39
|
+
return new MessageBuilder(this.sock, {
|
|
40
|
+
contacts: { displayName, contacts }
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
location(location = {}) { return new MessageBuilder(this.sock, { location }) }
|
|
44
|
+
buttonReply(displayText, id, index = 0) {
|
|
45
|
+
return new MessageBuilder(this.sock, {
|
|
46
|
+
buttonReply: { displayText, id, index },
|
|
47
|
+
type: 'plain'
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
listReply(reply = {}) { return new MessageBuilder(this.sock, { listReply: reply }) }
|
|
51
|
+
react(messageKey, text = '') {
|
|
52
|
+
return new MessageBuilder(this.sock, {
|
|
53
|
+
react: { key: messageKey, text }
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
groupInvite(info = {}) { return new MessageBuilder(this.sock, { groupInvite: info }) }
|
|
57
|
+
product(product, options = {}) {
|
|
58
|
+
return new MessageBuilder(this.sock, { product, ...options })
|
|
59
|
+
}
|
|
60
|
+
requestPhoneNumber(value = true) {
|
|
61
|
+
return new MessageBuilder(this.sock, { requestPhoneNumber: Boolean(value) })
|
|
62
|
+
}
|
|
63
|
+
sharePhoneNumber(value = true) {
|
|
64
|
+
return new MessageBuilder(this.sock, { sharePhoneNumber: Boolean(value) })
|
|
65
|
+
}
|
|
66
|
+
pin(messageKey, type, time) {
|
|
67
|
+
const payload = { pin: messageKey, type }
|
|
68
|
+
if (time != null) payload.time = time
|
|
69
|
+
return new MessageBuilder(this.sock, payload)
|
|
70
|
+
}
|
|
71
|
+
forward(message, force = false) {
|
|
72
|
+
return new MessageBuilder(this.sock, { forward: message, force })
|
|
73
|
+
}
|
|
74
|
+
delete(messageKey) { return new MessageBuilder(this.sock, { delete: messageKey }) }
|
|
75
|
+
disappearing(value) { return new MessageBuilder(this.sock, { disappearingMessagesInChat: value }) }
|
|
76
|
+
limitSharing(value = true) { return new MessageBuilder(this.sock, { limitSharing: Boolean(value) }) }
|
|
77
|
+
button(...args) { return createButtonBuilder(this.sock, ...args) }
|
|
78
|
+
buttonV2(...args) { return createButtonV2Builder(this.sock, ...args) }
|
|
79
|
+
carousel(...args) { return createCarouselBuilder(this.sock, ...args) }
|
|
80
|
+
ai(...args) { return createAIBuilder(this.sock, ...args) }
|
|
81
|
+
foad(...args) { return createFoadBuilder(this.sock, ...args) }
|
|
82
|
+
foad2(...args) { return createFoad2Builder(this.sock, ...args) }
|
|
83
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export class TextBuilder {
|
|
2
|
+
constructor(sock, text = '') {
|
|
3
|
+
this.sock = sock
|
|
4
|
+
this.content = { text: String(text ?? '') }
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
text(value) { this.content.text = String(value ?? ''); return this }
|
|
8
|
+
footer(value) { this.content.footer = String(value ?? ''); return this }
|
|
9
|
+
context(value) { this.content.contextInfo = value || {}; return this }
|
|
10
|
+
mentions(value) { this.content.mentions = Array.isArray(value) ? [...value] : []; return this }
|
|
11
|
+
viewOnce(value = true) { this.content.viewOnce = Boolean(value); return this }
|
|
12
|
+
edit(key) { this.content.edit = key; return this }
|
|
13
|
+
payload(value) { Object.assign(this.content, value || {}); return this }
|
|
14
|
+
|
|
15
|
+
build() {
|
|
16
|
+
return { ...this.content }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
send(jid, options = {}) {
|
|
20
|
+
return this.sock.sendMessage(jid, { ...this.content }, options)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
export declare class SimpleClient {
|
|
2
|
+
readonly sock: any
|
|
3
|
+
readonly raw: Record<string, any>
|
|
4
|
+
readonly wrapper: Record<string, any>
|
|
5
|
+
constructor(sock: any)
|
|
6
|
+
text(text?: string): TextBuilder
|
|
7
|
+
image(media: any): MediaBuilder
|
|
8
|
+
video(media: any): MediaBuilder
|
|
9
|
+
audio(media: any): MediaBuilder
|
|
10
|
+
voice(media: any): MediaBuilder
|
|
11
|
+
document(media: any): MediaBuilder
|
|
12
|
+
sticker(media: any): MediaBuilder
|
|
13
|
+
ptv(media: any): MediaBuilder
|
|
14
|
+
gif(media: any): MediaBuilder
|
|
15
|
+
message(content?: Record<string, any>): MessageBuilder
|
|
16
|
+
poll(name: string, values?: string[], selectableCount?: number): MessageBuilder
|
|
17
|
+
event(options?: Record<string, any>): MessageBuilder
|
|
18
|
+
album(options?: Record<string, any>): MessageBuilder
|
|
19
|
+
contacts(displayName: string, contacts?: any[]): MessageBuilder
|
|
20
|
+
location(location?: Record<string, any>): MessageBuilder
|
|
21
|
+
buttonReply(displayText: string, id: string, index?: number): MessageBuilder
|
|
22
|
+
listReply(reply?: Record<string, any>): MessageBuilder
|
|
23
|
+
react(messageKey: any, text?: string): MessageBuilder
|
|
24
|
+
groupInvite(info?: Record<string, any>): MessageBuilder
|
|
25
|
+
product(product: any, options?: Record<string, any>): MessageBuilder
|
|
26
|
+
requestPhoneNumber(value?: boolean): MessageBuilder
|
|
27
|
+
sharePhoneNumber(value?: boolean): MessageBuilder
|
|
28
|
+
pin(messageKey: any, type?: any, time?: 86400 | 604800 | 2592000): MessageBuilder
|
|
29
|
+
forward(message: any, force?: boolean): MessageBuilder
|
|
30
|
+
delete(messageKey: any): MessageBuilder
|
|
31
|
+
disappearing(value: boolean | number): MessageBuilder
|
|
32
|
+
limitSharing(value?: boolean): MessageBuilder
|
|
33
|
+
button(...args: any[]): any
|
|
34
|
+
buttonV2(...args: any[]): any
|
|
35
|
+
carousel(...args: any[]): any
|
|
36
|
+
ai(...args: any[]): any
|
|
37
|
+
foad(...args: any[]): any
|
|
38
|
+
foad2(...args: any[]): any
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export declare class TextBuilder {
|
|
42
|
+
constructor(sock: any, text?: string)
|
|
43
|
+
text(value: string): this
|
|
44
|
+
footer(value: string): this
|
|
45
|
+
context(value: Record<string, any>): this
|
|
46
|
+
mentions(value: string[]): this
|
|
47
|
+
viewOnce(value?: boolean): this
|
|
48
|
+
edit(key: any): this
|
|
49
|
+
payload(value: Record<string, any>): this
|
|
50
|
+
mentions(value: string[]): this
|
|
51
|
+
viewOnce(value?: boolean): this
|
|
52
|
+
edit(key: any): this
|
|
53
|
+
build(): Record<string, any>
|
|
54
|
+
send(jid: string, options?: Record<string, any>): Promise<any>
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export declare class MediaBuilder {
|
|
58
|
+
constructor(sock: any, type: string, media: any)
|
|
59
|
+
caption(value: string): this
|
|
60
|
+
fileName(value: string): this
|
|
61
|
+
mimetype(value: string): this
|
|
62
|
+
context(value: Record<string, any>): this
|
|
63
|
+
payload(value: Record<string, any>): this
|
|
64
|
+
mentions(value: string[]): this
|
|
65
|
+
viewOnce(value?: boolean): this
|
|
66
|
+
ptt(value?: boolean): this
|
|
67
|
+
voice(value?: boolean): this
|
|
68
|
+
ptv(value?: boolean): this
|
|
69
|
+
videoNote(value?: boolean): this
|
|
70
|
+
gif(value?: boolean): this
|
|
71
|
+
animated(value?: boolean): this
|
|
72
|
+
dimensions(width?: number, height?: number): this
|
|
73
|
+
thumbnail(value: any): this
|
|
74
|
+
build(): Record<string, any>
|
|
75
|
+
send(jid: string, options?: Record<string, any>): Promise<any>
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export declare class CardBuilder {
|
|
79
|
+
constructor(parent: any, options?: Record<string, any>)
|
|
80
|
+
title(value: string): this
|
|
81
|
+
body(value: string): this
|
|
82
|
+
text(value: string): this
|
|
83
|
+
footer(value: string): this
|
|
84
|
+
image(media: any, options?: Record<string, any>): this
|
|
85
|
+
video(media: any, options?: Record<string, any>): this
|
|
86
|
+
media(type: 'image' | 'video', media: any, options?: Record<string, any>): this
|
|
87
|
+
button(displayText: string, id: string, options?: Record<string, any>): this
|
|
88
|
+
reply(displayText: string, id: string, options?: Record<string, any>): this
|
|
89
|
+
quickReply(displayText: string, id: string, options?: Record<string, any>): this
|
|
90
|
+
url(displayText: string, url: string, options?: Record<string, any>): this
|
|
91
|
+
copy(displayText: string, copyCode: string, options?: Record<string, any>): this
|
|
92
|
+
coppy(displayText: string, copyCode: string, options?: Record<string, any>): this
|
|
93
|
+
call(displayText: string, phone: string, options?: Record<string, any>): this
|
|
94
|
+
buttons(buttons?: any[]): this
|
|
95
|
+
rawButton(button: Record<string, any>): this
|
|
96
|
+
context(value: Record<string, any>): this
|
|
97
|
+
payload(value: Record<string, any>): this
|
|
98
|
+
build(): Promise<Record<string, any>>
|
|
99
|
+
add(): CarouselBuilder
|
|
100
|
+
end(): CarouselBuilder
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export declare class CarouselBuilder {
|
|
104
|
+
readonly sock: any
|
|
105
|
+
readonly raw: any
|
|
106
|
+
constructor(sock: any, ...args: any[])
|
|
107
|
+
card(options?: Record<string, any>): CardBuilder
|
|
108
|
+
cards(cards?: any[]): this
|
|
109
|
+
addCard(card: any): this
|
|
110
|
+
clear(): this
|
|
111
|
+
title(value: string): this
|
|
112
|
+
subtitle(value: string): this
|
|
113
|
+
body(value: string): this
|
|
114
|
+
text(value: string): this
|
|
115
|
+
footer(value: string): this
|
|
116
|
+
context(value: Record<string, any>): this
|
|
117
|
+
payload(value: Record<string, any>): this
|
|
118
|
+
loadFrom(message: any): this
|
|
119
|
+
build(jid: string, options?: Record<string, any>): Promise<any>
|
|
120
|
+
send(jid: string, options?: Record<string, any>): Promise<any>
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export declare class MessageBuilder {
|
|
124
|
+
constructor(sock: any, content?: Record<string, any>)
|
|
125
|
+
payload(value: Record<string, any>): this
|
|
126
|
+
context(value: Record<string, any>): this
|
|
127
|
+
mentions(value: string[]): this
|
|
128
|
+
viewOnce(value?: boolean): this
|
|
129
|
+
edit(key: any): this
|
|
130
|
+
build(): Record<string, any>
|
|
131
|
+
send(jid: string, options?: Record<string, any>): Promise<any>
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export declare function createKyyinfinite(sock: any): SimpleClient
|
|
135
|
+
export declare function attachKyyinfinite(sock: any): any
|
|
136
|
+
export declare function createAIBuilder(sock: any, ...args: any[]): any
|
|
137
|
+
export declare function createButtonBuilder(sock: any, ...args: any[]): any
|
|
138
|
+
export declare function createButtonV2Builder(sock: any, ...args: any[]): any
|
|
139
|
+
export declare function createCarouselBuilder(sock: any, ...args: any[]): CarouselBuilder
|
|
140
|
+
export declare function createFoadBuilder(sock: any, ...args: any[]): any
|
|
141
|
+
export declare function createFoad2Builder(sock: any, ...args: any[]): any
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SimpleClient } from './SimpleClient.js'
|
|
2
|
+
|
|
3
|
+
export { SimpleClient }
|
|
4
|
+
export { TextBuilder } from './TextBuilder.js'
|
|
5
|
+
export { MediaBuilder } from './MediaBuilder.js'
|
|
6
|
+
export { MessageBuilder } from './MessageBuilder.js'
|
|
7
|
+
export { createAIBuilder, AIRich } from './AIBuilder.js'
|
|
8
|
+
export { createButtonBuilder, createButtonV2Builder, Button, ButtonV2 } from './ButtonBuilder.js'
|
|
9
|
+
export { createCarouselBuilder, CarouselBuilder, CardBuilder, Carousel } from './CarouselBuilder.js'
|
|
10
|
+
export { createFoadBuilder, createFoad2Builder, Foad, Foad2 } from './FoadBuilder.js'
|
|
11
|
+
|
|
12
|
+
export function createKyyinfinite(sock) {
|
|
13
|
+
return new SimpleClient(sock)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function attachKyyinfinite(sock) {
|
|
17
|
+
const api = new SimpleClient(sock)
|
|
18
|
+
const names = ['text', 'image', 'video', 'audio', 'voice', 'document', 'sticker', 'ptv', 'gif', 'message', 'poll', 'event', 'album', 'contacts', 'location', 'react', 'groupInvite', 'product', 'requestPhoneNumber', 'sharePhoneNumber', 'pin', 'forward', 'delete', 'disappearing', 'limitSharing', 'button', 'buttonV2', 'carousel', 'ai', 'foad', 'foad2']
|
|
19
|
+
|
|
20
|
+
for (const name of names) {
|
|
21
|
+
if (name in sock) continue
|
|
22
|
+
Object.defineProperty(sock, name, {
|
|
23
|
+
configurable: true,
|
|
24
|
+
enumerable: false,
|
|
25
|
+
writable: false,
|
|
26
|
+
value: (...args) => api[name](...args)
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return sock
|
|
31
|
+
}
|