LinkUp-P2P-Chat/chatBot/includes/TextMessage.js

27 lines
693 B
JavaScript
Raw Normal View History

class TextMessage {
2024-06-11 17:40:02 -04:00
constructor(peerName, peerAvatar, topic, message, timestamp) {
this.peerName = peerName;
this.peerAvatar = peerAvatar;
this.topic = topic;
this.message = message;
this.timestamp = timestamp;
}
2024-06-11 17:40:02 -04:00
toJsonString() {
return JSON.stringify({
type: 'message',
name: this.peerName,
message: this.message,
avatar: this.peerAvatar,
topic: this.topic,
timestamp: this.timestamp
});
}
2024-06-11 17:40:02 -04:00
static new(bot, message) {
return new TextMessage(bot.botName, "", bot.currentTopic, message, Date.now());
}
}
2024-06-11 17:40:02 -04:00
export default TextMessage;