linkup-bot-lib
Version:
49 lines (48 loc) • 1.42 kB
JavaScript
;
/**
* @module Message
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.TextMessage = void 0;
const Message_1 = require("./Message");
class TextMessage extends Message_1.Message {
message;
/**
* @description Creates a new text message.
* @since 1.0
* @author MiTask
* @constructor
* @param peerName Peer username
* @param peerAvatar Peer avatar URL
* @param topic Chat room topic string
* @param timestamp UNIX Timestamp
* @param message Text of the message
*/
constructor(peerName, peerAvatar, topic, timestamp, message) {
super("message", peerName, peerAvatar, topic, timestamp);
this.message = message;
}
/**
* @since 1.0
* @author MiTask
* @returns {String} JSON String with all of the information about the message
*/
toJsonString() {
return JSON.stringify({
...this.toJson(),
message: this.message,
});
}
/**
* @description Creates a new text message instance.
* @since 1.0
* @author MiTask
* @param bot Bot Client class
* @param message Text of the message
* @returns {TextMessage} TextMessage instance
*/
static new(bot, message) {
return new TextMessage(bot.botName, bot.botAvatar, bot.currentTopic, Date.now(), message);
}
}
exports.TextMessage = TextMessage;