mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-18 11:39:14 +00:00
Add group chat functions, slight refactoring
This commit is contained in:
33
src/structures/Chat.js
Normal file
33
src/structures/Chat.js
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
|
||||
/**
|
||||
* Represents a Chat on WhatsApp
|
||||
* @extends {Base}
|
||||
*/
|
||||
class Chat extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
if(data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
this.id = data.id;
|
||||
|
||||
this.name = data.formattedTitle;
|
||||
this.isGroup = data.isGroup;
|
||||
this.isReadOnly = data.isReadOnly;
|
||||
this.unreadCount = data.unreadCount;
|
||||
this.timestamp = data.t;
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
sendMessage(message) {
|
||||
return this.client.sendMessage(this.id._serialized, message);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Chat;
|
||||
Reference in New Issue
Block a user