mirror of
https://github.com/thelounge/thelounge
synced 2024-11-14 00:07:17 +00:00
Count number of mode changes, not MODE messages
Update the code in MessageCondensed that generates the condensed messages ("X users have joined, Y modes were set") to count the number of actual mode changes instead of the raw count of MODE messages. One mode message can contain multiple mode changes. Signed-off-by: Taavi Väänänen <hi@taavi.wtf>
This commit is contained in:
parent
acf520bd9a
commit
be498e8f93
1 changed files with 13 additions and 1 deletions
|
@ -46,7 +46,19 @@ export default {
|
|||
});
|
||||
|
||||
for (const message of this.messages) {
|
||||
obj[message.type]++;
|
||||
// special case since one MODE message can change multiple modes
|
||||
if (message.type === "mode") {
|
||||
// syntax: +vv-t maybe-some targets
|
||||
// we want the number of mode changes in the message, so count the
|
||||
// number of chars other than + and - before the first space
|
||||
const modeChangesCount = message.text
|
||||
.split(" ")[0]
|
||||
.split("")
|
||||
.filter((char) => char !== "+" && char !== "-").length;
|
||||
obj[message.type] += modeChangesCount;
|
||||
} else {
|
||||
obj[message.type]++;
|
||||
}
|
||||
}
|
||||
|
||||
// Count quits as parts in condensed messages to reduce information density
|
||||
|
|
Loading…
Reference in a new issue