},
'JOIN': function (command) {
- var channel;
+ var channel, time;
if (typeof command.trailing === 'string' && command.trailing !== '') {
channel = command.trailing;
} else if (typeof command.params[0] === 'string' && command.params[0] !== '') {
channel = command.params[0];
}
+ if (_.contains(this.irc_connection.cap.enabled, 'server-time') && command.tags && command.tags.length > 0) {
+ time = _.find(command.tags, function (tag) {
+ return tag.tag === 'time';
+ });
+ time = time ? time.value : undefined;
+ }
+
this.irc_connection.emit('channel ' + channel + ' join', {
nick: command.nick,
ident: command.ident,
hostname: command.hostname,
- channel: channel
+ channel: channel,
+ time: time
});
},
'PART': function (command) {
+ var time;
+
+ if (_.contains(this.irc_connection.cap.enabled, 'server-time') && command.tags && command.tags.length > 0) {
+ time = _.find(command.tags, function (tag) {
+ return tag.tag === 'time';
+ });
+ time = time ? time.value : undefined;
+ }
+
this.irc_connection.emit('channel ' + command.params[0] + ' part', {
nick: command.nick,
ident: command.ident,
hostname: command.hostname,
channel: command.params[0],
- message: command.trailing
+ message: command.trailing,
+ time: time
});
},
'KICK': function (command) {
+ var time;
+
+ if (_.contains(this.irc_connection.cap.enabled, 'server-time') && command.tags && command.tags.length > 0) {
+ time = _.find(command.tags, function (tag) {
+ return tag.tag === 'time';
+ });
+ time = time ? time.value : undefined;
+ }
+
this.irc_connection.emit('channel ' + command.params[0] + ' kick', {
kicked: command.params[1],
nick: command.nick,
ident: command.ident,
hostname: command.hostname,
channel: command.params[0],
- message: command.trailing
+ message: command.trailing,
+ time: time
});
},
'QUIT': function (command) {
+ var time;
+
+ if (_.contains(this.irc_connection.cap.enabled, 'server-time') && command.tags && command.tags.length > 0) {
+ time = _.find(command.tags, function (tag) {
+ return tag.tag === 'time';
+ });
+ time = time ? time.value : undefined;
+ }
+
this.irc_connection.emit('user ' + command.nick + ' quit', {
nick: command.nick,
ident: command.ident,
hostname: command.hostname,
- message: command.trailing
+ message: command.trailing,
+ time: time
});
},
'NOTICE': function (command) {
- var namespace;
+ var namespace,
+ time;
+
+ if (_.contains(this.irc_connection.cap.enabled, 'server-time') && command.tags && command.tags.length > 0) {
+ time = _.find(command.tags, function (tag) {
+ return tag.tag === 'time';
+ });
+ time = time ? time.value : undefined;
+ }
+
if ((command.trailing.charAt(0) === String.fromCharCode(1)) && (command.trailing.charAt(command.trailing.length - 1) === String.fromCharCode(1))) {
// It's a CTCP response
ident: command.ident,
hostname: command.hostname,
channel: command.params[0],
- msg: command.trailing.substring(1, command.trailing.length - 1)
+ msg: command.trailing.substring(1, command.trailing.length - 1),
+ time: time
});
} else {
namespace = (command.params[0].toLowerCase() == this.irc_connection.nick.toLowerCase() || command.params[0] == '*') ?
ident: command.ident,
hostname: command.hostname,
target: command.params[0],
- msg: command.trailing
+ msg: command.trailing,
+ time: time
});
}
},
'NICK': function (command) {
+ var time;
+
+ if (_.contains(this.irc_connection.cap.enabled, 'server-time') && command.tags && command.tags.length > 0) {
+ time = _.find(command.tags, function (tag) {
+ return tag.tag === 'time';
+ });
+ time = time ? time.value : undefined;
+ }
+
this.irc_connection.emit('user ' + command.nick + ' nick', {
nick: command.nick,
ident: command.ident,
hostname: command.hostname,
- newnick: command.trailing || command.params[0]
+ newnick: command.trailing || command.params[0],
+ time: time
});
},
'TOPIC': function (command) {
+ var time;
+
// If we don't have an associated channel, no need to continue
if (!command.params[0]) return;
+ if (_.contains(this.irc_connection.cap.enabled, 'server-time') && command.tags && command.tags.length > 0) {
+ time = _.find(command.tags, function (tag) {
+ return tag.tag === 'time';
+ });
+ time = time ? time.value : undefined;
+ }
+
var channel = command.params[0],
topic = command.trailing || '';
this.irc_connection.emit('channel ' + channel + ' topic', {
nick: command.nick,
channel: channel,
- topic: topic
+ topic: topic,
+ time: time
});
},
prefixes = this.irc_connection.options.PREFIX || [],
always_param = (chanmodes[0] || '').concat((chanmodes[1] || '')),
modes = [],
- has_param, i, j, add, event;
+ has_param, i, j, add, event, time;
+
+ if (_.contains(this.irc_connection.cap.enabled, 'server-time') && command.tags && command.tags.length > 0) {
+ time = _.find(command.tags, function (tag) {
+ return tag.tag === 'time';
+ });
+ time = time ? time.value : undefined;
+ }
prefixes = _.reduce(prefixes, function (list, prefix) {
list.push(prefix.mode);
this.irc_connection.emit(event, {
target: command.params[0],
nick: command.nick || command.prefix || '',
- modes: modes
+ modes: modes,
+ time: time
});
},
'PRIVMSG': function (command) {
- var tmp, namespace;
+ var tmp, namespace, time;
+
+ if (_.contains(this.irc_connection.cap.enabled, 'server-time') && command.tags && command.tags.length > 0) {
+ time = _.find(command.tags, function (tag) {
+ return tag.tag === 'time';
+ });
+ time = time ? time.value : undefined;
+ }
+
if ((command.trailing.charAt(0) === String.fromCharCode(1)) && (command.trailing.charAt(command.trailing.length - 1) === String.fromCharCode(1))) {
//CTCP request
if (command.trailing.substr(1, 6) === 'ACTION') {
- this.irc_connection.clientEvent('action', {nick: command.nick, ident: command.ident, hostname: command.hostname, channel: command.params[0], msg: command.trailing.substring(8, command.trailing.length - 1)});
+ this.irc_connection.clientEvent('action', {
+ nick: command.nick,
+ ident: command.ident,
+ hostname: command.hostname,
+ channel: command.params[0],
+ msg: command.trailing.substring(8, command.trailing.length - 1),
+ time: time
+ });
} else if (command.trailing.substr(1, 4) === 'KIWI') {
tmp = command.trailing.substring(6, command.trailing.length - 1);
namespace = tmp.split(' ', 1)[0];
- this.irc_connection.clientEvent('kiwi', {namespace: namespace, data: tmp.substr(namespace.length + 1)});
+ this.irc_connection.clientEvent('kiwi', {
+ namespace: namespace,
+ data: tmp.substr(namespace.length + 1),
+ time: time
+ });
} else if (command.trailing.substr(1, 7) === 'VERSION') {
this.irc_connection.write('NOTICE ' + command.nick + ' :' + String.fromCharCode(1) + 'VERSION KiwiIRC' + String.fromCharCode(1));
} else if (command.trailing.substr(1, 6) === 'SOURCE') {
hostname: command.hostname,
target: command.params[0],
type: (command.trailing.substring(1, command.trailing.length - 1).split(' ') || [null])[0],
- msg: command.trailing.substring(1, command.trailing.length - 1)
+ msg: command.trailing.substring(1, command.trailing.length - 1),
+ time: time
});
}
} else {
ident: command.ident,
hostname: command.hostname,
channel: command.params[0],
- msg: command.trailing
+ msg: command.trailing,
+ time: time
});
}
},
var request;
// Which capabilities we want to enable
- var want = ['multi-prefix', 'away-notify'];
+ var want = ['multi-prefix', 'away-notify', 'server-time'];
if (this.irc_connection.password) {
want.push('sasl');
},
'AWAY': function (command) {
+ var time;
+
+ if (_.contains(this.irc_connection.cap.enabled, 'server-time') && command.tags && command.tags.length > 0) {
+ time = _.find(command.tags, function (tag) {
+ return tag.tag === 'time';
+ });
+ time = time ? time.value : undefined;
+ }
+
this.irc_connection.emit('user ' + command.nick + ' away', {
nick: command.nick,
- msg: command.trailing
+ msg: command.trailing,
+ time: time
});
},