Skip to content

Commit 12ae0fc

Browse files
committed
Rename special->exact and getDiscordChannelFor->findDiscordChannel
1 parent 68a6b9c commit 12ae0fc

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

lib/bot.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,18 @@ class Bot {
104104
this.ircClient.on('join', (channel, nick) => {
105105
if (!this.ircStatusNotices) return;
106106
if (nick === this.nickname && !this.announceSelfJoin) return;
107-
this.sendSpecialToDiscord(channel, `*${nick}* has joined the channel`);
107+
this.sendExactToDiscord(channel, `*${nick}* has joined the channel`);
108108
});
109109

110110
this.ircClient.on('part', (channel, nick, reason) => {
111111
if (!this.ircStatusNotices || nick === this.nickname) return;
112-
this.sendSpecialToDiscord(channel, `*${nick}* has left the channel (${reason})`);
112+
this.sendExactToDiscord(channel, `*${nick}* has left the channel (${reason})`);
113113
});
114114

115115
this.ircClient.on('quit', (nick, reason, channels) => {
116116
if (!this.ircStatusNotices || nick === this.nickname) return;
117117
channels.forEach((channel) => {
118-
this.sendSpecialToDiscord(channel, `*${nick}* has quit (${reason})`);
118+
this.sendExactToDiscord(channel, `*${nick}* has quit (${reason})`);
119119
});
120120
});
121121

@@ -220,7 +220,7 @@ class Bot {
220220
}
221221
}
222222

223-
getDiscordChannelFor(ircChannel) {
223+
findDiscordChannel(ircChannel) {
224224
const discordChannelName = this.invertedMapping[ircChannel.toLowerCase()];
225225
if (discordChannelName) {
226226
// #channel -> channel before retrieving and select only text channels:
@@ -239,7 +239,7 @@ class Bot {
239239
}
240240

241241
sendToDiscord(author, channel, text) {
242-
const discordChannel = this.getDiscordChannelFor(channel);
242+
const discordChannel = this.findDiscordChannel(channel);
243243
if (!discordChannel) return;
244244

245245
// Convert text formatting (bold, italics, underscore)
@@ -273,8 +273,8 @@ class Bot {
273273
}
274274

275275
/* Sends a message to Discord exactly as it appears */
276-
sendSpecialToDiscord(channel, text) {
277-
const discordChannel = this.getDiscordChannelFor(channel);
276+
sendExactToDiscord(channel, text) {
277+
const discordChannel = this.findDiscordChannel(channel);
278278
if (!discordChannel) return;
279279

280280
logger.debug('Sending special message to Discord', text, channel, '->', `#${discordChannel.name}`);

test/bot-events.test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('Bot Events', function () {
2424
const bot = new Bot(useConfig);
2525
bot.sendToIRC = sandbox.stub();
2626
bot.sendToDiscord = sandbox.stub();
27-
bot.sendSpecialToDiscord = sandbox.stub();
27+
bot.sendExactToDiscord = sandbox.stub();
2828
return bot;
2929
};
3030

@@ -130,7 +130,7 @@ describe('Bot Events', function () {
130130
const nick = 'user';
131131
const text = `*${nick}* has joined the channel`;
132132
bot.ircClient.emit('join', channel, nick);
133-
bot.sendSpecialToDiscord.should.have.been.calledWithExactly(channel, text);
133+
bot.sendExactToDiscord.should.have.been.calledWithExactly(channel, text);
134134
});
135135

136136
it('should not announce itself joining by default', function () {
@@ -139,7 +139,7 @@ describe('Bot Events', function () {
139139
const channel = '#channel';
140140
const nick = bot.nickname;
141141
bot.ircClient.emit('join', channel, nick);
142-
bot.sendSpecialToDiscord.should.not.have.been.called;
142+
bot.sendExactToDiscord.should.not.have.been.called;
143143
});
144144

145145
it('should be possible to get the bot to announce itself joining', function () {
@@ -149,7 +149,7 @@ describe('Bot Events', function () {
149149
const nick = this.bot.nickname;
150150
const text = `*${nick}* has joined the channel`;
151151
bot.ircClient.emit('join', channel, nick);
152-
bot.sendSpecialToDiscord.should.have.been.calledWithExactly(channel, text);
152+
bot.sendExactToDiscord.should.have.been.calledWithExactly(channel, text);
153153
});
154154

155155
it('should send part messages to discord when config enabled', function () {
@@ -160,7 +160,7 @@ describe('Bot Events', function () {
160160
const reason = 'Leaving';
161161
const text = `*${nick}* has left the channel (${reason})`;
162162
bot.ircClient.emit('part', channel, nick, reason);
163-
bot.sendSpecialToDiscord.should.have.been.calledWithExactly(channel, text);
163+
bot.sendExactToDiscord.should.have.been.calledWithExactly(channel, text);
164164
});
165165

166166
it('should send quit messages to discord when config enabled', function () {
@@ -172,8 +172,8 @@ describe('Bot Events', function () {
172172
const reason = 'Quit: Leaving';
173173
const text = `*${nick}* has quit (${reason})`;
174174
bot.ircClient.emit('quit', nick, reason, [channel1, channel2]);
175-
bot.sendSpecialToDiscord.getCall(0).args.should.deep.equal([channel1, text]);
176-
bot.sendSpecialToDiscord.getCall(1).args.should.deep.equal([channel2, text]);
175+
bot.sendExactToDiscord.getCall(0).args.should.deep.equal([channel1, text]);
176+
bot.sendExactToDiscord.getCall(1).args.should.deep.equal([channel2, text]);
177177
});
178178

179179
it('should be possible to disable join/part/quit messages', function () {
@@ -187,7 +187,7 @@ describe('Bot Events', function () {
187187
bot.ircClient.emit('part', channel, nick, reason);
188188
bot.ircClient.emit('join', channel, nick);
189189
bot.ircClient.emit('quit', nick, reason, [channel]);
190-
bot.sendSpecialToDiscord.should.not.have.been.called;
190+
bot.sendExactToDiscord.should.not.have.been.called;
191191
});
192192

193193
it('should not listen to discord debug messages in production', function () {

test/bot.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,19 @@ describe('Bot', function () {
9898

9999
it('should not send special messages to discord if the channel isn\'t in the channel mapping',
100100
function () {
101-
this.bot.sendSpecialToDiscord('#no-irc', 'message');
101+
this.bot.sendExactToDiscord('#no-irc', 'message');
102102
this.sendMessageStub.should.not.have.been.called;
103103
});
104104

105105
it('should not send special messages to discord if it isn\'t in the channel',
106106
function () {
107-
this.bot.sendSpecialToDiscord('#otherirc', 'message');
107+
this.bot.sendExactToDiscord('#otherirc', 'message');
108108
this.sendMessageStub.should.not.have.been.called;
109109
});
110110

111111
it('should send special messages to discord',
112112
function () {
113-
this.bot.sendSpecialToDiscord('#irc', 'message');
113+
this.bot.sendExactToDiscord('#irc', 'message');
114114
this.sendMessageStub.should.have.been.calledWith('message');
115115
this.debugSpy.should.have.been.calledWith('Sending special message to Discord', 'message', '#irc', '->', '#discord');
116116
});

0 commit comments

Comments
 (0)