Merge branch 'main' into fix-buttons-list

This commit is contained in:
Rajeh Taher
2023-01-06 20:17:02 +02:00
committed by GitHub
7 changed files with 45 additions and 3 deletions

3
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,3 @@
github: [pedroslopez, PurpShell]
ko_fi: pedroslopez
custom: ["paypal.me/psla", "buymeacoff.ee/pedroslopez"]

View File

@@ -94,7 +94,7 @@ You can support the maintainer of this project through the links below
- [Support via GitHub Sponsors](https://github.com/sponsors/pedroslopez)
- [Support via PayPal](https://www.paypal.me/psla/)
- [Sign up for DigitalOcean](https://m.do.co/c/73f906a36ed4) and get $100 in credit when you sign up (Referral)
- [Sign up for DigitalOcean](https://m.do.co/c/73f906a36ed4) and get $200 in credit when you sign up (Referral)
## Disclaimer

View File

@@ -280,6 +280,15 @@ client.on('change_state', state => {
console.log('CHANGE STATE', state );
});
// Change to false if you don't want to reject incoming calls
let rejectCalls = true;
client.on('call', async (call) => {
console.log('Call received, rejecting. GOTO Line 261 to disable', call);
if (rejectCalls) await call.reject();
await client.sendMessage(call.from, `[${call.fromMe ? 'Outgoing' : 'Incoming'}] Phone call from ${call.from}, type ${call.isGroup ? 'group' : ''} ${call.isVideo ? 'video' : 'audio'} call. ${rejectCalls ? 'This call was automatically rejected by the script.' : ''}`);
});
client.on('disconnected', (reason) => {
console.log('Client was logged out', reason);
});

3
index.d.ts vendored
View File

@@ -1328,6 +1328,9 @@ declare namespace WAWebJS {
webClientShouldHandle: boolean,
/** Object with participants */
participants: object
/** Reject the call */
reject: () => Promise<void>
}
/** Message type List */

View File

@@ -62,7 +62,15 @@ class Call extends Base {
return super._patch(data);
}
/**
* Reject the call
*/
async reject() {
return this.client.pupPage.evaluate((peerJid, id) => {
return window.WWebJS.rejectCall(peerJid, id);
}, this.from, this.id);
}
}
module.exports = Call;

View File

@@ -51,7 +51,7 @@ exports.Events = {
DISCONNECTED: 'disconnected',
STATE_CHANGED: 'change_state',
BATTERY_CHANGED: 'change_battery',
INCOMING_CALL: 'incoming_call',
INCOMING_CALL: 'call',
REMOTE_SESSION_SAVED: 'remote_session_saved'
};

View File

@@ -53,6 +53,8 @@ exports.ExposeStore = (moduleRaidStr) => {
window.Store.ReplyUtils = window.mR.findModule('canReplyMsg').length > 0 && window.mR.findModule('canReplyMsg')[0];
window.Store.MsgActionChecks = window.mR.findModule('canSenderRevokeMsg')[0];
window.Store.QuotedMsg = window.mR.findModule('getQuotedMsgObj')[0];
window.Store.Socket = window.mR.findModule('deprecatedSendIq')[0];
window.Store.SocketWap = window.mR.findModule('wap')[0];
window.Store.StickerTools = {
...window.mR.findModule('toWebpSticker')[0],
...window.mR.findModule('addWebpMetadata')[0]
@@ -930,4 +932,21 @@ exports.LoadUtils = () => {
return undefined;
};
window.WWebJS.rejectCall = async (peerJid, id) => {
peerJid = peerJid.split('@')[0] + '@s.whatsapp.net';
let userId = window.Store.User.getMaybeMeUser().user + '@s.whatsapp.net';
const stanza = window.Store.SocketWap.wap('call', {
id: window.Store.SocketWap.generateId(),
from: window.Store.SocketWap.USER_JID(userId),
to: window.Store.SocketWap.USER_JID(peerJid),
}, [
window.Store.SocketWap.wap('reject', {
'call-id': id,
'call-creator': window.Store.SocketWap.USER_JID(peerJid),
count: '0',
})
]);
await window.Store.Socket.deprecatedCastStanza(stanza);
};
};