Permalink
Browse files

Merge pull request #120 from cwc/fixes

Allow nick change
  • Loading branch information...
2 parents fa65db2 + f75c1ac commit 1aa2dfe559ace12e12edc113e55bf78bd598f470 David Petersen committed Jun 6, 2012
Showing with 18 additions and 2 deletions.
  1. +12 −2 assets/js/client.js
  2. +6 −0 lib/irchandler.js
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() {

0 comments on commit 1aa2dfe

Please sign in to comment.