@lordbex/thelounge 4.4.4-blowfish → 4.5.1-blowfish

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/README.md +2 -2
  2. package/dist/defaults/config.js +31 -2
  3. package/dist/package.json +93 -91
  4. package/dist/server/client.js +188 -194
  5. package/dist/server/clientManager.js +65 -63
  6. package/dist/server/command-line/index.js +44 -43
  7. package/dist/server/command-line/install.js +37 -70
  8. package/dist/server/command-line/outdated.js +12 -17
  9. package/dist/server/command-line/start.js +25 -26
  10. package/dist/server/command-line/storage.js +26 -31
  11. package/dist/server/command-line/uninstall.js +16 -23
  12. package/dist/server/command-line/upgrade.js +20 -26
  13. package/dist/server/command-line/users/add.js +33 -40
  14. package/dist/server/command-line/users/edit.js +18 -24
  15. package/dist/server/command-line/users/index.js +12 -16
  16. package/dist/server/command-line/users/list.js +11 -39
  17. package/dist/server/command-line/users/remove.js +16 -22
  18. package/dist/server/command-line/users/reset.js +34 -35
  19. package/dist/server/command-line/utils.js +231 -87
  20. package/dist/server/config.js +61 -52
  21. package/dist/server/helper.js +29 -28
  22. package/dist/server/identification.js +39 -34
  23. package/dist/server/index.js +1 -3
  24. package/dist/server/log.js +19 -16
  25. package/dist/server/models/chan.js +36 -33
  26. package/dist/server/models/msg.js +15 -19
  27. package/dist/server/models/network.js +88 -86
  28. package/dist/server/models/prefix.js +4 -7
  29. package/dist/server/models/user.js +5 -10
  30. package/dist/server/path-helper.js +8 -0
  31. package/dist/server/plugins/auth/ldap.js +177 -112
  32. package/dist/server/plugins/auth/local.js +10 -15
  33. package/dist/server/plugins/auth.js +6 -35
  34. package/dist/server/plugins/changelog.js +30 -27
  35. package/dist/server/plugins/clientCertificate.js +33 -37
  36. package/dist/server/plugins/dev-server.js +15 -21
  37. package/dist/server/plugins/inputs/action.js +9 -14
  38. package/dist/server/plugins/inputs/away.js +1 -3
  39. package/dist/server/plugins/inputs/ban.js +9 -14
  40. package/dist/server/plugins/inputs/blow.js +9 -14
  41. package/dist/server/plugins/inputs/connect.js +5 -10
  42. package/dist/server/plugins/inputs/ctcp.js +7 -12
  43. package/dist/server/plugins/inputs/disconnect.js +1 -3
  44. package/dist/server/plugins/inputs/ignore.js +23 -29
  45. package/dist/server/plugins/inputs/ignorelist.js +12 -18
  46. package/dist/server/plugins/inputs/index.js +8 -34
  47. package/dist/server/plugins/inputs/invite.js +7 -12
  48. package/dist/server/plugins/inputs/kick.js +7 -12
  49. package/dist/server/plugins/inputs/kill.js +1 -3
  50. package/dist/server/plugins/inputs/list.js +1 -3
  51. package/dist/server/plugins/inputs/mode.js +10 -15
  52. package/dist/server/plugins/inputs/msg.js +13 -18
  53. package/dist/server/plugins/inputs/mute.js +9 -15
  54. package/dist/server/plugins/inputs/nick.js +9 -14
  55. package/dist/server/plugins/inputs/notice.js +5 -7
  56. package/dist/server/plugins/inputs/part.js +11 -16
  57. package/dist/server/plugins/inputs/quit.js +7 -13
  58. package/dist/server/plugins/inputs/rainbow.js +55 -0
  59. package/dist/server/plugins/inputs/raw.js +1 -3
  60. package/dist/server/plugins/inputs/rejoin.js +7 -12
  61. package/dist/server/plugins/inputs/topic.js +7 -12
  62. package/dist/server/plugins/inputs/whois.js +1 -3
  63. package/dist/server/plugins/irc-events/away.js +14 -20
  64. package/dist/server/plugins/irc-events/cap.js +16 -22
  65. package/dist/server/plugins/irc-events/chghost.js +14 -13
  66. package/dist/server/plugins/irc-events/connection.js +61 -63
  67. package/dist/server/plugins/irc-events/ctcp.js +22 -28
  68. package/dist/server/plugins/irc-events/error.js +20 -26
  69. package/dist/server/plugins/irc-events/help.js +7 -13
  70. package/dist/server/plugins/irc-events/info.js +7 -13
  71. package/dist/server/plugins/irc-events/invite.js +7 -13
  72. package/dist/server/plugins/irc-events/join.js +30 -27
  73. package/dist/server/plugins/irc-events/kick.js +21 -17
  74. package/dist/server/plugins/irc-events/link.js +75 -96
  75. package/dist/server/plugins/irc-events/list.js +23 -26
  76. package/dist/server/plugins/irc-events/message.js +46 -52
  77. package/dist/server/plugins/irc-events/mode.js +66 -63
  78. package/dist/server/plugins/irc-events/modelist.js +29 -35
  79. package/dist/server/plugins/irc-events/motd.js +10 -16
  80. package/dist/server/plugins/irc-events/names.js +3 -6
  81. package/dist/server/plugins/irc-events/nick.js +26 -23
  82. package/dist/server/plugins/irc-events/part.js +19 -15
  83. package/dist/server/plugins/irc-events/quit.js +17 -14
  84. package/dist/server/plugins/irc-events/sasl.js +9 -15
  85. package/dist/server/plugins/irc-events/spgroups.js +38 -0
  86. package/dist/server/plugins/irc-events/spjoin.js +52 -0
  87. package/dist/server/plugins/irc-events/topic.js +12 -18
  88. package/dist/server/plugins/irc-events/unhandled.js +12 -12
  89. package/dist/server/plugins/irc-events/welcome.js +7 -13
  90. package/dist/server/plugins/irc-events/whois.js +20 -24
  91. package/dist/server/plugins/massEventAggregator.js +214 -0
  92. package/dist/server/plugins/messageStorage/sqlite.js +322 -141
  93. package/dist/server/plugins/messageStorage/text.js +21 -26
  94. package/dist/server/plugins/packages/index.js +105 -74
  95. package/dist/server/plugins/packages/publicClient.js +7 -16
  96. package/dist/server/plugins/packages/themes.js +11 -16
  97. package/dist/server/plugins/storage.js +28 -33
  98. package/dist/server/plugins/sts.js +12 -17
  99. package/dist/server/plugins/uploader.js +40 -43
  100. package/dist/server/plugins/webpush.js +23 -51
  101. package/dist/server/server.js +318 -271
  102. package/dist/server/storageCleaner.js +29 -37
  103. package/dist/server/utils/fish.js +7 -14
  104. package/dist/shared/irc.js +3 -6
  105. package/dist/shared/linkify.js +7 -14
  106. package/dist/shared/types/chan.js +6 -9
  107. package/dist/shared/types/changelog.js +1 -2
  108. package/dist/shared/types/config.js +1 -2
  109. package/dist/shared/types/mention.js +1 -2
  110. package/dist/shared/types/msg.js +3 -5
  111. package/dist/shared/types/network.js +1 -2
  112. package/dist/shared/types/storage.js +1 -2
  113. package/dist/shared/types/user.js +1 -2
  114. package/index.js +14 -10
  115. package/package.json +93 -91
  116. package/public/css/style.css +9 -6
  117. package/public/css/style.css.map +1 -1
  118. package/public/fonts/font-awesome/fa-brands-400.ttf +0 -0
  119. package/public/fonts/font-awesome/fa-brands-400.woff2 +0 -0
  120. package/public/fonts/font-awesome/fa-duotone-900.ttf +0 -0
  121. package/public/fonts/font-awesome/fa-duotone-900.woff2 +0 -0
  122. package/public/fonts/font-awesome/fa-light-300.ttf +0 -0
  123. package/public/fonts/font-awesome/fa-light-300.woff2 +0 -0
  124. package/public/fonts/font-awesome/fa-regular-400.ttf +0 -0
  125. package/public/fonts/font-awesome/fa-regular-400.woff2 +0 -0
  126. package/public/fonts/font-awesome/fa-solid-900.ttf +0 -0
  127. package/public/fonts/font-awesome/fa-solid-900.woff2 +0 -0
  128. package/public/fonts/font-awesome/fa-thin-100.ttf +0 -0
  129. package/public/fonts/font-awesome/fa-thin-100.woff2 +0 -0
  130. package/public/fonts/font-awesome/fa-v4compatibility.ttf +0 -0
  131. package/public/fonts/font-awesome/fa-v4compatibility.woff2 +0 -0
  132. package/public/js/bundle.js +1 -1
  133. package/public/js/bundle.js.map +1 -1
  134. package/public/js/bundle.vendor.js +1 -1
  135. package/public/js/bundle.vendor.js.LICENSE.txt +24 -6
  136. package/public/js/bundle.vendor.js.map +1 -1
  137. package/public/service-worker.js +1 -1
  138. package/public/themes/default.css +1 -1
  139. package/public/themes/morning.css +1 -1
  140. package/dist/webpack.config.js +0 -224
