Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Allow nick change #120

Merged
merged 1 commit into from Jun 6, 2012
Jump to file or symbol
Failed to load files and symbols.
+18 −2
Split
View
@@ -210,13 +210,17 @@ $(function() {
if (data.oldNick === irc.me.get('nick'))
irc.me.set('nick', data.newNick);
- // TODO: If not me, change name in user list and send channel message
var channel = irc.chatWindows.getByName(data.channels[0]);
var user = channel.userList.getByNick(data.oldNick);
user.set({nick: data.newNick});
user.view.render();
+
+ // Add nickmessage to all channels
var nickMessage = new Message({type: 'nick', oldNick: data.oldNick, newNick: data.newNick});
- channel.stream.add(nickMessage);
+ for( var i in data.channels ) {
+ channel = irc.chatWindows.getByName(data.channels[i]);
+ channel.stream.add(nickMessage);
+ }
});
irc.socket.on('topic', function(data) {
@@ -300,6 +304,12 @@ $(function() {
irc.appView.channelList.channelTabs[0].setActive();
}
break;
+
+ case '/nick':
+ if (commandText[1]) {
+ irc.socket.emit('nick', {nick : commandText[1]});
+ }
+ break;
case '/topic':
if (commandText[2]) {
irc.socket.emit('topic', {name: commandText[1], topic: commandText[2]});
View
@@ -207,6 +207,12 @@ var irchandler = exports.irchandler = function(socket, app) {
client.send('TOPIC ' + data.name + ' ' + data.topic);
});
+ socket.on('nick', function(data){
+ client.send('NICK ' + data.nick);
+ client.nick = data.nick;
+ client.opt.nick = data.nick;
+ });
+
socket.on('command', function(text) { console.log(text); client.send(text); });
socket.on('disconnect', function() {