mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-19 20:19:14 +00:00
@@ -78,6 +78,9 @@ client.on('message', async msg => {
|
|||||||
} else {
|
} else {
|
||||||
msg.reply('This command can only be used in a group!');
|
msg.reply('This command can only be used in a group!');
|
||||||
}
|
}
|
||||||
|
} else if(msg.body == '!chats') {
|
||||||
|
const chats = await client.getChats();
|
||||||
|
client.sendMessage(msg.from, `The bot has ${chats.length} chats open.`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -148,12 +148,11 @@ class Client extends EventEmitter {
|
|||||||
* Get all current chat instances
|
* Get all current chat instances
|
||||||
*/
|
*/
|
||||||
async getChats() {
|
async getChats() {
|
||||||
// let chats = await this.pupPage.evaluate(() => {
|
let chats = await this.pupPage.evaluate(() => {
|
||||||
// return Store.Chat.serialize()
|
return WWebJS.getChats();
|
||||||
// });
|
});
|
||||||
|
|
||||||
// return chats.map(chatData => ChatFactory.create(this, chatData));
|
return chats.map(chat => ChatFactory.create(this, chat));
|
||||||
throw new Error('NOT IMPLEMENTED')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ exports.LoadCustomSerializers = () => {
|
|||||||
const chat = Store.Chat.get(chatId);
|
const chat = Store.Chat.get(chatId);
|
||||||
return WWebJS.getChatModel(chat);
|
return WWebJS.getChatModel(chat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.WWebJS.getChats = () => {
|
||||||
|
const chats = Store.Chat.models;
|
||||||
|
return chats.map(chat => WWebJS.getChatModel(chat));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.MarkAllRead = () => {
|
exports.MarkAllRead = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user