Get Stories (#3294)

* Get all broadcast

* fixed return msgs

* feat: add usage example

* Update src/structures/Broadcast.js

Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>

---------

Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
This commit is contained in:
tofers 2024-09-30 20:33:31 +03:00 • committed by GitHub
commit 5b0e139ad4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 125 additions and 2 deletions

View file

@ -15,7 +15,7 @@ const { LoadUtils } = require('./util/Injected/Utils');
const ChatFactory = require('./factories/ChatFactory');
const ContactFactory = require('./factories/ContactFactory');
const WebCacheFactory = require('./webCache/WebCacheFactory');
const { ClientInfo, Message, MessageMedia, Contact, Location, Poll, PollVote, GroupNotification, Label, Call, Buttons, List, Reaction } = require('./structures');
const { ClientInfo, Message, MessageMedia, Contact, Location, Poll, PollVote, GroupNotification, Label, Call, Buttons, List, Reaction, Broadcast} = require('./structures');
const NoAuth = require('./authStrategies/NoAuth');
const {exposeFunctionIfAbsent} = require('./util/Puppeteer');
@ -1472,6 +1472,17 @@ class Client extends EventEmitter {
return labels.map(data => new Label(this, data));
}
/**
* Get all current Broadcast
* @returns {Promise<Array<Broadcast>>}
*/
async getBroadcasts() {
const broadcasts = await this.pupPage.evaluate(async () => {
return window.WWebJS.getAllStatuses();
});
return broadcasts.map(data => new Broadcast(this, data));
}
/**
* Get Label instance by ID