Skip to content

Commit da5f608

Browse files
authored
Merge pull request #94 from MaxLeiter/ctcp
Fix handling CTCP requests; case insensitive and compare full request command
2 parents ab50a41 + dcb471b commit da5f608

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/commands/handlers/messaging.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ var handlers = {
7070

7171
if ((message.charAt(0) === '\01') && (message.charAt(message.length - 1) === '\01')) {
7272
// CTCP request
73-
if (message.substr(1, 6) === 'ACTION') {
74-
73+
var ctcp_command = message.slice(1, -1).split(' ')[0].toUpperCase();
74+
if (ctcp_command === 'ACTION') {
7575
this.emit('action', {
7676
nick: command.nick,
7777
ident: command.ident,
@@ -84,14 +84,14 @@ var handlers = {
8484
account: command.getTag('account')
8585
});
8686

87-
} else if (message.substr(1, 7) === 'VERSION') {
87+
} else if (ctcp_command === 'VERSION') {
8888
this.connection.write(util.format(
8989
'NOTICE %s :\01VERSION %s\01',
9090
command.nick,
9191
this.connection.options.version
9292
));
9393

94-
} else if (message.substr(1, 10) === 'CLIENTINFO') {
94+
} else if (ctcp_command === 'CLIENTINFO') {
9595
this.connection.write(util.format(
9696
'NOTICE %s :\01CLIENTINFO VERSION\01',
9797
command.nick
@@ -104,7 +104,7 @@ var handlers = {
104104
hostname: command.hostname,
105105
target: target,
106106
group: target_group,
107-
type: (message.substring(1, message.length - 1).split(' ') || [null])[0],
107+
type: (ctcp_command || [null])[0],
108108
message: message.substring(1, message.length - 1),
109109
time: time,
110110
account: command.getTag('account')

0 commit comments

Comments
 (0)