irc-framework
Version:
A better IRC framework for node.js
77 lines (76 loc) • 3.65 kB
JavaScript
;
require("core-js/modules/es.symbol.js");
require("core-js/modules/es.symbol.description.js");
require("core-js/modules/es.symbol.iterator.js");
require("core-js/modules/es.array.iterator.js");
require("core-js/modules/es.object.define-property.js");
require("core-js/modules/es.string.iterator.js");
require("core-js/modules/web.dom-collections.iterator.js");
require("core-js/modules/es.symbol.to-primitive.js");
require("core-js/modules/es.array.for-each.js");
require("core-js/modules/es.array.index-of.js");
require("core-js/modules/es.array.join.js");
require("core-js/modules/es.date.to-primitive.js");
require("core-js/modules/es.number.constructor.js");
require("core-js/modules/es.object.assign.js");
require("core-js/modules/es.object.create.js");
require("core-js/modules/es.object.to-string.js");
require("core-js/modules/web.dom-collections.for-each.js");
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
var MessageTags = require('./messagetags');
module.exports = /*#__PURE__*/function () {
function IrcMessage(command) {
_classCallCheck(this, IrcMessage);
this.tags = Object.create(null);
this.prefix = '';
this.nick = '';
this.ident = '';
this.hostname = '';
this.command = command || '';
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
this.params = args || [];
}
return _createClass(IrcMessage, [{
key: "to1459",
value: function to1459() {
var _this = this;
var parts = [];
var tags = MessageTags.encode(this.tags);
if (tags) {
parts.push('@' + tags);
}
if (this.prefix) {
// TODO: If prefix is empty, build it from the nick!ident@hostname
parts.push(':' + this.prefix);
}
parts.push(this.command);
if (this.params.length > 0) {
this.params.forEach(function (param, idx) {
if (idx === _this.params.length - 1 && (param.indexOf(' ') > -1 || param[0] === ':')) {
parts.push(':' + param);
} else {
parts.push(param);
}
});
}
return parts.join(' ');
}
}, {
key: "toJson",
value: function toJson() {
return {
tags: Object.assign({}, this.tags),
source: this.prefix,
command: this.command,
params: this.params
};
}
}]);
}();