27 lines
693 B
JavaScript
27 lines
693 B
JavaScript
class TextMessage {
|
|
constructor(peerName, peerAvatar, topic, message, timestamp) {
|
|
this.peerName = peerName;
|
|
this.peerAvatar = peerAvatar;
|
|
this.topic = topic;
|
|
this.message = message;
|
|
this.timestamp = timestamp;
|
|
}
|
|
|
|
toJsonString() {
|
|
return JSON.stringify({
|
|
type: 'message',
|
|
name: this.peerName,
|
|
message: this.message,
|
|
avatar: this.peerAvatar,
|
|
topic: this.topic,
|
|
timestamp: this.timestamp
|
|
});
|
|
}
|
|
|
|
static new(bot, message) {
|
|
return new TextMessage(bot.botName, "", bot.currentTopic, message, Date.now());
|
|
}
|
|
}
|
|
|
|
export default TextMessage;
|