Use ircClient.nick instead of nickname when guarding against events for current nick #257
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As the irc library can change the nick of the bot when connecting (e.g. because the nick is currently taken, by some other user),
this.nickname
may not correspond to the current nickname and so when receiving a join event upon joining a channel (prior to the names event), the current guard against this can pass despite it being an event for the bot.This modifies it to check against ircClient.nick where relevant, and also modifies the test stubs to allow adding the nickname to the config and exposing this functionality in tests.
To see the failure before this patch, enable
ircStatusNotices
and run two copies of the bot; the second should crash upon joining a channel, as it will have a modified nickname (e.g. 'testbot1').The use of
...args
in the constructor is because it seems writingconstructor(_, nickname, _)
clashes due to same-named parameters, andconstructor(_server, nickname, _ircOptions)
seems to complain about unused variables (though the_
s are intended to show that this has been acknowledged).