@@ -1,31 +1,23 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const msg_1 = __importDefault(require("../../models/msg"));
7
- const msg_2 = require("../../../shared/types/msg");
8
- const chan_1 = require("../../../shared/types/chan");
9
- exports.default = (function (irc, network) {
10
- const client = this;
11
- irc.on("away", (data) => handleAway(msg_2.MessageType.AWAY, data));
12
- irc.on("back", (data) => handleAway(msg_2.MessageType.BACK, data));
13
- function handleAway(type, data) {
1
+ import Msg from "../../models/msg.js";
2
+ import { MessageType } from "../../../shared/types/msg.js";
3
+ import { ChanType } from "../../../shared/types/chan.js";
4
+ export default (function (irc, network) {
5
+ const handleAway = (type, data) => {
14
6
  const away = data.message;
15
7
  if (data.self) {
16
- const msg = new msg_1.default({
8
+ const msg = new Msg({
17
9
  self: true,
18
10
  type: type,
19
11
  text: away,
20
12
  time: data.time,
21
13
  });
22
- network.getLobby().pushMessage(client, msg, true);
14
+ network.getLobby().pushMessage(this, msg, true);
23
15
  return;
24
16
  }
25
17
  network.channels.forEach((chan) => {
26
18
  let user;
27
19
  switch (chan.type) {
28
- case chan_1.ChanType.QUERY: {
20
+ case ChanType.QUERY: {
29
21
  if (data.nick.toLowerCase() !== chan.name.toLowerCase()) {
30
22
  return;
31
23
  }
@@ -36,16 +28,16 @@ exports.default = (function (irc, network) {
36
28
  // because query windows have no users
37
29
  chan.userAway = away;
38
30
  user = chan.getUser(data.nick);
39
- const msg = new msg_1.default({
31
+ const msg = new Msg({
40
32
  type: type,
41
33
  text: away || "",
42
34
  time: data.time,
43
35
  from: user,
44
36
  });
45
- chan.pushMessage(client, msg);
37
+ chan.pushMessage(this, msg);
46
38
  break;
47
39
  }
48
- case chan_1.ChanType.CHANNEL: {
40
+ case ChanType.CHANNEL: {
49
41
  user = chan.findUser(data.nick);
50
42
  if (!user || user.away === away) {
51
43
  return;
@@ -55,5 +47,7 @@ exports.default = (function (irc, network) {
55
47
  }
56
48
  }
57
49
  });
58
- }
50
+ };
51
+ irc.on("away", (data) => handleAway(MessageType.AWAY, data));
52
+ irc.on("back", (data) => handleAway(MessageType.BACK, data));
59
53
  });
@@ -1,19 +1,7 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const msg_1 = __importDefault(require("../../models/msg"));
7
- const sts_1 = __importDefault(require("../sts"));
8
- exports.default = (function (irc, network) {
9
- const client = this;
10
- irc.on("cap ls", (data) => {
11
- handleSTS(data, true);
12
- });
13
- irc.on("cap new", (data) => {
14
- handleSTS(data, false);
15
- });
16
- function handleSTS(data, shouldReconnect) {
1
+ import Msg from "../../models/msg.js";
2
+ import STSPolicies from "../sts.js";
3
+ export default (function (irc, network) {
4
+ const handleSTS = (data, shouldReconnect) => {
17
5
  if (!Object.prototype.hasOwnProperty.call(data.capabilities, "sts")) {
18
6
  return;
19
7
  }
@@ -24,18 +12,18 @@ exports.default = (function (irc, network) {
24
12
  values[value[0]] = value[1];
25
13
  });
26
14
  if (isSecure) {
27
- const duration = parseInt(values.duration, 10);
15
+ const duration = parseInt(values.duration ?? "", 10);
28
16
  if (isNaN(duration)) {
29
17
  return;
30
18
  }
31
- sts_1.default.update(network.host, network.port, duration);
19
+ STSPolicies.update(network.host, network.port, duration);
32
20
  }
33
21
  else {
34
- const port = parseInt(values.port, 10);
22
+ const port = parseInt(values.port ?? "", 10);
35
23
  if (isNaN(port)) {
36
24
  return;
37
25
  }
38
- network.getLobby().pushMessage(client, new msg_1.default({
26
+ network.getLobby().pushMessage(this, new Msg({
39
27
  text: `Server sent a strict transport security policy, reconnecting to ${network.host}:${port}…`,
40
28
  }), true);
41
29
  // Forcefully end the connection if STS is seen in CAP LS
@@ -56,7 +44,13 @@ exports.default = (function (irc, network) {
56
44
  // Start a new connection
57
45
  irc.connect();
58
46
  }
59
- client.save();
47
+ this.save();
60
48
  }
61
- }
49
+ };
50
+ irc.on("cap ls", (data) => {
51
+ handleSTS(data, true);
52
+ });
53
+ irc.on("cap new", (data) => {
54
+ handleSTS(data, false);
55
+ });
62
56
  });
@@ -1,29 +1,30 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const msg_1 = __importDefault(require("../../models/msg"));
7
- const msg_2 = require("../../../shared/types/msg");
8
- exports.default = (function (irc, network) {
9
- const client = this;
1
+ import Msg from "../../models/msg.js";
2
+ import { MessageType } from "../../../shared/types/msg.js";
3
+ export default (function (irc, network) {
10
4
  // If server supports CHGHOST cap, then changing the hostname does not require
11
5
  // sending PART and JOIN, which means less work for us over all
12
- irc.on("user updated", function (data) {
6
+ irc.on("user updated", (data) => {
13
7
  network.channels.forEach((chan) => {
14
8
  const user = chan.findUser(data.nick);
15
9
  if (typeof user === "undefined") {
16
10
  return;
17
11
  }
18
- const msg = new msg_1.default({
12
+ const msg = new Msg({
19
13
  time: data.time,
20
- type: msg_2.MessageType.CHGHOST,
14
+ type: MessageType.CHGHOST,
21
15
  new_ident: data.ident !== data.new_ident ? data.new_ident : "",
22
16
  new_host: data.hostname !== data.new_hostname ? data.new_hostname : "",
23
17
  self: data.nick === irc.user.nick,
24
18
  from: user,
25
19
  });
26
- chan.pushMessage(client, msg);
20
+ // Try to process through mass event aggregator
21
+ // No user list update needed for chghost
22
+ const wasBuffered = this.massEventAggregator.processMessage(network, chan, msg, () => { } // No user list changes for chghost
23
+ );
24
+ if (!wasBuffered) {
25
+ // Not in mass event mode - process normally
26
+ chan.pushMessage(this, msg);
27
+ }
27
28
  });
28
29
  });
29
30
  });
@@ -1,23 +1,25 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const lodash_1 = __importDefault(require("lodash"));
7
- const log_1 = __importDefault(require("../../log"));
8
- const msg_1 = __importDefault(require("../../models/msg"));
9
- const helper_1 = __importDefault(require("../../helper"));
10
- const config_1 = __importDefault(require("../../config"));
11
- const msg_2 = require("../../../shared/types/msg");
12
- const chan_1 = require("../../../shared/types/chan");
13
- exports.default = (function (irc, network) {
14
- const client = this;
15
- network.getLobby().pushMessage(client, new msg_1.default({
1
+ import _ from "lodash";
2
+ import log from "../../log.js";
3
+ import Msg from "../../models/msg.js";
4
+ import Helper from "../../helper.js";
5
+ import Config from "../../config.js";
6
+ import { MessageType } from "../../../shared/types/msg.js";
7
+ import { ChanType, ChanState } from "../../../shared/types/chan.js";
8
+ export default (function (irc, network) {
9
+ const sendStatus = () => {
10
+ const status = network.getNetworkStatus();
11
+ const toSend = {
12
+ ...status,
13
+ network: network.uuid,
14
+ };
15
+ this.emit("network:status", toSend);
16
+ };
17
+ network.getLobby().pushMessage(this, new Msg({
16
18
  text: "Network created, connecting to " + network.host + ":" + network.port + "...",
17
19
  }), true);
18
- irc.on("registered", function () {
20
+ irc.on("registered", () => {
19
21
  if (network.irc.network.cap.enabled.length > 0) {
20
- network.getLobby().pushMessage(client, new msg_1.default({
22
+ network.getLobby().pushMessage(this, new Msg({
21
23
  text: "Enabled capabilities: " + network.irc.network.cap.enabled.join(", "),
22
24
  }), true);
23
25
  }
@@ -26,14 +28,14 @@ exports.default = (function (irc, network) {
26
28
  irc.raw("AWAY", network.awayMessage);
27
29
  // Only set generic away message if there are no clients attached
28
30
  }
29
- else if (client.awayMessage && lodash_1.default.size(client.attachedClients) === 0) {
30
- irc.raw("AWAY", client.awayMessage);
31
+ else if (this.awayMessage && _.size(this.attachedClients) === 0) {
32
+ irc.raw("AWAY", this.awayMessage);
31
33
  }
32
34
  let delay = 1000;
33
35
  if (Array.isArray(network.commands)) {
34
36
  network.commands.forEach((cmd) => {
35
- setTimeout(function () {
36
- client.input({
37
+ setTimeout(() => {
38
+ this.input({
37
39
  target: network.getLobby().id,
38
40
  text: cmd,
39
41
  });
@@ -42,50 +44,54 @@ exports.default = (function (irc, network) {
42
44
  });
43
45
  }
44
46
  network.channels.forEach((chan) => {
45
- if (chan.type !== chan_1.ChanType.CHANNEL) {
47
+ if (chan.type !== ChanType.CHANNEL) {
46
48
  return;
47
49
  }
48
- setTimeout(function () {
50
+ setTimeout(() => {
49
51
  network.irc.join(chan.name, chan.key);
50
52
  }, delay);
51
53
  delay += 1000;
52
54
  });
53
55
  });
54
- irc.on("socket connected", function () {
56
+ irc.on("socket connected", () => {
55
57
  if (irc.network.options.PREFIX) {
56
58
  network.serverOptions.PREFIX.update(irc.network.options.PREFIX);
57
59
  }
58
- network.getLobby().pushMessage(client, new msg_1.default({
60
+ network.getLobby().pushMessage(this, new Msg({
59
61
  text: "Connected to the network.",
60
62
  }), true);
61
63
  sendStatus();
62
64
  });
63
- irc.on("close", function () {
64
- network.getLobby().pushMessage(client, new msg_1.default({
65
+ irc.on("close", () => {
66
+ network.getLobby().pushMessage(this, new Msg({
65
67
  text: "Disconnected from the network, and will not reconnect. Use /connect to reconnect again.",
66
68
  }), true);
67
69
  });
68
70
  let identSocketId;
69
- irc.on("raw socket connected", function (socket) {
70
- let ident = client.name || network.username;
71
- if (config_1.default.values.useHexIp) {
72
- ident = helper_1.default.ip2hex(client.config.browser.ip);
71
+ irc.on("raw socket connected", (socket) => {
72
+ let ident = this.name || network.username;
73
+ if (Config.values.useHexIp) {
74
+ ident = Helper.ip2hex(this.config.browser.ip);
73
75
  }
74
- identSocketId = client.manager.identHandler.addSocket(socket, ident);
76
+ identSocketId = this.manager.identHandler.addSocket(socket, ident);
75
77
  });
76
- irc.on("socket close", function (error) {
78
+ irc.on("socket close", (error) => {
77
79
  if (identSocketId > 0) {
78
- client.manager.identHandler.removeSocket(identSocketId);
80
+ this.manager.identHandler.removeSocket(identSocketId);
79
81
  identSocketId = 0;
80
82
  }
81
83
  network.channels.forEach((chan) => {
82
84
  chan.users = new Map();
83
- chan.state = chan_1.ChanState.PARTED;
85
+ chan.state = ChanState.PARTED;
84
86
  });
85
87
  if (error) {
86
- network.getLobby().pushMessage(client, new msg_1.default({
87
- type: msg_2.MessageType.ERROR,
88
- text: `Connection closed unexpectedly: ${String(error)}`,
88
+ network.getLobby().pushMessage(this, new Msg({
89
+ type: MessageType.ERROR,
90
+ text: `Connection closed unexpectedly: ${error instanceof Error
91
+ ? error.message
92
+ : typeof error === "string"
93
+ ? error
94
+ : "Unknown error"}`,
89
95
  }), true);
90
96
  }
91
97
  if (network.keepNick) {
@@ -93,60 +99,52 @@ exports.default = (function (irc, network) {
93
99
  irc.options.nick = irc.user.nick = network.keepNick;
94
100
  network.setNick(network.keepNick);
95
101
  network.keepNick = null;
96
- client.emit("nick", {
102
+ this.emit("nick", {
97
103
  network: network.uuid,
98
104
  nick: network.nick,
99
105
  });
100
106
  }
101
107
  sendStatus();
102
108
  });
103
- if (config_1.default.values.debug.ircFramework) {
104
- irc.on("debug", function (message) {
105
- log_1.default.debug(`[${client.name} (${client.id}) on ${network.name} (${network.uuid}]`, message);
109
+ if (Config.values.debug.ircFramework) {
110
+ irc.on("debug", (message) => {
111
+ log.debug(`[${this.name} (${this.id}) on ${network.name} (${network.uuid}]`, message);
106
112
  });
107
113
  }
108
- if (config_1.default.values.debug.raw) {
109
- irc.on("raw", function (message) {
110
- network.getLobby().pushMessage(client, new msg_1.default({
114
+ if (Config.values.debug.raw) {
115
+ irc.on("raw", (message) => {
116
+ network.getLobby().pushMessage(this, new Msg({
111
117
  self: !message.from_server,
112
- type: msg_2.MessageType.RAW,
118
+ type: MessageType.RAW,
113
119
  text: message.line,
114
120
  }), true);
115
121
  });
116
122
  }
117
- irc.on("socket error", function (err) {
118
- network.getLobby().pushMessage(client, new msg_1.default({
119
- type: msg_2.MessageType.ERROR,
123
+ irc.on("socket error", (err) => {
124
+ network.getLobby().pushMessage(this, new Msg({
125
+ type: MessageType.ERROR,
120
126
  text: "Socket error: " + err,
121
127
  }), true);
122
128
  });
123
- irc.on("reconnecting", function (data) {
124
- network.getLobby().pushMessage(client, new msg_1.default({
129
+ irc.on("reconnecting", (data) => {
130
+ network.getLobby().pushMessage(this, new Msg({
125
131
  text: `Disconnected from the network. Reconnecting in ${Math.round(data.wait / 1000)} seconds… (Attempt ${Number(data.attempt)})`,
126
132
  }), true);
127
133
  });
128
- irc.on("ping timeout", function () {
129
- network.getLobby().pushMessage(client, new msg_1.default({
134
+ irc.on("ping timeout", () => {
135
+ network.getLobby().pushMessage(this, new Msg({
130
136
  text: "Ping timeout, disconnecting…",
131
137
  }), true);
132
138
  });
133
- irc.on("server options", function (data) {
139
+ irc.on("server options", (data) => {
134
140
  network.serverOptions.PREFIX.update(data.options.PREFIX);
135
141
  if (data.options.CHANTYPES) {
136
142
  network.serverOptions.CHANTYPES = data.options.CHANTYPES;
137
143
  }
138
144
  network.serverOptions.NETWORK = data.options.NETWORK;
139
- client.emit("network:options", {
145
+ this.emit("network:options", {
140
146
  network: network.uuid,
141
147
  serverOptions: network.serverOptions,
142
148
  });
143
149
  });
144
- function sendStatus() {
145
- const status = network.getNetworkStatus();
146
- const toSend = {
147
- ...status,
148
- network: network.uuid,
149
- };
150
- client.emit("network:status", toSend);
151
- }
152
150
  });
@@ -1,28 +1,22 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const lodash_1 = __importDefault(require("lodash"));
7
- const helper_1 = __importDefault(require("../../helper"));
8
- const msg_1 = __importDefault(require("../../models/msg"));
9
- const user_1 = __importDefault(require("../../models/user"));
10
- const package_json_1 = __importDefault(require("../../../package.json"));
11
- const msg_2 = require("../../../shared/types/msg");
1
+ import _ from "lodash";
2
+ import Helper from "../../helper.js";
3
+ import Msg from "../../models/msg.js";
4
+ import User from "../../models/user.js";
5
+ import pkg from "../../../package.json" with { type: "json" };
6
+ import { MessageType } from "../../../shared/types/msg.js";
12
7
  const ctcpResponses = {
13
8
  CLIENTINFO: () => Object.getOwnPropertyNames(ctcpResponses)
14
9
  .filter((key) => key !== "CLIENTINFO" && typeof ctcpResponses[key] === "function")
15
10
  .join(" "),
16
11
  PING: ({ message }) => message.substring(5),
17
- SOURCE: () => package_json_1.default.repository.url,
18
- VERSION: () => package_json_1.default.name + " -- " + package_json_1.default.homepage,
12
+ SOURCE: () => pkg.repository.url,
13
+ VERSION: () => pkg.name + " -- " + pkg.homepage,
19
14
  };
20
- exports.default = (function (irc, network) {
21
- const client = this;
15
+ export default (function (irc, network) {
22
16
  const lobby = network.getLobby();
23
- irc.on("ctcp response", function (data) {
24
- const shouldIgnore = network.ignoreList.some(function (entry) {
25
- return helper_1.default.compareHostmask(entry, data);
17
+ irc.on("ctcp response", (data) => {
18
+ const shouldIgnore = network.ignoreList.some((entry) => {
19
+ return Helper.compareHostmask(entry, data);
26
20
  });
27
21
  if (shouldIgnore) {
28
22
  return;
@@ -31,16 +25,16 @@ exports.default = (function (irc, network) {
31
25
  if (typeof chan === "undefined") {
32
26
  chan = lobby;
33
27
  }
34
- const msg = new msg_1.default({
35
- type: msg_2.MessageType.CTCP,
28
+ const msg = new Msg({
29
+ type: MessageType.CTCP,
36
30
  time: data.time,
37
31
  from: chan.getUser(data.nick),
38
32
  ctcpMessage: data.message,
39
33
  });
40
- chan.pushMessage(client, msg, true);
34
+ chan.pushMessage(this, msg, true);
41
35
  });
42
36
  // Limit requests to a rate of one per second max
43
- irc.on("ctcp request", lodash_1.default.throttle((data) => {
37
+ irc.on("ctcp request", _.throttle((data) => {
44
38
  // Ignore echoed ctcp requests that aren't targeted at us
45
39
  // See https://github.com/kiwiirc/irc-framework/issues/225
46
40
  if (data.nick === irc.user.nick &&
@@ -48,8 +42,8 @@ exports.default = (function (irc, network) {
48
42
  network.irc.network.cap.isEnabled("echo-message")) {
49
43
  return;
50
44
  }
51
- const shouldIgnore = network.ignoreList.some(function (entry) {
52
- return helper_1.default.compareHostmask(entry, data);
45
+ const shouldIgnore = network.ignoreList.some((entry) => {
46
+ return Helper.compareHostmask(entry, data);
53
47
  });
54
48
  if (shouldIgnore) {
55
49
  return;
@@ -60,13 +54,13 @@ exports.default = (function (irc, network) {
60
54
  irc.ctcpResponse(target, data.type, response(data));
61
55
  }
62
56
  // Let user know someone is making a CTCP request against their nick
63
- const msg = new msg_1.default({
64
- type: msg_2.MessageType.CTCP_REQUEST,
57
+ const msg = new Msg({
58
+ type: MessageType.CTCP_REQUEST,
65
59
  time: data.time,
66
- from: new user_1.default({ nick: target }),
60
+ from: new User({ nick: target }),
67
61
  hostmask: data.ident + "@" + data.hostname,
68
62
  ctcpMessage: data.message,
69
63
  });
70
- lobby.pushMessage(client, msg, true);
64
+ lobby.pushMessage(this, msg, true);
71
65
  }, 1000, { trailing: false }));
72
66
  });
@@ -1,16 +1,10 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const msg_1 = __importDefault(require("../../models/msg"));
7
- const config_1 = __importDefault(require("../../config"));
8
- const msg_2 = require("../../../shared/types/msg");
9
- exports.default = (function (irc, network) {
10
- const client = this;
11
- irc.on("irc error", function (data) {
12
- const msg = new msg_1.default({
13
- type: msg_2.MessageType.ERROR,
1
+ import Msg from "../../models/msg.js";
2
+ import Config from "../../config.js";
3
+ import { MessageType } from "../../../shared/types/msg.js";
4
+ export default (function (irc, network) {
5
+ irc.on("irc error", (data) => {
6
+ const msg = new Msg({
7
+ type: MessageType.ERROR,
14
8
  error: data.error,
15
9
  showInActive: true,
16
10
  nick: data.nick,
@@ -28,11 +22,11 @@ exports.default = (function (irc, network) {
28
22
  msg.showInActive = false;
29
23
  }
30
24
  }
31
- target.pushMessage(client, msg, true);
25
+ target.pushMessage(this, msg, true);
32
26
  });
33
- irc.on("nick in use", function (data) {
27
+ irc.on("nick in use", (data) => {
34
28
  let message = data.nick + ": " + (data.reason || "Nickname is already in use.");
35
- if (irc.connection.registered === false && !config_1.default.values.public) {
29
+ if (irc.connection.registered === false && !Config.values.public) {
36
30
  message += " An attempt to use it will be made when this nick quits.";
37
31
  // Clients usually get nick in use on connect when reconnecting to a network
38
32
  // after a network failure (like ping timeout), and as a result of that,
@@ -41,12 +35,12 @@ exports.default = (function (irc, network) {
41
35
  network.keepNick = irc.user.nick;
42
36
  }
43
37
  const lobby = network.getLobby();
44
- const msg = new msg_1.default({
45
- type: msg_2.MessageType.ERROR,
38
+ const msg = new Msg({
39
+ type: MessageType.ERROR,
46
40
  text: message,
47
41
  showInActive: true,
48
42
  });
49
- lobby.pushMessage(client, msg, true);
43
+ lobby.pushMessage(this, msg, true);
50
44
  if (irc.connection.registered === false) {
51
45
  const nickLen = parseInt(network.irc.network.options.NICKLEN, 10) || 16;
52
46
  const random = (data.nick || irc.user.nick) + Math.floor(Math.random() * 10);
@@ -56,23 +50,23 @@ exports.default = (function (irc, network) {
56
50
  irc.changeNick(random);
57
51
  }
58
52
  }
59
- client.emit("nick", {
53
+ this.emit("nick", {
60
54
  network: network.uuid,
61
55
  nick: irc.user.nick,
62
56
  });
63
57
  });
64
- irc.on("nick invalid", function (data) {
58
+ irc.on("nick invalid", (data) => {
65
59
  const lobby = network.getLobby();
66
- const msg = new msg_1.default({
67
- type: msg_2.MessageType.ERROR,
60
+ const msg = new Msg({
61
+ type: MessageType.ERROR,
68
62
  text: data.nick + ": " + (data.reason || "Nickname is invalid."),
69
63
  showInActive: true,
70
64
  });
71
- lobby.pushMessage(client, msg, true);
65
+ lobby.pushMessage(this, msg, true);
72
66
  if (irc.connection.registered === false) {
73
- irc.changeNick(config_1.default.getDefaultNick());
67
+ irc.changeNick(Config.getDefaultNick());
74
68
  }
75
- client.emit("nick", {
69
+ this.emit("nick", {
76
70
  network: network.uuid,
77
71
  nick: irc.user.nick,
78
72
  });
@@ -1,21 +1,15 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const msg_1 = __importDefault(require("../../models/msg"));
7
- const msg_2 = require("../../../shared/types/msg");
8
- exports.default = (function (irc, network) {
9
- const client = this;
10
- irc.on("help", function (data) {
1
+ import Msg from "../../models/msg.js";
2
+ import { MessageType } from "../../../shared/types/msg.js";
3
+ export default (function (irc, network) {
4
+ irc.on("help", (data) => {
11
5
  const lobby = network.getLobby();
12
6
  if (data.help) {
13
- const msg = new msg_1.default({
14
- type: msg_2.MessageType.MONOSPACE_BLOCK,
7
+ const msg = new Msg({
8
+ type: MessageType.MONOSPACE_BLOCK,
15
9
  command: "help",
16
10
  text: data.help,
17
11
  });
18
- lobby.pushMessage(client, msg, true);
12
+ lobby.pushMessage(this, msg, true);
19
13
  }
20
14
  });
21
15
  });
@@ -1,21 +1,15 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const msg_1 = __importDefault(require("../../models/msg"));
7
- const msg_2 = require("../../../shared/types/msg");
8
- exports.default = (function (irc, network) {
9
- const client = this;
10
- irc.on("info", function (data) {
1
+ import Msg from "../../models/msg.js";
2
+ import { MessageType } from "../../../shared/types/msg.js";
3
+ export default (function (irc, network) {
4
+ irc.on("info", (data) => {
11
5
  const lobby = network.getLobby();
12
6
  if (data.info) {
13
- const msg = new msg_1.default({
14
- type: msg_2.MessageType.MONOSPACE_BLOCK,
7
+ const msg = new Msg({
8
+ type: MessageType.MONOSPACE_BLOCK,
15
9
  command: "info",
16
10
  text: data.info,
17
11
  });
18
- lobby.pushMessage(client, msg, true);
12
+ lobby.pushMessage(this, msg, true);
19
13
  }
20
14
  });
21
15
  });