New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix channel join regression and fix possibly joining parted channels #411
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,35 @@ module.exports = function(irc, network) { | |
text: "Network created, connecting to " + network.host + ":" + network.port + "..." | ||
})); | ||
|
||
irc.on("registered", function() { | ||
if (network.irc.network.cap.enabled.length > 0) { | ||
network.channels[0].pushMessage(client, new Msg({ | ||
text: "Enabled capabilities: " + network.irc.network.cap.enabled.join(", ") | ||
})); | ||
} | ||
|
||
var delay = 1000; | ||
var commands = network.commands; | ||
if (Array.isArray(commands)) { | ||
commands.forEach(function(cmd) { | ||
setTimeout(function() { | ||
client.input({ | ||
target: network.channels[0].id, | ||
text: cmd | ||
}); | ||
}, delay); | ||
delay += 1000; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be simplified a bit; const delay = 1000;
commands.forEach((text, idx) => {
setTimeout(() => client.input({
target: network.channels[0].id,
text,
}), delay * ++idx);
}); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Joins have to run after commands, so that won't work. I also didn't touch this code, only moved it to another file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be honest, I'm not sure the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed with @astorije, plus apart from changing the functions to arrow functions (thus breaking older versions), it doesn't actually change much. |
||
}); | ||
} | ||
|
||
network.channels.forEach(function(chan) { | ||
setTimeout(function() { | ||
network.irc.join(chan.name); | ||
}, delay); | ||
delay += 100; | ||
}); | ||
}); | ||
|
||
irc.on("socket connected", function() { | ||
network.channels[0].pushMessage(client, new Msg({ | ||
text: "Connected to the network." | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about:
or, if you don't want that long first line:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, got ruled out in priv by @xPaw, who plans to use the
channels
variable in a further PR and cannot blindly overwrite it.