1 | "use strict";
|
2 |
|
3 | require("core-js/modules/es.symbol.js");
|
4 | require("core-js/modules/es.symbol.description.js");
|
5 | require("core-js/modules/es.symbol.iterator.js");
|
6 | require("core-js/modules/es.array.iterator.js");
|
7 | require("core-js/modules/es.object.define-property.js");
|
8 | require("core-js/modules/es.string.iterator.js");
|
9 | require("core-js/modules/web.dom-collections.iterator.js");
|
10 | require("core-js/modules/es.symbol.to-primitive.js");
|
11 | require("core-js/modules/es.array.for-each.js");
|
12 | require("core-js/modules/es.array.index-of.js");
|
13 | require("core-js/modules/es.array.join.js");
|
14 | require("core-js/modules/es.date.to-primitive.js");
|
15 | require("core-js/modules/es.number.constructor.js");
|
16 | require("core-js/modules/es.object.assign.js");
|
17 | require("core-js/modules/es.object.create.js");
|
18 | require("core-js/modules/es.object.to-string.js");
|
19 | require("core-js/modules/web.dom-collections.for-each.js");
|
20 | 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); }
|
21 | function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
22 | 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); } }
|
23 | function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
24 | function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
25 | 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); }
|
26 | var MessageTags = require('./messagetags');
|
27 | module.exports = function () {
|
28 | function IrcMessage(command) {
|
29 | _classCallCheck(this, IrcMessage);
|
30 | this.tags = Object.create(null);
|
31 | this.prefix = '';
|
32 | this.nick = '';
|
33 | this.ident = '';
|
34 | this.hostname = '';
|
35 | this.command = command || '';
|
36 | for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
37 | args[_key - 1] = arguments[_key];
|
38 | }
|
39 | this.params = args || [];
|
40 | }
|
41 | return _createClass(IrcMessage, [{
|
42 | key: "to1459",
|
43 | value: function to1459() {
|
44 | var _this = this;
|
45 | var parts = [];
|
46 | var tags = MessageTags.encode(this.tags);
|
47 | if (tags) {
|
48 | parts.push('@' + tags);
|
49 | }
|
50 | if (this.prefix) {
|
51 |
|
52 | parts.push(':' + this.prefix);
|
53 | }
|
54 | parts.push(this.command);
|
55 | if (this.params.length > 0) {
|
56 | this.params.forEach(function (param, idx) {
|
57 | if (idx === _this.params.length - 1 && (param.indexOf(' ') > -1 || param[0] === ':')) {
|
58 | parts.push(':' + param);
|
59 | } else {
|
60 | parts.push(param);
|
61 | }
|
62 | });
|
63 | }
|
64 | return parts.join(' ');
|
65 | }
|
66 | }, {
|
67 | key: "toJson",
|
68 | value: function toJson() {
|
69 | return {
|
70 | tags: Object.assign({}, this.tags),
|
71 | source: this.prefix,
|
72 | command: this.command,
|
73 | params: this.params
|
74 | };
|
75 | }
|
76 | }]);
|
77 | }(); |
\ | No newline at end of file |