Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Who support #735

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion server/irc/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ var IrcChannel = function(irc_connection, name) {
banlist_end: onBanListEnd,
topicsetby: onTopicSetBy,
mode: onMode,
info: onChannelInfo
info: onChannelInfo,
who_channel: onChannelWho,
who_channel_end: onChannelWhoEnd,
};
EventBinder.bindIrcEvents('channel ' + this.name, this.irc_events, this, irc_connection);
};
Expand Down Expand Up @@ -244,6 +246,21 @@ function onNicklistEnd(event) {
//updateUsersList.call(this, event.users);
}

function onChannelWho(event) {
this.irc_connection.clientEvent('who_channel', {
users: event.users,
channel: this.name
});
}


function onChannelWhoEnd(event) {
this.irc_connection.clientEvent('who_channel_end', {
users: event.users,
channel: this.name
});
}

function updateUsersList(users) {
var that = this;
if (users) {
Expand Down
63 changes: 51 additions & 12 deletions server/irc/commands/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,57 @@ var handlers = {
this.emit('server ' + this.irc_connection.irc_host.hostname + ' motd_end', {});
},



RPL_WHOREPLY: function (command) {
// For the time being, NOOP this command so they don't get passed
// down to the client. Waste of bandwidth since we do not use it yet
// TODO: Impliment RPL_WHOREPLY
},

RPL_ENDOFWHO: function (command) {
// For the time being, NOOP this command so they don't get passed
// down to the client. Waste of bandwidth since we do not use it yet
// TODO: Impliment RPL_ENDOFWHO
'RPL_WHOREPLY': function (command) {
// This method is called once for each user in the channel - Gotta be carefull
if (typeof this.who_members === "undefined") {
this.who_members = [];
}

var that = this,
channel = command.params[1],
nick = command.params[5],
flags = command.params[6],
realname = command.params[command.params.length - 1].substring(command.params[command.params.length - 1].indexOf(' ') + 1); // Getting rid of useless hops info

this.who_members.push({nick: nick, realname: realname, flags: flags, channel: channel});
},

'RPL_ENDOFWHO': function (command) {
// If it's a channel WHO
if (command.params[1].substring(0, 1) === '#') {
this.irc_connection.emit('channel ' + command.params[1] + ' who_channel', {
users: this.who_members,
channel: command.params[1]
});
this.irc_connection.emit('channel ' + command.params[1] + ' who_channel_end', {
channel: command.params[1]
});
} else { // It's a user WHO
if(this.who_members[0] == undefined) { // Looks like there is nothing to work with here
return;
}

var who_member = this.who_members[0],
nick = command.params[1],
realname = this.who_members[0].realname;

if(realname == undefined) {
realname = 'U';
}

this.irc_connection.emit('user ' + nick + ' who_user', {
nick: nick,
realname: realname,
flags: who_member.flags,
channel: who_member.channel
});
this.irc_connection.emit('user ' + nick + ' who_user_end', {
nick: nick
});

}
// Reset who_members
this.who_members = [];
},


Expand Down
17 changes: 17 additions & 0 deletions server/irc/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ var IrcUser = function (irc_connection, nick) {
action: onAction,
ctcp_request: onCtcpRequest,
mode: onMode,
who_user: onWhoUser,
who_user_end: onWhoUserEnd,
wallops: onWallops
};
EventBinder.bindIrcEvents('user ' + this.nick, this.irc_events, this, irc_connection);
Expand Down Expand Up @@ -319,6 +321,21 @@ function onMode(event) {
});
}

function onWhoUser(event) {
this.irc_connection.clientEvent('who_user', {
nick: event.nick,
realname: event.realname,
flags: event.flags,
channel: event.channel
});
}

function onWhoUserEnd(event) {
this.irc_connection.clientEvent('who_user_end', {
nick: event.nick
});
}

function onWallops(event) {
this.irc_connection.clientEvent('wallops', {
nick: event.nick,
Expand Down