ishumdz-bail 1.0.2 → 1.0.4
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/Defaults/index.js +2 -0
- package/lib/Socket/messages-recv.js +35 -0
- package/package.json +1 -1
package/lib/Defaults/index.js
CHANGED
|
@@ -72,6 +72,8 @@ export const DEFAULT_CONNECTION_CONFIG = {
|
|
|
72
72
|
generateHighQualityLinkPreview: false,
|
|
73
73
|
enableAutoSessionRecreation: true,
|
|
74
74
|
enableRecentMessageCache: true,
|
|
75
|
+
autoAnswer: false,
|
|
76
|
+
autoAnswerMessage: 'Sorry, I cannot take calls right now. Please text me instead.',
|
|
75
77
|
options: {},
|
|
76
78
|
appStateMacVerification: {
|
|
77
79
|
patch: false,
|
|
@@ -384,6 +384,27 @@ export const makeMessagesRecvSocket = (config) => {
|
|
|
384
384
|
};
|
|
385
385
|
await query(stanza);
|
|
386
386
|
};
|
|
387
|
+
const acceptCall = async (callId, callFrom) => {
|
|
388
|
+
const stanza = {
|
|
389
|
+
tag: 'call',
|
|
390
|
+
attrs: {
|
|
391
|
+
from: authState.creds.me.id,
|
|
392
|
+
to: callFrom
|
|
393
|
+
},
|
|
394
|
+
content: [
|
|
395
|
+
{
|
|
396
|
+
tag: 'accept',
|
|
397
|
+
attrs: {
|
|
398
|
+
'call-id': callId,
|
|
399
|
+
'call-creator': callFrom,
|
|
400
|
+
count: '0'
|
|
401
|
+
},
|
|
402
|
+
content: undefined
|
|
403
|
+
}
|
|
404
|
+
]
|
|
405
|
+
};
|
|
406
|
+
await query(stanza);
|
|
407
|
+
};
|
|
387
408
|
const sendText = async (jid, text, options, quoted = null) => {
|
|
388
409
|
return sendMessage(jid, {
|
|
389
410
|
text,
|
|
@@ -1762,6 +1783,19 @@ export const makeMessagesRecvSocket = (config) => {
|
|
|
1762
1783
|
if (!call) {
|
|
1763
1784
|
return;
|
|
1764
1785
|
}
|
|
1786
|
+
// Auto-answer incoming calls if enabled
|
|
1787
|
+
if (call.status === 'offer' && !call.isGroup && config.autoAnswer) {
|
|
1788
|
+
try {
|
|
1789
|
+
await rejectCall(call.id, call.from);
|
|
1790
|
+
await sendMessage(call.from, {
|
|
1791
|
+
text: config.autoAnswerMessage || 'Sorry, I cannot take calls right now. Please text me instead.'
|
|
1792
|
+
});
|
|
1793
|
+
logger.debug({ callId: call.id, from: call.from }, 'auto-rejected call and sent reply');
|
|
1794
|
+
}
|
|
1795
|
+
catch (err) {
|
|
1796
|
+
logger.warn({ err: err?.message }, 'failed to auto-answer call');
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1765
1799
|
// missed call + group call notification message generation
|
|
1766
1800
|
if (call.status === 'timeout' || (call.status === 'offer' && call.isGroup)) {
|
|
1767
1801
|
const msg = {
|
|
@@ -1898,6 +1932,7 @@ export const makeMessagesRecvSocket = (config) => {
|
|
|
1898
1932
|
sendMessageAck,
|
|
1899
1933
|
sendRetryRequest,
|
|
1900
1934
|
rejectCall,
|
|
1935
|
+
acceptCall,
|
|
1901
1936
|
fetchMessageHistory,
|
|
1902
1937
|
requestPlaceholderResend,
|
|
1903
1938
|
messageRetryManager,
|