@lordbex/thelounge 4.4.3-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 (141) hide show
  1. package/README.md +31 -7
  2. package/dist/defaults/config.js +31 -2
  3. package/dist/package.json +94 -91
  4. package/dist/server/client.js +188 -194
  5. package/dist/server/clientManager.js +75 -72
  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 +102 -104
  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 +122 -109
  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 +349 -389
  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 +94 -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/js/loading-error-handlers.js +1 -1
  138. package/public/service-worker.js +1 -1
  139. package/public/themes/default.css +1 -1
  140. package/public/themes/morning.css +1 -1
  141. package/dist/webpack.config.js +0 -224
@@ -1,33 +1,27 @@
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 link_1 = __importDefault(require("./link"));
8
- const irc_1 = require("../../../shared/irc");
9
- const helper_1 = __importDefault(require("../../helper"));
10
- const msg_2 = require("../../../shared/types/msg");
11
- const chan_1 = require("../../../shared/types/chan");
12
- const fish_1 = require("../../utils/fish");
1
+ import Msg from "../../models/msg.js";
2
+ import LinkPrefetch from "./link.js";
3
+ import { cleanIrcMessage } from "../../../shared/irc.js";
4
+ import Helper from "../../helper.js";
5
+ import { MessageType } from "../../../shared/types/msg.js";
6
+ import { ChanType } from "../../../shared/types/chan.js";
7
+ import { tryDecryptFishLine } from "../../utils/fish";
13
8
  const nickRegExp = /(?:\x03[0-9]{1,2}(?:,[0-9]{1,2})?)?([\w[\]\\`^{|}-]+)/g;
14
9
  function convertForHandle(type, data) {
15
10
  return { ...data, type: type };
16
11
  }
17
- exports.default = (function (irc, network) {
18
- const client = this;
19
- irc.on("notice", function (data) {
20
- handleMessage(convertForHandle(msg_2.MessageType.NOTICE, data));
12
+ export default (function (irc, network) {
13
+ irc.on("notice", (data) => {
14
+ handleMessage.call(this, convertForHandle(MessageType.NOTICE, data));
21
15
  });
22
- irc.on("action", function (data) {
23
- handleMessage(convertForHandle(msg_2.MessageType.ACTION, data));
16
+ irc.on("action", (data) => {
17
+ handleMessage.call(this, convertForHandle(MessageType.ACTION, data));
24
18
  });
25
- irc.on("privmsg", function (data) {
26
- handleMessage(convertForHandle(msg_2.MessageType.MESSAGE, data));
19
+ irc.on("privmsg", (data) => {
20
+ handleMessage.call(this, convertForHandle(MessageType.MESSAGE, data));
27
21
  });
28
- irc.on("wallops", function (data) {
22
+ irc.on("wallops", (data) => {
29
23
  data.from_server = true;
30
- handleMessage(convertForHandle(msg_2.MessageType.WALLOPS, data));
24
+ handleMessage.call(this, convertForHandle(MessageType.WALLOPS, data));
31
25
  });
32
26
  function handleMessage(data) {
33
27
  let chan;
@@ -43,13 +37,13 @@ exports.default = (function (irc, network) {
43
37
  // Check if the sender is in our ignore list
44
38
  const shouldIgnore = !self &&
45
39
  network.ignoreList.some(function (entry) {
46
- return helper_1.default.compareHostmask(entry, data);
40
+ return Helper.compareHostmask(entry, data);
47
41
  });
48
42
  // Server messages that aren't targeted at a channel go to the server window
49
43
  if (data.from_server &&
50
44
  (!data.target ||
51
45
  !network.getChannel(data.target) ||
52
- network.getChannel(data.target)?.type !== chan_1.ChanType.CHANNEL)) {
46
+ network.getChannel(data.target)?.type !== ChanType.CHANNEL)) {
53
47
  chan = network.getLobby();
54
48
  from = chan.getUser(data.nick);
55
49
  }
@@ -65,43 +59,43 @@ exports.default = (function (irc, network) {
65
59
  chan = network.getChannel(target);
66
60
  if (typeof chan === "undefined") {
67
61
  // Send notices that are not targeted at us into the server window
68
- if (data.type === msg_2.MessageType.NOTICE) {
62
+ if (data.type === MessageType.NOTICE) {
69
63
  showInActive = true;
70
64
  chan = network.getLobby();
71
65
  }
72
66
  else {
73
- chan = client.createChannel({
74
- type: chan_1.ChanType.QUERY,
67
+ chan = this.createChannel({
68
+ type: ChanType.QUERY,
75
69
  name: target,
76
70
  });
77
- client.emit("join", {
71
+ this.emit("join", {
78
72
  network: network.uuid,
79
73
  chan: chan.getFilteredClone(true),
80
74
  shouldOpen: false,
81
75
  index: network.addChannel(chan),
82
76
  });
83
- client.save();
84
- chan.loadMessages(client, network);
77
+ this.save();
78
+ chan.loadMessages(this, network);
85
79
  }
86
80
  }
87
81
  from = chan.getUser(data.nick);
88
82
  // Attempt mIRC FiSH Blowfish decryption if applicable
89
83
  if (chan.blowfishKey) {
90
- const decrypted = (0, fish_1.tryDecryptFishLine)(data.message, chan.blowfishKey);
84
+ const decrypted = tryDecryptFishLine(data.message, chan.blowfishKey);
91
85
  if (decrypted !== null) {
92
86
  data.message = decrypted;
93
87
  }
94
88
  }
95
89
  // Query messages (unless self or muted) always highlight
96
- if (chan.type === chan_1.ChanType.QUERY) {
90
+ if (chan.type === ChanType.QUERY) {
97
91
  highlight = !self;
98
92
  }
99
- else if (chan.type === chan_1.ChanType.CHANNEL) {
93
+ else if (chan.type === ChanType.CHANNEL) {
100
94
  from.lastMessage = data.time || Date.now();
101
95
  }
102
96
  }
103
97
  // msg is constructed down here because `from` is being copied in the constructor
104
- const msg = new msg_1.default({
98
+ const msg = new Msg({
105
99
  type: data.type,
106
100
  time: data.time ? new Date(data.time) : undefined,
107
101
  text: data.message,
@@ -114,19 +108,19 @@ exports.default = (function (irc, network) {
114
108
  msg.showInActive = true;
115
109
  }
116
110
  // remove IRC formatting for custom highlight testing
117
- const cleanMessage = (0, irc_1.cleanIrcMessage)(data.message);
111
+ const cleanMessage = cleanIrcMessage(data.message);
118
112
  // Self messages in channels are never highlighted
119
113
  // Non-self messages are highlighted as soon as the nick is detected
120
114
  if (!msg.highlight && !msg.self) {
121
115
  msg.highlight = network.highlightRegex?.test(data.message);
122
116
  // If we still don't have a highlight, test against custom highlights if there's any
123
- if (!msg.highlight && client.highlightRegex) {
124
- msg.highlight = client.highlightRegex.test(cleanMessage);
117
+ if (!msg.highlight && this.highlightRegex) {
118
+ msg.highlight = this.highlightRegex.test(cleanMessage);
125
119
  }
126
120
  }
127
121
  // if highlight exceptions match, do not highlight at all
128
- if (msg.highlight && client.highlightExceptionRegex) {
129
- msg.highlight = !client.highlightExceptionRegex.test(cleanMessage);
122
+ if (msg.highlight && this.highlightExceptionRegex) {
123
+ msg.highlight = !this.highlightExceptionRegex.test(cleanMessage);
130
124
  }
131
125
  if (data.group) {
132
126
  msg.statusmsgGroup = data.group;
@@ -138,30 +132,30 @@ exports.default = (function (irc, network) {
138
132
  }
139
133
  }
140
134
  // No prefetch URLs unless are simple MESSAGE or ACTION types
141
- if ([msg_2.MessageType.MESSAGE, msg_2.MessageType.ACTION].includes(data.type)) {
142
- (0, link_1.default)(client, chan, msg, cleanMessage);
135
+ if ([MessageType.MESSAGE, MessageType.ACTION].includes(data.type)) {
136
+ LinkPrefetch(this, chan, msg, cleanMessage);
143
137
  }
144
- chan.pushMessage(client, msg, !msg.self);
138
+ chan.pushMessage(this, msg, !msg.self);
145
139
  // Do not send notifications if the channel is muted or for messages older than 15 minutes (znc buffer for example)
146
140
  if (!chan.muted && msg.highlight && (!data.time || data.time > Date.now() - 900000)) {
147
141
  let title = chan.name;
148
142
  let body = cleanMessage;
149
- if (msg.type === msg_2.MessageType.ACTION) {
143
+ if (msg.type === MessageType.ACTION) {
150
144
  // For actions, do not include colon in the message
151
145
  body = `${data.nick} ${body}`;
152
146
  }
153
- else if (chan.type !== chan_1.ChanType.QUERY) {
147
+ else if (chan.type !== ChanType.QUERY) {
154
148
  // In channels, prepend sender nickname to the message
155
149
  body = `${data.nick}: ${body}`;
156
150
  }
157
- // If a channel is active on any client, highlight won't increment and notification will say (0 mention)
151
+ // If a channel is active on any this, highlight won't increment and notification will say (0 mention)
158
152
  if (chan.highlight > 0) {
159
- title += ` (${chan.highlight} ${chan.type === chan_1.ChanType.QUERY ? "new message" : "mention"}${chan.highlight > 1 ? "s" : ""})`;
153
+ title += ` (${chan.highlight} ${chan.type === ChanType.QUERY ? "new message" : "mention"}${chan.highlight > 1 ? "s" : ""})`;
160
154
  }
161
155
  if (chan.highlight > 1) {
162
156
  body += `\n\n… and ${chan.highlight - 1} other message${chan.highlight > 2 ? "s" : ""}`;
163
157
  }
164
- client.manager.webPush.push(client, {
158
+ this.manager.webPush.push(this, {
165
159
  type: "notification",
166
160
  chanId: chan.id,
167
161
  timestamp: data.time || Date.now(),
@@ -169,9 +163,9 @@ exports.default = (function (irc, network) {
169
163
  body: body,
170
164
  }, true);
171
165
  }
172
- // Keep track of all mentions in channels for this client
173
- if (msg.highlight && chan.type === chan_1.ChanType.CHANNEL) {
174
- client.mentions.push({
166
+ // Keep track of all mentions in channels for this this
167
+ if (msg.highlight && chan.type === ChanType.CHANNEL) {
168
+ this.mentions.push({
175
169
  chanId: chan.id,
176
170
  msgId: msg.id,
177
171
  type: msg.type,
@@ -179,8 +173,8 @@ exports.default = (function (irc, network) {
179
173
  text: msg.text,
180
174
  from: msg.from,
181
175
  });
182
- if (client.mentions.length > 100) {
183
- client.mentions.splice(0, client.mentions.length - 100);
176
+ if (this.mentions.length > 100) {
177
+ this.mentions.splice(0, this.mentions.length - 100);
184
178
  }
185
179
  }
186
180
  }
@@ -1,18 +1,12 @@
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 msg_1 = __importDefault(require("../../models/msg"));
8
- const msg_2 = require("../../../shared/types/msg");
9
- exports.default = (function (irc, network) {
10
- const client = this;
1
+ import _ from "lodash";
2
+ import Msg from "../../models/msg.js";
3
+ import { MessageType } from "../../../shared/types/msg.js";
4
+ export default (function (irc, network) {
11
5
  // The following saves the channel key based on channel mode instead of
12
6
  // extracting it from `/join #channel key`. This lets us not have to
13
7
  // temporarily store the key until successful join, but also saves the key
14
8
  // if a key is set or changed while being on the channel.
15
- irc.on("channel info", function (data) {
9
+ irc.on("channel info", (data) => {
16
10
  if (!data.modes) {
17
11
  return;
18
12
  }
@@ -26,26 +20,26 @@ exports.default = (function (irc, network) {
26
20
  const char = text[1];
27
21
  if (char === "k") {
28
22
  targetChan.key = add ? mode.param : "";
29
- client.save();
23
+ this.save();
30
24
  }
31
25
  });
32
- const msg = new msg_1.default({
33
- type: msg_2.MessageType.MODE_CHANNEL,
26
+ const msg = new Msg({
27
+ type: MessageType.MODE_CHANNEL,
34
28
  text: `${data.raw_modes} ${data.raw_params.join(" ")}`,
35
29
  });
36
- targetChan.pushMessage(client, msg);
30
+ targetChan.pushMessage(this, msg);
37
31
  });
38
- irc.on("user info", function (data) {
32
+ irc.on("user info", (data) => {
39
33
  const serverChan = network.getLobby();
40
- const msg = new msg_1.default({
41
- type: msg_2.MessageType.MODE_USER,
34
+ const msg = new Msg({
35
+ type: MessageType.MODE_USER,
42
36
  raw_modes: data.raw_modes,
43
37
  self: false,
44
38
  showInActive: true,
45
39
  });
46
- serverChan.pushMessage(client, msg);
40
+ serverChan.pushMessage(this, msg);
47
41
  });
48
- irc.on("mode", function (data) {
42
+ irc.on("mode", (data) => {
49
43
  let targetChan;
50
44
  if (data.target === irc.user.nick) {
51
45
  targetChan = network.getLobby();
@@ -56,9 +50,9 @@ exports.default = (function (irc, network) {
56
50
  return;
57
51
  }
58
52
  }
59
- const msg = new msg_1.default({
53
+ const msg = new Msg({
60
54
  time: data.time,
61
- type: msg_2.MessageType.MODE,
55
+ type: MessageType.MODE,
62
56
  from: targetChan.getUser(data.nick),
63
57
  text: `${data.raw_modes} ${data.raw_params.join(" ")}`,
64
58
  self: data.nick === irc.user.nick,
@@ -72,53 +66,62 @@ exports.default = (function (irc, network) {
72
66
  if (users.length > 0) {
73
67
  msg.users = users;
74
68
  }
75
- targetChan.pushMessage(client, msg);
76
- let usersUpdated = false;
77
- const userModeSortPriority = {};
78
- const supportsMultiPrefix = network.irc.network.cap.isEnabled("multi-prefix");
79
- irc.network.options.PREFIX.forEach((prefix, index) => {
80
- userModeSortPriority[prefix.symbol] = index;
81
- });
82
- data.modes.forEach((mode) => {
83
- const add = mode.mode[0] === "+";
84
- const char = mode.mode[1];
85
- if (char === "k") {
86
- targetChan.key = add ? mode.param : "";
87
- client.save();
88
- }
89
- if (!mode.param) {
90
- return;
91
- }
92
- const user = targetChan.findUser(mode.param);
93
- if (!user) {
69
+ // Mode update logic - needs to run regardless of buffering
70
+ const updateModes = () => {
71
+ let usersUpdated = false;
72
+ const userModeSortPriority = {};
73
+ const supportsMultiPrefix = network.irc.network.cap.isEnabled("multi-prefix");
74
+ irc.network.options.PREFIX.forEach((prefix, index) => {
75
+ userModeSortPriority[prefix.symbol] = index;
76
+ });
77
+ data.modes.forEach((mode) => {
78
+ const add = mode.mode[0] === "+";
79
+ const char = mode.mode[1];
80
+ if (char === "k") {
81
+ targetChan.key = add ? mode.param : "";
82
+ this.save();
83
+ }
84
+ if (!mode.param) {
85
+ return;
86
+ }
87
+ const user = targetChan.findUser(mode.param);
88
+ if (!user) {
89
+ return;
90
+ }
91
+ usersUpdated = true;
92
+ if (!supportsMultiPrefix) {
93
+ return;
94
+ }
95
+ const changedMode = network.serverOptions.PREFIX.modeToSymbol[char];
96
+ if (!add) {
97
+ _.pull(user.modes, changedMode);
98
+ }
99
+ else if (!user.modes.includes(changedMode)) {
100
+ user.modes.push(changedMode);
101
+ user.modes.sort(function (a, b) {
102
+ return userModeSortPriority[a] - userModeSortPriority[b];
103
+ });
104
+ }
105
+ });
106
+ if (!usersUpdated) {
94
107
  return;
95
108
  }
96
- usersUpdated = true;
97
109
  if (!supportsMultiPrefix) {
98
- return;
99
- }
100
- const changedMode = network.serverOptions.PREFIX.modeToSymbol[char];
101
- if (!add) {
102
- lodash_1.default.pull(user.modes, changedMode);
110
+ // TODO: This is horrible
111
+ irc.raw("NAMES", data.target);
103
112
  }
104
- else if (!user.modes.includes(changedMode)) {
105
- user.modes.push(changedMode);
106
- user.modes.sort(function (a, b) {
107
- return userModeSortPriority[a] - userModeSortPriority[b];
113
+ else {
114
+ this.emit("users", {
115
+ chan: targetChan.id,
108
116
  });
109
117
  }
110
- });
111
- if (!usersUpdated) {
112
- return;
113
- }
114
- if (!supportsMultiPrefix) {
115
- // TODO: This is horrible
116
- irc.raw("NAMES", data.target);
117
- }
118
- else {
119
- client.emit("users", {
120
- chan: targetChan.id,
121
- });
118
+ };
119
+ // Try to process through mass event aggregator
120
+ const wasBuffered = this.massEventAggregator.processMessage(network, targetChan, msg, updateModes);
121
+ if (!wasBuffered) {
122
+ // Not in mass event mode - process normally
123
+ targetChan.pushMessage(this, msg);
124
+ updateModes();
122
125
  }
123
126
  });
124
127
  });
@@ -1,34 +1,12 @@
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("banlist", (list) => {
12
- const data = list.bans.map((ban) => ({
13
- hostmask: ban.banned,
14
- banned_by: ban.banned_by,
15
- banned_at: ban.banned_at * 1000,
16
- }));
17
- handleList(chan_1.SpecialChanType.BANLIST, "Ban list", list.channel, data);
18
- });
19
- irc.on("inviteList", (list) => {
20
- const data = list.invites.map((invite) => ({
21
- hostmask: invite.invited,
22
- invited_by: invite.invited_by,
23
- invited_at: invite.invited_at * 1000,
24
- }));
25
- handleList(chan_1.SpecialChanType.INVITELIST, "Invite list", list.channel, data);
26
- });
27
- function handleList(type, name, channel, data) {
1
+ import Msg from "../../models/msg.js";
2
+ import { MessageType } from "../../../shared/types/msg.js";
3
+ import { SpecialChanType, ChanType } from "../../../shared/types/chan.js";
4
+ export default (function (irc, network) {
5
+ const handleList = (type, name, channel, data) => {
28
6
  if (data.length === 0) {
29
- const msg = new msg_1.default({
7
+ const msg = new Msg({
30
8
  time: new Date(),
31
- type: msg_2.MessageType.ERROR,
9
+ type: MessageType.ERROR,
32
10
  text: `${name} is empty`,
33
11
  });
34
12
  let chan = network.getChannel(channel);
@@ -37,19 +15,19 @@ exports.default = (function (irc, network) {
37
15
  msg.showInActive = true;
38
16
  chan = network.getLobby();
39
17
  }
40
- chan.pushMessage(client, msg, true);
18
+ chan.pushMessage(this, msg, true);
41
19
  return;
42
20
  }
43
21
  const chanName = `${name} for ${channel}`;
44
22
  let chan = network.getChannel(chanName);
45
23
  if (typeof chan === "undefined") {
46
- chan = client.createChannel({
47
- type: chan_1.ChanType.SPECIAL,
24
+ chan = this.createChannel({
25
+ type: ChanType.SPECIAL,
48
26
  special: type,
49
27
  name: chanName,
50
28
  data: data,
51
29
  });
52
- client.emit("join", {
30
+ this.emit("join", {
53
31
  network: network.uuid,
54
32
  chan: chan.getFilteredClone(true),
55
33
  shouldOpen: false,
@@ -58,10 +36,26 @@ exports.default = (function (irc, network) {
58
36
  }
59
37
  else {
60
38
  chan.data = data;
61
- client.emit("msg:special", {
39
+ this.emit("msg:special", {
62
40
  chan: chan.id,
63
41
  data: data,
64
42
  });
65
43
  }
66
- }
44
+ };
45
+ irc.on("banlist", (list) => {
46
+ const data = list.bans.map((ban) => ({
47
+ hostmask: ban.banned,
48
+ banned_by: ban.banned_by,
49
+ banned_at: ban.banned_at * 1000,
50
+ }));
51
+ handleList(SpecialChanType.BANLIST, "Ban list", list.channel, data);
52
+ });
53
+ irc.on("inviteList", (list) => {
54
+ const data = list.invites.map((invite) => ({
55
+ hostmask: invite.invited,
56
+ invited_by: invite.invited_by,
57
+ invited_at: invite.invited_at * 1000,
58
+ }));
59
+ handleList(SpecialChanType.INVITELIST, "Invite list", list.channel, data);
60
+ });
67
61
  });
@@ -1,29 +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
- exports.default = (function (irc, network) {
9
- const client = this;
10
- irc.on("motd", 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("motd", (data) => {
11
5
  const lobby = network.getLobby();
12
6
  if (data.motd) {
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: "motd",
16
10
  text: data.motd,
17
11
  });
18
- lobby.pushMessage(client, msg);
12
+ lobby.pushMessage(this, msg);
19
13
  }
20
14
  if (data.error) {
21
- const msg = new msg_1.default({
22
- type: msg_2.MessageType.MONOSPACE_BLOCK,
15
+ const msg = new Msg({
16
+ type: MessageType.MONOSPACE_BLOCK,
23
17
  command: "motd",
24
18
  text: data.error,
25
19
  });
26
- lobby.pushMessage(client, msg);
20
+ lobby.pushMessage(this, msg);
27
21
  }
28
22
  });
29
23
  });
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = (function (irc, network) {
4
- const client = this;
5
- irc.on("userlist", function (data) {
1
+ export default (function (irc, network) {
2
+ irc.on("userlist", (data) => {
6
3
  const chan = network.getChannel(data.channel);
7
4
  if (typeof chan === "undefined") {
8
5
  return;
@@ -14,7 +11,7 @@ exports.default = (function (irc, network) {
14
11
  newUsers.set(user.nick.toLowerCase(), newUser);
15
12
  });
16
13
  chan.users = newUsers;
17
- client.emit("users", {
14
+ this.emit("users", {
18
15
  chan: chan.id,
19
16
  });
20
17
  });
@@ -1,23 +1,17 @@
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("nick", 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("nick", (data) => {
11
5
  const self = data.nick === irc.user.nick;
12
6
  if (self) {
13
7
  network.setNick(data.new_nick);
14
8
  const lobby = network.getLobby();
15
- const msg = new msg_1.default({
9
+ const msg = new Msg({
16
10
  text: `You're now known as ${data.new_nick}`,
17
11
  });
18
- lobby.pushMessage(client, msg, true);
19
- client.save();
20
- client.emit("nick", {
12
+ lobby.pushMessage(this, msg, true);
13
+ this.save();
14
+ this.emit("nick", {
21
15
  network: network.uuid,
22
16
  nick: data.new_nick,
23
17
  });
@@ -27,19 +21,28 @@ exports.default = (function (irc, network) {
27
21
  if (typeof user === "undefined") {
28
22
  return;
29
23
  }
30
- const msg = new msg_1.default({
24
+ const msg = new Msg({
31
25
  time: data.time,
32
26
  from: user,
33
- type: msg_2.MessageType.NICK,
27
+ type: MessageType.NICK,
34
28
  new_nick: data.new_nick,
35
29
  });
36
- chan.pushMessage(client, msg);
37
- chan.removeUser(user);
38
- user.nick = data.new_nick;
39
- chan.setUser(user);
40
- client.emit("users", {
41
- chan: chan.id,
42
- });
30
+ // User list update callback - executed regardless of buffering
31
+ const updateUserList = () => {
32
+ chan.removeUser(user);
33
+ user.nick = data.new_nick;
34
+ chan.setUser(user);
35
+ this.emit("users", {
36
+ chan: chan.id,
37
+ });
38
+ };
39
+ // Try to process through mass event aggregator
40
+ const wasBuffered = this.massEventAggregator.processMessage(network, chan, msg, updateUserList);
41
+ if (!wasBuffered) {
42
+ // Not in mass event mode - process normally
43
+ chan.pushMessage(this, msg);
44
+ updateUserList();
45
+ }
43
46
  });
44
47
  });
45
48
  });