keithbaileys 1.0.5 → 1.0.6
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/lib/Socket/chats.js +78 -0
- package/lib/Socket/messages-send.js +1 -0
- package/package.json +1 -1
package/lib/Socket/chats.js
CHANGED
|
@@ -135,6 +135,10 @@ const makeChatsSocket = (config) => {
|
|
|
135
135
|
}
|
|
136
136
|
]
|
|
137
137
|
});
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
138
142
|
const botNode = (0, WABinary_1.getBinaryNodeChild)(resp, 'bot');
|
|
139
143
|
const botList = [];
|
|
140
144
|
for (const section of (0, WABinary_1.getBinaryNodeChildren)(botNode, 'section')) {
|
|
@@ -149,6 +153,28 @@ const makeChatsSocket = (config) => {
|
|
|
149
153
|
}
|
|
150
154
|
return botList;
|
|
151
155
|
};
|
|
156
|
+
|
|
157
|
+
const createCallLink = async (type, event, timeoutMs) => {
|
|
158
|
+
const result = await query({
|
|
159
|
+
tag: 'call',
|
|
160
|
+
attrs: {
|
|
161
|
+
id: generateMessageTag(),
|
|
162
|
+
to: '@call'
|
|
163
|
+
},
|
|
164
|
+
content: [
|
|
165
|
+
{
|
|
166
|
+
tag: 'link_create',
|
|
167
|
+
attrs: { media: type },
|
|
168
|
+
content: event ? [{ tag: 'event', attrs: { start_time: String(event.startTime) } }] : undefined
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
}, timeoutMs);
|
|
172
|
+
|
|
173
|
+
const child = (0, WABinary_1.getBinaryNodeChild)(result, 'link_create');
|
|
174
|
+
return child === null || child === void 0 ? void 0 : child.attrs.token;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
|
|
152
178
|
const onWhatsApp = async (...jids) => {
|
|
153
179
|
const usyncQuery = new WAUSync_1.USyncQuery().withContactProtocol().withLIDProtocol();
|
|
154
180
|
for (const jid of jids) {
|
|
@@ -737,6 +763,52 @@ const makeChatsSocket = (config) => {
|
|
|
737
763
|
* queries need to be fired on connection open
|
|
738
764
|
* help ensure parity with WA Web
|
|
739
765
|
* */
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Add or Edit Contact
|
|
770
|
+
*/
|
|
771
|
+
const addOrEditContact = (jid, contact) => {
|
|
772
|
+
return chatModify({
|
|
773
|
+
contact
|
|
774
|
+
}, jid);
|
|
775
|
+
};
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* Remove Contact
|
|
779
|
+
*/
|
|
780
|
+
const removeContact = (jid) => {
|
|
781
|
+
return chatModify({
|
|
782
|
+
contact: null
|
|
783
|
+
}, jid);
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* Add or Edit Quick Reply
|
|
788
|
+
*/
|
|
789
|
+
const addOrEditQuickReply = (quickReply) => {
|
|
790
|
+
return chatModify({
|
|
791
|
+
quickReply
|
|
792
|
+
}, '');
|
|
793
|
+
};
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* Remove Quick Reply
|
|
797
|
+
*/
|
|
798
|
+
const removeQuickReply = (timestamp) => {
|
|
799
|
+
return chatModify({
|
|
800
|
+
quickReply: { timestamp, deleted: true }
|
|
801
|
+
}, '');
|
|
802
|
+
};
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Enable/Disable link preview privacy
|
|
806
|
+
*/
|
|
807
|
+
const updateDisableLinkPreviewsPrivacy = (isPreviewsDisabled) => {
|
|
808
|
+
return chatModify({
|
|
809
|
+
disableLinkPreviews: { isPreviewsDisabled }
|
|
810
|
+
}, '');
|
|
811
|
+
};
|
|
740
812
|
const executeInitQueries = async () => {
|
|
741
813
|
await Promise.all([fetchProps(), fetchBlocklist(), fetchPrivacySettings()]);
|
|
742
814
|
};
|
|
@@ -840,6 +912,7 @@ const makeChatsSocket = (config) => {
|
|
|
840
912
|
return {
|
|
841
913
|
...sock,
|
|
842
914
|
getBotListV2,
|
|
915
|
+
createCallLink,
|
|
843
916
|
processingMutex,
|
|
844
917
|
fetchPrivacySettings,
|
|
845
918
|
upsertMessage,
|
|
@@ -868,6 +941,11 @@ const makeChatsSocket = (config) => {
|
|
|
868
941
|
getBusinessProfile,
|
|
869
942
|
resyncAppState,
|
|
870
943
|
chatModify,
|
|
944
|
+
addOrEditContact,
|
|
945
|
+
removeContact,
|
|
946
|
+
addOrEditQuickReply,
|
|
947
|
+
removeQuickReply,
|
|
948
|
+
updateDisableLinkPreviewsPrivacy,
|
|
871
949
|
cleanDirtyBits,
|
|
872
950
|
addLabel,
|
|
873
951
|
addChatLabel,
|
|
@@ -866,6 +866,7 @@ const makeMessagesSocket = (config) => {
|
|
|
866
866
|
uploadImage: generateHighQualityLinkPreview ? waUploadToServer : undefined
|
|
867
867
|
}),
|
|
868
868
|
getProfilePicUrl: sock.profilePictureUrl,
|
|
869
|
+
getCallLink: sock.createCallLink,
|
|
869
870
|
upload: waUploadToServer,
|
|
870
871
|
mediaCache: config.mediaCache,
|
|
871
872
|
options: config.options,
|