Basic Chat and Message model implementation
This commit is contained in:
parent
1dab219764
commit
6442469437
1 changed files with 118 additions and 18 deletions
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
const Base = require('./Base');
|
||||
|
||||
// TODO
|
||||
|
||||
/**
|
||||
* Represents a Chat on WhatsApp
|
||||
* @extends {Base}
|
||||
|
|
@ -12,7 +10,28 @@ class Chat extends Base {
|
|||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
if(data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
this.id = data.id;
|
||||
|
||||
this.isGroup = data.isGroup;
|
||||
this.isReadOnly = data.isReadOnly;
|
||||
this.name = data.name;
|
||||
this.unreadCount = data.unreadCount;
|
||||
this.timestamp = data.t;
|
||||
}
|
||||
|
||||
sendMessage(message) {
|
||||
return this.client.sendMessage(this.id._serialized, message);
|
||||
}
|
||||
|
||||
static get extraFields() {
|
||||
return [
|
||||
'formattedTitle',
|
||||
'isGroup'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue