UNPKG

hackmud-chat

Version:
29 lines 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const message_1 = require("./message"); /** * Represents a private message */ class PrivateMessage extends message_1.Message { constructor(accountUser, fromUser, msg, t, id, toUser) { super(accountUser, fromUser, msg, t, id); this.toUser = toUser; } /** * Sends a reply to the private message. * @param message The message */ async reply(message) { return await this.accountUser.send(this.fromUser, message); } /** * Return a string with the message formatted. */ toString() { const time = new Date(this.t * 1000); // tslint:disable-next-line:max-line-length return `(${this.accountUser.name}) ${("00" + time.getHours()).slice(-2) + ("00" + time.getMinutes()).slice(-2)} ${this.isOwnMessage() ? "to " + this.toUser : "from " + this.fromUser} :::${this.msg}:::`; } } exports.PrivateMessage = PrivateMessage; //# sourceMappingURL=private.message.js.map