mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-18 03:29:14 +00:00
Compare commits
1 Commits
patch-part
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1499ea503e |
7
index.d.ts
vendored
7
index.d.ts
vendored
@@ -1108,11 +1108,11 @@ declare namespace WAWebJS {
|
||||
|
||||
/** Promotes or demotes participants by IDs to regular users or admins */
|
||||
export type ChangeParticipantsPermissions =
|
||||
(participantIds: Array<string>, sleep?: number) => Promise<{ status: number }>
|
||||
(participantIds: Array<string>) => Promise<{ status: number }>
|
||||
|
||||
/** Adds or removes a list of participants by ID to the group */
|
||||
export type ChangeGroupParticipants =
|
||||
(participantIds: Array<string>, sleep?: number) => Promise<{
|
||||
(participantIds: Array<string>) => Promise<{
|
||||
status: number;
|
||||
participants: Array<{
|
||||
[key: string]: {
|
||||
@@ -1326,9 +1326,6 @@ declare namespace WAWebJS {
|
||||
webClientShouldHandle: boolean,
|
||||
/** Object with participants */
|
||||
participants: object
|
||||
|
||||
/** Reject the call */
|
||||
reject: () => Promise<void>
|
||||
}
|
||||
|
||||
/** Message type List */
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
"fluent-ffmpeg": "^2.1.2",
|
||||
"jsqr": "^1.3.1",
|
||||
"mime": "^3.0.0",
|
||||
"node-fetch": "^2.6.5",
|
||||
"node-fetch": "^3.3.0",
|
||||
"node-webpmux": "^3.1.0",
|
||||
"puppeteer": "^13.0.0"
|
||||
},
|
||||
|
||||
@@ -62,15 +62,7 @@ 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;
|
||||
@@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const Chat = require('./Chat');
|
||||
const Util = require('../util/Util');
|
||||
|
||||
/**
|
||||
* Group participant information
|
||||
@@ -53,65 +52,57 @@ class GroupChat extends Chat {
|
||||
get participants() {
|
||||
return this.groupMetadata.participants;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function to change a number of participant's state..
|
||||
* @param {string} type (promote|demote|add|remove)
|
||||
*/
|
||||
async _changeParticipants(participantIds, type, sleep = null) {
|
||||
return await this.client.pupPage.evaluate(async (chatId, participantIds, type, sleep) => {
|
||||
if (type != 'add' && type != 'remove' && type != 'promote' && type != 'demote') return null;
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p));
|
||||
const status = [];
|
||||
for (const participantWid of participantWids) {
|
||||
status.push(await window.Store.GroupParticipants['send'+type.charAt(0).toUpperCase() + type.slice(1)+'Participants'](chatWid, [participantWid]));
|
||||
if (sleep) {
|
||||
await Util.sleep(sleep);
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}, this.id._serialized, participantIds, type, sleep);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a list of participants by ID to the group
|
||||
* @param {Array<string>} participantIds
|
||||
* @param {?number} default 100ms, amount to sleep in milliseconds before adding the next participant
|
||||
* @returns {Promise<Array<Object>>}
|
||||
* @param {Array<string>} participantIds
|
||||
* @returns {Promise<Object>}
|
||||
*/
|
||||
async addParticipants(participantIds, sleep = 100) {
|
||||
return this._changeParticipants(participantIds, 'add', sleep);
|
||||
async addParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p));
|
||||
return window.Store.GroupParticipants.sendAddParticipants(chatWid, participantWids);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a list of participants by ID to the group
|
||||
* @param {Array<string>} participantIds
|
||||
* @param {?number} default 100ms, amount to sleep in milliseconds before removing the next participant
|
||||
* @returns {Promise<Array<Object>>}
|
||||
* @param {Array<string>} participantIds
|
||||
* @returns {Promise<Object>}
|
||||
*/
|
||||
async removeParticipants(participantIds, sleep = 100) {
|
||||
return this._changeParticipants(participantIds, 'remove', sleep);
|
||||
async removeParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p));
|
||||
return window.Store.GroupParticipants.sendRemoveParticipants(chatWid, participantWids);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Promote participants to admins by IDs
|
||||
* @param {Array<string>} participantIds
|
||||
* @param {?number} default 100ms, amount to sleep in milliseconds before promoting the next participant
|
||||
* @returns {Promise<Array<Object>>}
|
||||
* Promotes participants by IDs to admins
|
||||
* @param {Array<string>} participantIds
|
||||
* @returns {Promise<{ status: number }>} Object with status code indicating if the operation was successful
|
||||
*/
|
||||
async promoteParticipants(participantIds, sleep = 100) {
|
||||
return this._changeParticipants(participantIds, 'promote', sleep);
|
||||
async promoteParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p));
|
||||
return window.Store.GroupParticipants.sendPromoteParticipants(chatWid, participantWids);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Demotes admins to regular participants by IDs
|
||||
* @param {Array<string>} participantIds
|
||||
* @param {?number} default 100ms, amount to sleep in milliseconds before demoting the next participant
|
||||
* @returns {Promise<Array<Object>>}
|
||||
* Demotes participants by IDs to regular users
|
||||
* @param {Array<string>} participantIds
|
||||
* @returns {Promise<{ status: number }>} Object with status code indicating if the operation was successful
|
||||
*/
|
||||
async demoteParticipants(participantIds, sleep = 100) {
|
||||
return this._changeParticipants(participantIds, 'demote', sleep);
|
||||
async demoteParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p));
|
||||
return window.Store.GroupParticipants.sendDemoteParticipants(chatWid, participantWids);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,4 +231,4 @@ class GroupChat extends Chat {
|
||||
|
||||
}
|
||||
|
||||
module.exports = GroupChat;
|
||||
module.exports = GroupChat;
|
||||
@@ -53,8 +53,6 @@ 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]
|
||||
@@ -604,21 +602,4 @@ 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);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -181,10 +181,6 @@ class Util {
|
||||
static setFfmpegPath(path) {
|
||||
ffmpeg.setFfmpegPath(path);
|
||||
}
|
||||
|
||||
static sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Util;
|
||||
|
||||
Reference in New Issue
Block a user