@lordbex/thelounge 4.4.4-blowfish → 4.5.0-blowfish-pre

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,11 +1,6 @@
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");
1
+ import Msg from "../../models/msg.js";
2
+ import { MessageType } from "../../../shared/types/msg.js";
3
+ import { ChanType } from "../../../shared/types/chan.js";
9
4
  const commands = ["invite", "invitelist"];
10
5
  const input = function ({ irc }, chan, cmd, args) {
11
6
  if (cmd === "invitelist") {
@@ -15,17 +10,17 @@ const input = function ({ irc }, chan, cmd, args) {
15
10
  if (args.length === 2) {
16
11
  irc.raw("INVITE", args[0], args[1]); // Channel provided in the command
17
12
  }
18
- else if (args.length === 1 && chan.type === chan_1.ChanType.CHANNEL) {
13
+ else if (args.length === 1 && chan.type === ChanType.CHANNEL) {
19
14
  irc.raw("INVITE", args[0], chan.name); // Current channel
20
15
  }
21
16
  else {
22
- chan.pushMessage(this, new msg_1.default({
23
- type: msg_2.MessageType.ERROR,
17
+ chan.pushMessage(this, new Msg({
18
+ type: MessageType.ERROR,
24
19
  text: `${cmd} command can only be used in channels or by specifying a target.`,
25
20
  }));
26
21
  }
27
22
  };
28
- exports.default = {
23
+ export default {
29
24
  commands,
30
25
  input,
31
26
  };
@@ -1,16 +1,11 @@
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");
1
+ import Msg from "../../models/msg.js";
2
+ import { MessageType } from "../../../shared/types/msg.js";
3
+ import { ChanType } from "../../../shared/types/chan.js";
9
4
  const commands = ["kick"];
10
5
  const input = function ({ irc }, chan, cmd, args) {
11
- if (chan.type !== chan_1.ChanType.CHANNEL) {
12
- chan.pushMessage(this, new msg_1.default({
13
- type: msg_2.MessageType.ERROR,
6
+ if (chan.type !== ChanType.CHANNEL) {
7
+ chan.pushMessage(this, new Msg({
8
+ type: MessageType.ERROR,
14
9
  text: `${cmd} command can only be used in channels.`,
15
10
  }));
16
11
  return;
@@ -20,7 +15,7 @@ const input = function ({ irc }, chan, cmd, args) {
20
15
  }
21
16
  return true;
22
17
  };
23
- exports.default = {
18
+ export default {
24
19
  commands,
25
20
  input,
26
21
  };
@@ -1,5 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  const commands = ["kill"];
4
2
  const input = function ({ irc }, chan, cmd, args) {
5
3
  if (args.length !== 0) {
@@ -7,7 +5,7 @@ const input = function ({ irc }, chan, cmd, args) {
7
5
  }
8
6
  return true;
9
7
  };
10
- exports.default = {
8
+ export default {
11
9
  commands,
12
10
  input,
13
11
  };
@@ -1,12 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  const commands = ["list"];
4
2
  const input = function (network, chan, cmd, args) {
5
3
  network.chanCache = [];
6
4
  network.irc.list(...args);
7
5
  return true;
8
6
  };
9
- exports.default = {
7
+ export default {
10
8
  commands,
11
9
  input,
12
10
  };
@@ -1,11 +1,6 @@
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");
1
+ import Msg from "../../models/msg.js";
2
+ import { MessageType } from "../../../shared/types/msg.js";
3
+ import { ChanType } from "../../../shared/types/chan.js";
9
4
  const commands = ["mode", "umode", "op", "deop", "hop", "dehop", "voice", "devoice"];
10
5
  const input = function ({ irc, nick }, chan, cmd, args) {
11
6
  if (cmd === "umode") {
@@ -13,17 +8,17 @@ const input = function ({ irc, nick }, chan, cmd, args) {
13
8
  return;
14
9
  }
15
10
  else if (cmd !== "mode") {
16
- if (chan.type !== chan_1.ChanType.CHANNEL) {
17
- chan.pushMessage(this, new msg_1.default({
18
- type: msg_2.MessageType.ERROR,
11
+ if (chan.type !== ChanType.CHANNEL) {
12
+ chan.pushMessage(this, new Msg({
13
+ type: MessageType.ERROR,
19
14
  text: `${cmd} command can only be used in channels.`,
20
15
  }));
21
16
  return;
22
17
  }
23
18
  const target = args.filter((arg) => arg !== "");
24
19
  if (target.length === 0) {
25
- chan.pushMessage(this, new msg_1.default({
26
- type: msg_2.MessageType.ERROR,
20
+ chan.pushMessage(this, new Msg({
21
+ type: MessageType.ERROR,
27
22
  text: `Usage: /${cmd} <nick> [...nick]`,
28
23
  }));
29
24
  return;
@@ -45,11 +40,11 @@ const input = function ({ irc, nick }, chan, cmd, args) {
45
40
  return;
46
41
  }
47
42
  if (args.length === 0 || args[0][0] === "+" || args[0][0] === "-") {
48
- args.unshift(chan.type === chan_1.ChanType.CHANNEL || chan.type === chan_1.ChanType.QUERY ? chan.name : nick);
43
+ args.unshift(chan.type === ChanType.CHANNEL || chan.type === ChanType.QUERY ? chan.name : nick);
49
44
  }
50
45
  irc.raw("MODE", ...args);
51
46
  };
52
- exports.default = {
47
+ export default {
53
48
  commands,
54
49
  input,
55
50
  };
@@ -1,12 +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 msg_2 = require("../../../shared/types/msg");
8
- const chan_1 = require("../../../shared/types/chan");
9
- const fish_1 = require("../../utils/fish");
1
+ import Msg from "../../models/msg.js";
2
+ import { MessageType } from "../../../shared/types/msg.js";
3
+ import { ChanType } from "../../../shared/types/chan.js";
4
+ import { createFishMessage } from "../../utils/fish.js";
10
5
  const commands = ["query", "msg", "say"];
11
6
  function getTarget(cmd, args, chan) {
12
7
  switch (cmd) {
@@ -21,8 +16,8 @@ const input = function (network, chan, cmd, args) {
21
16
  let targetName = getTarget(cmd, args, chan);
22
17
  if (cmd === "query") {
23
18
  if (!targetName) {
24
- chan.pushMessage(this, new msg_1.default({
25
- type: msg_2.MessageType.ERROR,
19
+ chan.pushMessage(this, new Msg({
20
+ type: MessageType.ERROR,
26
21
  text: "You cannot open a query window without an argument.",
27
22
  }));
28
23
  return;
@@ -32,23 +27,23 @@ const input = function (network, chan, cmd, args) {
32
27
  const char = targetName[0];
33
28
  if (network.irc.network.options.CHANTYPES &&
34
29
  network.irc.network.options.CHANTYPES.includes(char)) {
35
- chan.pushMessage(this, new msg_1.default({
36
- type: msg_2.MessageType.ERROR,
30
+ chan.pushMessage(this, new Msg({
31
+ type: MessageType.ERROR,
37
32
  text: "You can not open query windows for channels, use /join instead.",
38
33
  }));
39
34
  return;
40
35
  }
41
36
  for (let i = 0; i < network.irc.network.options.PREFIX.length; i++) {
42
37
  if (network.irc.network.options.PREFIX[i].symbol === char) {
43
- chan.pushMessage(this, new msg_1.default({
44
- type: msg_2.MessageType.ERROR,
38
+ chan.pushMessage(this, new Msg({
39
+ type: MessageType.ERROR,
45
40
  text: "You can not open query windows for names starting with a user prefix.",
46
41
  }));
47
42
  return;
48
43
  }
49
44
  }
50
45
  const newChan = this.createChannel({
51
- type: chan_1.ChanType.QUERY,
46
+ type: ChanType.QUERY,
52
47
  name: targetName,
53
48
  });
54
49
  this.emit("join", {
@@ -74,7 +69,7 @@ const input = function (network, chan, cmd, args) {
74
69
  // Determine if we should encrypt using FiSH for this target
75
70
  const targetChan = network.getChannel(targetName) || (chan.name === targetName ? chan : undefined);
76
71
  const key = targetChan?.blowfishKey;
77
- const toSend = key ? (0, fish_1.createFishMessage)(msg, key) : msg;
72
+ const toSend = key ? createFishMessage(msg, key) : msg;
78
73
  network.irc.say(targetName, toSend);
79
74
  // If the IRCd does not support echo-message, simulate the message
80
75
  // being sent back to us. Emit the same text we sent (encrypted or plain)
@@ -100,7 +95,7 @@ const input = function (network, chan, cmd, args) {
100
95
  }
101
96
  return true;
102
97
  };
103
- exports.default = {
98
+ export default {
104
99
  commands,
105
100
  input,
106
101
  };
@@ -1,11 +1,6 @@
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");
1
+ import Msg from "../../models/msg.js";
2
+ import { MessageType } from "../../../shared/types/msg.js";
3
+ import { ChanType } from "../../../shared/types/chan.js";
9
4
  const commands = ["mute", "unmute"];
10
5
  const allowDisconnected = true;
11
6
  function args_to_channels(network, args) {
@@ -19,7 +14,7 @@ function args_to_channels(network, args) {
19
14
  return targets;
20
15
  }
21
16
  function change_mute_state(client, target, valueToSet) {
22
- if (target.type === chan_1.ChanType.SPECIAL) {
17
+ if (target.type === ChanType.SPECIAL) {
23
18
  return;
24
19
  }
25
20
  target.setMuteStatus(valueToSet);
@@ -30,26 +25,25 @@ function change_mute_state(client, target, valueToSet) {
30
25
  }
31
26
  const input = function (network, chan, cmd, args) {
32
27
  const valueToSet = cmd === "mute" ? true : false;
33
- const client = this;
34
28
  if (args.length === 0) {
35
- change_mute_state(client, chan, valueToSet);
29
+ change_mute_state(this, chan, valueToSet);
36
30
  return;
37
31
  }
38
32
  const targets = args_to_channels(network, args);
39
33
  if (targets.length !== args.length) {
40
34
  const targetNames = targets.map((ch) => ch.name);
41
35
  const missing = args.filter((x) => !targetNames.includes(x));
42
- chan.pushMessage(client, new msg_1.default({
43
- type: msg_2.MessageType.ERROR,
36
+ chan.pushMessage(this, new Msg({
37
+ type: MessageType.ERROR,
44
38
  text: `No open ${missing.length === 1 ? "channel or user" : "channels or users"} found for ${missing.join(",")}`,
45
39
  }));
46
40
  return;
47
41
  }
48
42
  for (const target of targets) {
49
- change_mute_state(client, target, valueToSet);
43
+ change_mute_state(this, target, valueToSet);
50
44
  }
51
45
  };
52
- exports.default = {
46
+ export default {
53
47
  commands,
54
48
  input,
55
49
  allowDisconnected,
@@ -1,31 +1,26 @@
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");
1
+ import Msg from "../../models/msg.js";
2
+ import { MessageType } from "../../../shared/types/msg.js";
8
3
  const commands = ["nick"];
9
4
  const allowDisconnected = true;
10
5
  const input = function (network, chan, cmd, args) {
11
6
  if (args.length === 0) {
12
- chan.pushMessage(this, new msg_1.default({
13
- type: msg_2.MessageType.ERROR,
7
+ chan.pushMessage(this, new Msg({
8
+ type: MessageType.ERROR,
14
9
  text: "Usage: /nick <your new nick>",
15
10
  }));
16
11
  return;
17
12
  }
18
13
  if (args.length !== 1) {
19
- chan.pushMessage(this, new msg_1.default({
20
- type: msg_2.MessageType.ERROR,
14
+ chan.pushMessage(this, new Msg({
15
+ type: MessageType.ERROR,
21
16
  text: "Nicknames may not contain spaces.",
22
17
  }));
23
18
  return;
24
19
  }
25
20
  const newNick = args[0];
26
21
  if (newNick.length > 100) {
27
- chan.pushMessage(this, new msg_1.default({
28
- type: msg_2.MessageType.ERROR,
22
+ chan.pushMessage(this, new Msg({
23
+ type: MessageType.ERROR,
29
24
  text: "Nicknames may not be this long.",
30
25
  }));
31
26
  return;
@@ -48,7 +43,7 @@ const input = function (network, chan, cmd, args) {
48
43
  });
49
44
  this.save();
50
45
  };
51
- exports.default = {
46
+ export default {
52
47
  commands,
53
48
  input,
54
49
  allowDisconnected,
@@ -1,6 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const fish_1 = require("../../utils/fish");
1
+ import { createFishMessage } from "../../utils/fish.js";
4
2
  const commands = ["notice"];
5
3
  const input = function (network, chan, cmd, args) {
6
4
  if (!args[1]) {
@@ -11,7 +9,7 @@ const input = function (network, chan, cmd, args) {
11
9
  // Encrypt if a FiSH key is set for the target channel/query
12
10
  const targetChan = network.getChannel(targetName) || (chan.name === targetName ? chan : undefined);
13
11
  const key = targetChan?.blowfishKey;
14
- const toSend = key ? (0, fish_1.createFishMessage)(message, key) : message;
12
+ const toSend = key ? createFishMessage(message, key) : message;
15
13
  network.irc.notice(targetName, toSend);
16
14
  // If the IRCd does not support echo-message, simulate the message
17
15
  // being sent back to us.
@@ -22,9 +20,9 @@ const input = function (network, chan, cmd, args) {
22
20
  targetName = parsedTarget.target;
23
21
  targetGroup = parsedTarget.target_group;
24
22
  }
25
- const targetChan2 = network.getChannel(targetName);
23
+ const echoTargetChan = network.getChannel(targetName);
26
24
  let displayMessage = toSend;
27
- if (typeof targetChan2 === "undefined") {
25
+ if (typeof echoTargetChan === "undefined") {
28
26
  displayMessage = "{to " + args[0] + "} " + message;
29
27
  }
30
28
  network.irc.emit("notice", {
@@ -36,7 +34,7 @@ const input = function (network, chan, cmd, args) {
36
34
  }
37
35
  return true;
38
36
  };
39
- exports.default = {
37
+ export default {
40
38
  commands,
41
39
  input,
42
40
  };
@@ -1,12 +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 config_1 = __importDefault(require("../../config"));
8
- const msg_2 = require("../../../shared/types/msg");
9
- const chan_1 = require("../../../shared/types/chan");
1
+ import Msg from "../../models/msg.js";
2
+ import Config from "../../config.js";
3
+ import { MessageType } from "../../../shared/types/msg.js";
4
+ import { ChanType, ChanState } from "../../../shared/types/chan.js";
10
5
  const commands = ["close", "leave", "part"];
11
6
  const allowDisconnected = true;
12
7
  const input = function (network, chan, cmd, args) {
@@ -19,27 +14,27 @@ const input = function (network, chan, cmd, args) {
19
14
  args.shift();
20
15
  }
21
16
  }
22
- if (target.type === chan_1.ChanType.LOBBY) {
23
- chan.pushMessage(this, new msg_1.default({
24
- type: msg_2.MessageType.ERROR,
17
+ if (target.type === ChanType.LOBBY) {
18
+ chan.pushMessage(this, new Msg({
19
+ type: MessageType.ERROR,
25
20
  text: "You can not part from networks, use /quit instead.",
26
21
  }));
27
22
  return;
28
23
  }
29
24
  // If target is not a channel or we are not connected, instantly remove the channel
30
25
  // Otherwise send part to the server and wait for response
31
- if (target.type !== chan_1.ChanType.CHANNEL ||
32
- target.state === chan_1.ChanState.PARTED ||
26
+ if (target.type !== ChanType.CHANNEL ||
27
+ target.state === ChanState.PARTED ||
33
28
  !network.irc.connected) {
34
29
  this.part(network, target);
35
30
  }
36
31
  else {
37
- const partMessage = args.join(" ") || network.leaveMessage || config_1.default.values.leaveMessage;
32
+ const partMessage = args.join(" ") || network.leaveMessage || Config.values.leaveMessage;
38
33
  network.irc.part(target.name, partMessage);
39
34
  }
40
35
  return true;
41
36
  };
42
- exports.default = {
37
+ export default {
43
38
  commands,
44
39
  input,
45
40
  allowDisconnected,
@@ -1,26 +1,20 @@
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 clientCertificate_1 = __importDefault(require("../clientCertificate"));
1
+ import _ from "lodash";
2
+ import ClientCertificate from "../clientCertificate.js";
8
3
  const commands = ["quit"];
9
4
  const allowDisconnected = true;
10
5
  const input = function (network, chan, cmd, args) {
11
- const client = this;
12
- client.networks = lodash_1.default.without(client.networks, network);
6
+ this.networks = _.without(this.networks, network);
13
7
  network.destroy();
14
- client.save();
15
- client.emit("quit", {
8
+ this.save();
9
+ this.emit("quit", {
16
10
  network: network.uuid,
17
11
  });
18
12
  const quitMessage = args[0] ? args.join(" ") : undefined;
19
13
  network.quit(quitMessage);
20
- clientCertificate_1.default.remove(network.uuid);
14
+ ClientCertificate.remove(network.uuid);
21
15
  return true;
22
16
  };
23
- exports.default = {
17
+ export default {
24
18
  commands,
25
19
  input,
26
20
  allowDisconnected,
@@ -0,0 +1,55 @@
1
+ import Msg from "../../models/msg.js";
2
+ import { MessageType } from "../../../shared/types/msg.js";
3
+ import { ChanType } from "../../../shared/types/chan.js";
4
+ const commands = ["rainbow", "rgb"];
5
+ function rainbow(text) {
6
+ const skipChars = [" ", "\x03", "\x02", "\x1F", "\x1D", "\x0F", "\x1e", "\x11"];
7
+ const colorCodes = [4, 7, 8, 9, 3, 10, 11, 12, 2, 6, 13];
8
+ const colors = colorCodes.length;
9
+ return text
10
+ .split("")
11
+ .map((char, index) => {
12
+ if (skipChars.includes(char))
13
+ return char;
14
+ const isNumber = Number.isInteger(Number(char));
15
+ const currentColor = String(colorCodes[((index % colors) + colors) % colors]).padStart(isNumber ? 2 : 1, "0");
16
+ return `${currentColor}${char}`;
17
+ })
18
+ .join("");
19
+ }
20
+ const input = function ({ irc }, chan, cmd, args) {
21
+ if (chan.type !== ChanType.CHANNEL && chan.type !== ChanType.QUERY) {
22
+ chan.pushMessage(this, new Msg({
23
+ type: MessageType.ERROR,
24
+ text: `${cmd} command can only be used in channels and queries.`,
25
+ }));
26
+ return;
27
+ }
28
+ let text;
29
+ switch (cmd) {
30
+ case "rgb":
31
+ case "rainbow":
32
+ if (args.length === 0) {
33
+ break;
34
+ }
35
+ text = rainbow(text || args.join(" "));
36
+ irc.say(chan.name, text);
37
+ // If the IRCd does not support echo-message, simulate the message
38
+ // being sent back to us.
39
+ if (!irc.network.cap.isEnabled("echo-message")) {
40
+ irc.emit("privmsg", {
41
+ nick: irc.user.nick,
42
+ ident: irc.user.username,
43
+ hostname: irc.user.host,
44
+ target: chan.name,
45
+ message: text,
46
+ });
47
+ }
48
+ break;
49
+ }
50
+ return true;
51
+ };
52
+ export default {
53
+ commands,
54
+ input,
55
+ };
@@ -1,5 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  const commands = ["raw", "send", "quote"];
4
2
  const input = function ({ irc }, chan, cmd, args) {
5
3
  if (args.length !== 0) {
@@ -7,7 +5,7 @@ const input = function ({ irc }, chan, cmd, args) {
7
5
  }
8
6
  return true;
9
7
  };
10
- exports.default = {
8
+ export default {
11
9
  commands,
12
10
  input,
13
11
  };
@@ -1,16 +1,11 @@
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");
1
+ import Msg from "../../models/msg.js";
2
+ import { MessageType } from "../../../shared/types/msg.js";
3
+ import { ChanType } from "../../../shared/types/chan.js";
9
4
  const commands = ["cycle", "rejoin"];
10
5
  const input = function ({ irc }, chan) {
11
- if (chan.type !== chan_1.ChanType.CHANNEL) {
12
- chan.pushMessage(this, new msg_1.default({
13
- type: msg_2.MessageType.ERROR,
6
+ if (chan.type !== ChanType.CHANNEL) {
7
+ chan.pushMessage(this, new Msg({
8
+ type: MessageType.ERROR,
14
9
  text: "You can only rejoin channels.",
15
10
  }));
16
11
  return;
@@ -19,7 +14,7 @@ const input = function ({ irc }, chan) {
19
14
  irc.join(chan.name);
20
15
  return true;
21
16
  };
22
- exports.default = {
17
+ export default {
23
18
  commands,
24
19
  input,
25
20
  };
@@ -1,16 +1,11 @@
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");
1
+ import Msg from "../../models/msg.js";
2
+ import { MessageType } from "../../../shared/types/msg.js";
3
+ import { ChanType } from "../../../shared/types/chan.js";
9
4
  const commands = ["topic"];
10
5
  const input = function ({ irc }, chan, cmd, args) {
11
- if (chan.type !== chan_1.ChanType.CHANNEL) {
12
- chan.pushMessage(this, new msg_1.default({
13
- type: msg_2.MessageType.ERROR,
6
+ if (chan.type !== ChanType.CHANNEL) {
7
+ chan.pushMessage(this, new Msg({
8
+ type: MessageType.ERROR,
14
9
  text: `${cmd} command can only be used in channels.`,
15
10
  }));
16
11
  return;
@@ -18,7 +13,7 @@ const input = function ({ irc }, chan, cmd, args) {
18
13
  irc.setTopic(chan.name, args.join(" "));
19
14
  return true;
20
15
  };
21
- exports.default = {
16
+ export default {
22
17
  commands,
23
18
  input,
24
19
  };
@@ -1,5 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  const commands = ["whois"];
4
2
  const input = function ({ irc }, chan, cmd, args) {
5
3
  if (args.length === 1) {
@@ -13,7 +11,7 @@ const input = function ({ irc }, chan, cmd, args) {
13
11
  irc.raw(`${cmd} ${args.join(" ")}`);
14
12
  }
15
13
  };
16
- exports.default = {
14
+ export default {
17
15
  commands,
18
16
  input,
19
17
  };