hackmud-chat
Version:
A hackmud chat api wrapper for nodejs.
33 lines • 1.16 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const message_1 = require("./message");
/**
* Represents a message from a channel.
*/
class ChannelMessage extends message_1.Message {
constructor(accountUser, fromUser, msg, t, id, channel, isJoin = false, isLeave = false) {
super(accountUser, fromUser, msg, t, id);
this.channel = channel;
this.isJoin = isJoin;
this.isLeave = isLeave;
}
/**
* Sends a reply.
*
* Example output: @fromUser hey
* @param message The message
*/
async reply(message) {
return await this.channel.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.channel.name} ${this.fromUser} :::${this.msg}:::`;
}
}
exports.ChannelMessage = ChannelMessage;
//# sourceMappingURL=channel.message.js.map
;