2024-06-10 14:34:50 -04:00
|
|
|
class TextMessage {
|
2024-06-11 14:47:42 -04:00
|
|
|
public TextMessage(peerName, peerAvatar, topic, message, timestamp) {
|
|
|
|
this.peerName = peerName;
|
|
|
|
this.peerAvatar = peerAvatar;
|
|
|
|
this.topic = topic;
|
2024-06-10 14:34:50 -04:00
|
|
|
this.message = message;
|
|
|
|
this.timestamp = timestamp;
|
|
|
|
}
|
2024-06-11 14:47:42 -04:00
|
|
|
|
|
|
|
public toJsonString() {
|
|
|
|
return JSON.stringify({
|
|
|
|
type: 'message',
|
|
|
|
name: this.peerName,
|
|
|
|
message: this.message,
|
|
|
|
avatar: this.peerAvatar,
|
|
|
|
topic: this.topic,
|
|
|
|
timestamp: this.timestamp
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public static new(bot, message) {
|
|
|
|
return new TextMessage(bot.botName, "", bot.currentTopic, message, Date.now());
|
|
|
|
}
|
2024-06-10 14:34:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export default TextMessage;
|