@kyyinfinite/baileys 1.0.0 → 2.1.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 +582 -1340
- 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/KyyMessage.js +46 -0
- package/lib/Kyyinfinite/Simple/MediaBuilder.js +41 -0
- package/lib/Kyyinfinite/Simple/MessageBuilder.js +55 -0
- package/lib/Kyyinfinite/Simple/MessageTypesBuilder.js +3 -0
- package/lib/Kyyinfinite/Simple/SimpleBuilder.js +28 -0
- package/lib/Kyyinfinite/Simple/SimpleClient.js +120 -0
- package/lib/Kyyinfinite/Simple/TextBuilder.js +28 -0
- package/lib/Kyyinfinite/Simple/UniversalMediaBuilder.js +21 -0
- package/lib/Kyyinfinite/Simple/index.d.ts +232 -0
- package/lib/Kyyinfinite/Simple/index.js +38 -0
- package/lib/Kyyinfinite/Simple/jid.js +55 -0
- package/lib/Kyyinfinite/Simple/messageUtils.js +49 -0
- package/lib/Kyyinfinite/Simple/parseMessage.js +55 -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 +104 -23
- package/test/core.test.js +38 -0
- package/test/simple-api.test.js +183 -0
- 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,232 @@
|
|
|
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
|
+
media(media: any): UniversalMediaBuilder
|
|
8
|
+
wrapMessage(message: any): KyyMessage
|
|
9
|
+
parseMessage(message: any, options?: { prefix?: string, commandMode?: string }): any
|
|
10
|
+
send(jid: string, content: string | Record<string, any>, options?: Record<string, any> & { autoMentions?: boolean }): Promise<any>
|
|
11
|
+
quoted(message: any, content: string | Record<string, any>, options?: Record<string, any> & { autoMentions?: boolean }): Promise<any>
|
|
12
|
+
mentions(text: string): string[]
|
|
13
|
+
resolveMedia(media: any): any
|
|
14
|
+
resolveMediaContent(content: Record<string, any>): Record<string, any>
|
|
15
|
+
jid(value: string): string
|
|
16
|
+
parseJid(value: string): any
|
|
17
|
+
jidUser(value: string): string | null
|
|
18
|
+
jidServer(value: string): string | null
|
|
19
|
+
jidDevice(value: string): string | null
|
|
20
|
+
isGroup(value: string): boolean
|
|
21
|
+
isPrivate(value: string): boolean
|
|
22
|
+
isBroadcast(value: string): boolean
|
|
23
|
+
isStatus(value: string): boolean
|
|
24
|
+
isNewsletter(value: string): boolean
|
|
25
|
+
isLid(value: string): boolean
|
|
26
|
+
makeJid(user: string | number, server?: string, device?: string | number | null): string
|
|
27
|
+
reply(message: any, content: string | Record<string, any>, options?: Record<string, any>): Promise<any>
|
|
28
|
+
reactTo(message: any, text?: string): Promise<any>
|
|
29
|
+
editMessage(message: any, content: string | Record<string, any>, options?: Record<string, any>): Promise<any>
|
|
30
|
+
deleteMessage(message: any): Promise<any>
|
|
31
|
+
forwardMessage(message: any, jid?: string, force?: boolean): Promise<any>
|
|
32
|
+
downloadMessage(message: any, type?: 'buffer' | 'stream', options?: Record<string, any>, ctx?: any): Promise<any>
|
|
33
|
+
image(media: any): MediaBuilder
|
|
34
|
+
video(media: any): MediaBuilder
|
|
35
|
+
audio(media: any): MediaBuilder
|
|
36
|
+
voice(media: any): MediaBuilder
|
|
37
|
+
document(media: any): MediaBuilder
|
|
38
|
+
sticker(media: any): MediaBuilder
|
|
39
|
+
ptv(media: any): MediaBuilder
|
|
40
|
+
gif(media: any): MediaBuilder
|
|
41
|
+
message(content?: Record<string, any>): MessageBuilder
|
|
42
|
+
poll(name: string, values?: string[], selectableCount?: number): MessageBuilder
|
|
43
|
+
event(options?: Record<string, any>): MessageBuilder
|
|
44
|
+
album(options?: Record<string, any>): MessageBuilder
|
|
45
|
+
contacts(displayName: string, contacts?: any[]): MessageBuilder
|
|
46
|
+
location(location?: Record<string, any>): MessageBuilder
|
|
47
|
+
buttonReply(displayText: string, id: string, index?: number): MessageBuilder
|
|
48
|
+
listReply(reply?: Record<string, any>): MessageBuilder
|
|
49
|
+
react(messageKey: any, text?: string): MessageBuilder
|
|
50
|
+
groupInvite(info?: Record<string, any>): MessageBuilder
|
|
51
|
+
product(product: any, options?: Record<string, any>): MessageBuilder
|
|
52
|
+
requestPhoneNumber(value?: boolean): MessageBuilder
|
|
53
|
+
sharePhoneNumber(value?: boolean): MessageBuilder
|
|
54
|
+
pin(messageKey: any, type?: any, time?: 86400 | 604800 | 2592000): MessageBuilder
|
|
55
|
+
forward(message: any, force?: boolean): MessageBuilder
|
|
56
|
+
delete(messageKey: any): MessageBuilder
|
|
57
|
+
disappearing(value: boolean | number): MessageBuilder
|
|
58
|
+
limitSharing(value?: boolean): MessageBuilder
|
|
59
|
+
button(...args: any[]): any
|
|
60
|
+
buttonV2(...args: any[]): any
|
|
61
|
+
carousel(...args: any[]): any
|
|
62
|
+
ai(...args: any[]): any
|
|
63
|
+
foad(...args: any[]): any
|
|
64
|
+
foad2(...args: any[]): any
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export declare class TextBuilder {
|
|
68
|
+
constructor(sock: any, text?: string)
|
|
69
|
+
text(value: string): this
|
|
70
|
+
footer(value: string): this
|
|
71
|
+
context(value: Record<string, any>): this
|
|
72
|
+
mentions(value: string[]): this
|
|
73
|
+
autoMentions(value?: boolean): this
|
|
74
|
+
quoted(message: any): this
|
|
75
|
+
viewOnce(value?: boolean): this
|
|
76
|
+
edit(key: any): this
|
|
77
|
+
payload(value: Record<string, any>): this
|
|
78
|
+
build(): Record<string, any>
|
|
79
|
+
send(jid: string, options?: Record<string, any>): Promise<any>
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export declare class MediaBuilder {
|
|
83
|
+
constructor(sock: any, type: string, media: any)
|
|
84
|
+
caption(value: string): this
|
|
85
|
+
fileName(value: string): this
|
|
86
|
+
mimetype(value: string): this
|
|
87
|
+
context(value: Record<string, any>): this
|
|
88
|
+
payload(value: Record<string, any>): this
|
|
89
|
+
mentions(value: string[]): this
|
|
90
|
+
autoMentions(value?: boolean): this
|
|
91
|
+
quoted(message: any): this
|
|
92
|
+
viewOnce(value?: boolean): this
|
|
93
|
+
ptt(value?: boolean): this
|
|
94
|
+
voice(value?: boolean): this
|
|
95
|
+
ptv(value?: boolean): this
|
|
96
|
+
videoNote(value?: boolean): this
|
|
97
|
+
gif(value?: boolean): this
|
|
98
|
+
animated(value?: boolean): this
|
|
99
|
+
dimensions(width?: number, height?: number): this
|
|
100
|
+
thumbnail(value: any): this
|
|
101
|
+
build(): Record<string, any>
|
|
102
|
+
send(jid: string, options?: Record<string, any>): Promise<any>
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export declare class CardBuilder {
|
|
106
|
+
constructor(parent: any, options?: Record<string, any>)
|
|
107
|
+
title(value: string): this
|
|
108
|
+
body(value: string): this
|
|
109
|
+
text(value: string): this
|
|
110
|
+
footer(value: string): this
|
|
111
|
+
image(media: any, options?: Record<string, any>): this
|
|
112
|
+
video(media: any, options?: Record<string, any>): this
|
|
113
|
+
media(type: 'image' | 'video', media: any, options?: Record<string, any>): this
|
|
114
|
+
button(displayText: string, id: string, options?: Record<string, any>): this
|
|
115
|
+
reply(displayText: string, id: string, options?: Record<string, any>): this
|
|
116
|
+
quickReply(displayText: string, id: string, options?: Record<string, any>): this
|
|
117
|
+
url(displayText: string, url: string, options?: Record<string, any>): this
|
|
118
|
+
copy(displayText: string, copyCode: string, options?: Record<string, any>): this
|
|
119
|
+
coppy(displayText: string, copyCode: string, options?: Record<string, any>): this
|
|
120
|
+
call(displayText: string, phone: string, options?: Record<string, any>): this
|
|
121
|
+
buttons(buttons?: any[]): this
|
|
122
|
+
rawButton(button: Record<string, any>): this
|
|
123
|
+
context(value: Record<string, any>): this
|
|
124
|
+
payload(value: Record<string, any>): this
|
|
125
|
+
build(): Promise<Record<string, any>>
|
|
126
|
+
add(): CarouselBuilder
|
|
127
|
+
end(): CarouselBuilder
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export declare class CarouselBuilder {
|
|
131
|
+
readonly sock: any
|
|
132
|
+
readonly raw: any
|
|
133
|
+
constructor(sock: any, ...args: any[])
|
|
134
|
+
card(options?: Record<string, any>): CardBuilder
|
|
135
|
+
cards(cards?: any[]): this
|
|
136
|
+
addCard(card: any): this
|
|
137
|
+
clear(): this
|
|
138
|
+
title(value: string): this
|
|
139
|
+
subtitle(value: string): this
|
|
140
|
+
body(value: string): this
|
|
141
|
+
text(value: string): this
|
|
142
|
+
footer(value: string): this
|
|
143
|
+
context(value: Record<string, any>): this
|
|
144
|
+
payload(value: Record<string, any>): this
|
|
145
|
+
loadFrom(message: any): this
|
|
146
|
+
build(jid: string, options?: Record<string, any>): Promise<any>
|
|
147
|
+
send(jid: string, options?: Record<string, any>): Promise<any>
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export declare class MessageBuilder {
|
|
151
|
+
constructor(sock: any, content?: Record<string, any>)
|
|
152
|
+
payload(value: Record<string, any>): this
|
|
153
|
+
context(value: Record<string, any>): this
|
|
154
|
+
mentions(value: string[]): this
|
|
155
|
+
autoMentions(value?: boolean): this
|
|
156
|
+
quoted(message: any): this
|
|
157
|
+
viewOnce(value?: boolean): this
|
|
158
|
+
edit(key: any): this
|
|
159
|
+
build(): Record<string, any>
|
|
160
|
+
send(jid: string, options?: Record<string, any>): Promise<any>
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export declare function createKyyinfinite(sock: any): SimpleClient
|
|
164
|
+
export declare function attachKyyinfinite(sock: any): any
|
|
165
|
+
export declare function createAIBuilder(sock: any, ...args: any[]): any
|
|
166
|
+
export declare function createButtonBuilder(sock: any, ...args: any[]): any
|
|
167
|
+
export declare function createButtonV2Builder(sock: any, ...args: any[]): any
|
|
168
|
+
export declare function createCarouselBuilder(sock: any, ...args: any[]): CarouselBuilder
|
|
169
|
+
export declare function createFoadBuilder(sock: any, ...args: any[]): any
|
|
170
|
+
export declare function createFoad2Builder(sock: any, ...args: any[]): any
|
|
171
|
+
|
|
172
|
+
export declare class KyyMessage {
|
|
173
|
+
readonly sock: any
|
|
174
|
+
readonly message: any
|
|
175
|
+
readonly key: any
|
|
176
|
+
readonly id: any
|
|
177
|
+
readonly jid: any
|
|
178
|
+
readonly sender: any
|
|
179
|
+
readonly fromMe: boolean
|
|
180
|
+
constructor(sock: any, message: any)
|
|
181
|
+
reply(content: string | Record<string, any>, options?: Record<string, any>): Promise<any>
|
|
182
|
+
react(text?: string): Promise<any>
|
|
183
|
+
edit(content: string | Record<string, any>, options?: Record<string, any>): Promise<any>
|
|
184
|
+
delete(): Promise<any>
|
|
185
|
+
forward(jid?: string, force?: boolean): Promise<any>
|
|
186
|
+
download(type?: 'buffer' | 'stream', options?: Record<string, any>, ctx?: any): Promise<any>
|
|
187
|
+
raw(): any
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export declare class UniversalMediaBuilder extends MediaBuilder {
|
|
191
|
+
constructor(sock: any, media: any)
|
|
192
|
+
asImage(): this
|
|
193
|
+
asVideo(): this
|
|
194
|
+
asAudio(): this
|
|
195
|
+
asDocument(): this
|
|
196
|
+
asSticker(): this
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export declare function parseMessage(message: any, options?: { prefix?: string, commandMode?: string }): {
|
|
200
|
+
message: any
|
|
201
|
+
content: any
|
|
202
|
+
messageType: any
|
|
203
|
+
text: string
|
|
204
|
+
command: string
|
|
205
|
+
args: string[]
|
|
206
|
+
jid: any
|
|
207
|
+
sender: any
|
|
208
|
+
isGroup: boolean
|
|
209
|
+
isReply: boolean
|
|
210
|
+
quoted: any
|
|
211
|
+
key: any
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export declare function parseJid(jid: string): { user: string, device: string | null, server: string, jid: string } | null
|
|
215
|
+
export declare function normalizeJid(jid: string): string
|
|
216
|
+
export declare function jidUser(jid: string): string | null
|
|
217
|
+
export declare function jidServer(jid: string): string | null
|
|
218
|
+
export declare function jidDevice(jid: string): string | null
|
|
219
|
+
export declare function isGroupJid(jid: string): boolean
|
|
220
|
+
export declare function isPrivateJid(jid: string): boolean
|
|
221
|
+
export declare function isBroadcastJid(jid: string): boolean
|
|
222
|
+
export declare function isStatusJid(jid: string): boolean
|
|
223
|
+
export declare function isNewsletterJid(jid: string): boolean
|
|
224
|
+
export declare function isLidJid(jid: string): boolean
|
|
225
|
+
export declare function makeJid(user: string | number, server?: string, device?: string | number | null): string
|
|
226
|
+
|
|
227
|
+
export declare function extractMentions(text: string): string[]
|
|
228
|
+
export declare function getMessageText(content: Record<string, any>): string
|
|
229
|
+
export declare function applyAutoMentions(content: Record<string, any>, enabled?: boolean): Record<string, any>
|
|
230
|
+
export declare function resolveMedia(media: any): any
|
|
231
|
+
export declare function resolveMediaContent(content: Record<string, any>): Record<string, any>
|
|
232
|
+
export declare function quotedOptions(message: any, options?: Record<string, any>): Record<string, any>
|
|
@@ -0,0 +1,38 @@
|
|
|
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', 'media', 'wrapMessage', 'parseMessage', 'jid', 'parseJid', 'jidUser', 'jidServer', 'jidDevice', 'isGroup', 'isPrivate', 'isBroadcast', 'isStatus', 'isNewsletter', 'isLid', 'makeJid', 'reply', 'reactTo', 'editMessage', 'deleteMessage', 'forwardMessage', 'downloadMessage', '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
|
+
}
|
|
32
|
+
|
|
33
|
+
export { KyyMessage } from './KyyMessage.js'
|
|
34
|
+
export { UniversalMediaBuilder } from './UniversalMediaBuilder.js'
|
|
35
|
+
export { parseMessage } from './parseMessage.js'
|
|
36
|
+
export * from './jid.js'
|
|
37
|
+
|
|
38
|
+
export * from './messageUtils.js'
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const JID_RE = /^([^:@\s]+)(?::([^@\s]+))?@([^@\s]+)$/
|
|
2
|
+
|
|
3
|
+
export function parseJid(jid) {
|
|
4
|
+
if (typeof jid !== 'string' || !jid) return null
|
|
5
|
+
const match = jid.match(JID_RE)
|
|
6
|
+
if (!match) return null
|
|
7
|
+
return { user: match[1], device: match[2] || null, server: match[3], jid }
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function normalizeJid(jid) {
|
|
11
|
+
if (typeof jid !== 'string') return jid
|
|
12
|
+
return jid.trim()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function jidUser(jid) {
|
|
16
|
+
return parseJid(jid)?.user || null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function jidServer(jid) {
|
|
20
|
+
return parseJid(jid)?.server || null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function jidDevice(jid) {
|
|
24
|
+
return parseJid(jid)?.device || null
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function isGroupJid(jid) {
|
|
28
|
+
return jidServer(jid) === 'g.us'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function isPrivateJid(jid) {
|
|
32
|
+
const server = jidServer(jid)
|
|
33
|
+
return server === 's.whatsapp.net' || server === 'lid'
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function isBroadcastJid(jid) {
|
|
37
|
+
return jidServer(jid) === 'broadcast'
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function isStatusJid(jid) {
|
|
41
|
+
return jid === 'status@broadcast'
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function isNewsletterJid(jid) {
|
|
45
|
+
return jidServer(jid) === 'newsletter'
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function isLidJid(jid) {
|
|
49
|
+
return jidServer(jid) === 'lid'
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function makeJid(user, server = 's.whatsapp.net', device = null) {
|
|
53
|
+
if (user == null || user === '') throw new TypeError('JID user is required')
|
|
54
|
+
return `${String(user)}${device != null ? `:${device}` : ''}@${server}`
|
|
55
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const MENTION_RE = /(^|\s)@(\d{5,16})(?=\s|$|[.,!?])/g
|
|
2
|
+
|
|
3
|
+
export function extractMentions(text) {
|
|
4
|
+
if (typeof text !== 'string' || !text) return []
|
|
5
|
+
const result = []
|
|
6
|
+
const seen = new Set()
|
|
7
|
+
for (const match of text.matchAll(MENTION_RE)) {
|
|
8
|
+
const jid = `${match[2]}@s.whatsapp.net`
|
|
9
|
+
if (!seen.has(jid)) {
|
|
10
|
+
seen.add(jid)
|
|
11
|
+
result.push(jid)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return result
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function getMessageText(content) {
|
|
18
|
+
if (!content || typeof content !== 'object') return ''
|
|
19
|
+
return [content.text, content.caption, content.title, content.description]
|
|
20
|
+
.filter(value => typeof value === 'string')
|
|
21
|
+
.join('\n')
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function applyAutoMentions(content, enabled = true) {
|
|
25
|
+
if (!enabled || !content || typeof content !== 'object') return content
|
|
26
|
+
if (Array.isArray(content.mentions)) return content
|
|
27
|
+
const mentions = extractMentions(getMessageText(content))
|
|
28
|
+
if (!mentions.length) return content
|
|
29
|
+
return { ...content, mentions }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function resolveMedia(media) {
|
|
33
|
+
if (typeof media !== 'string') return media
|
|
34
|
+
return { url: media }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function resolveMediaContent(content) {
|
|
38
|
+
if (!content || typeof content !== 'object') return content
|
|
39
|
+
const mediaKeys = ['image', 'video', 'audio', 'document', 'sticker']
|
|
40
|
+
const output = { ...content }
|
|
41
|
+
for (const key of mediaKeys) {
|
|
42
|
+
if (typeof output[key] === 'string') output[key] = resolveMedia(output[key])
|
|
43
|
+
}
|
|
44
|
+
return output
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function quotedOptions(message, options = {}) {
|
|
48
|
+
return { ...(options || {}), quoted: message }
|
|
49
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { getContentType } from '../../Utils/messages.js'
|
|
2
|
+
|
|
3
|
+
function unwrap(message) {
|
|
4
|
+
let content = message?.message || message || {}
|
|
5
|
+
const wrappers = ['ephemeralMessage', 'viewOnceMessage', 'viewOnceMessageV2', 'viewOnceMessageV2Extension', 'documentWithCaptionMessage']
|
|
6
|
+
for (let i = 0; i < 6; i++) {
|
|
7
|
+
const type = getContentType(content)
|
|
8
|
+
if (!type || !wrappers.includes(type)) break
|
|
9
|
+
content = content[type]?.message || content[type] || content
|
|
10
|
+
}
|
|
11
|
+
return content
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function parseMessage(message, options = {}) {
|
|
15
|
+
const content = unwrap(message)
|
|
16
|
+
const type = getContentType(content)
|
|
17
|
+
const node = type ? content[type] : undefined
|
|
18
|
+
let text = ''
|
|
19
|
+
|
|
20
|
+
if (typeof node === 'string') text = node
|
|
21
|
+
else if (node?.text) text = node.text
|
|
22
|
+
else if (node?.caption) text = node.caption
|
|
23
|
+
else if (node?.selectedDisplayText) text = node.selectedDisplayText
|
|
24
|
+
else if (node?.title) text = node.title
|
|
25
|
+
else if (node?.contentText) text = node.contentText
|
|
26
|
+
|
|
27
|
+
const prefix = options.prefix ?? ''
|
|
28
|
+
const commandMode = options.commandMode ?? 'prefix'
|
|
29
|
+
let command = ''
|
|
30
|
+
let args = []
|
|
31
|
+
|
|
32
|
+
const normalized = String(text || '').trim()
|
|
33
|
+
const hasPrefix = !prefix || normalized.startsWith(prefix)
|
|
34
|
+
if (normalized && hasPrefix && (commandMode === 'prefix' || !prefix)) {
|
|
35
|
+
const body = prefix ? normalized.slice(prefix.length).trim() : normalized
|
|
36
|
+
const parts = body ? body.split(/\s+/) : []
|
|
37
|
+
command = parts.shift() || ''
|
|
38
|
+
args = parts
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
message,
|
|
43
|
+
content,
|
|
44
|
+
messageType: type,
|
|
45
|
+
text: normalized,
|
|
46
|
+
command,
|
|
47
|
+
args,
|
|
48
|
+
jid: message?.key?.remoteJid,
|
|
49
|
+
sender: message?.key?.participant || message?.key?.remoteJid,
|
|
50
|
+
isGroup: Boolean(message?.key?.remoteJid?.endsWith('@g.us')),
|
|
51
|
+
isReply: Boolean(node?.contextInfo?.quotedMessage),
|
|
52
|
+
quoted: node?.contextInfo?.quotedMessage,
|
|
53
|
+
key: message?.key
|
|
54
|
+
}
|
|
55
|
+
}
|