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

Add 14 new raw handlers #748

Open
wants to merge 2 commits 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
2 changes: 2 additions & 0 deletions client/assets/text_themes/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"channel_badpassword": "× %text",
"channel_topic": "ⓘ %text",
"channel_banned": "× %text",
"nick_change_too_fast": "⚠ %text",
"channel_badkey": "⚠ %text",
"channel_inviteonly": "⚠ %channel %text",
"channel_alreadyin": "⚠ %nick %text",
Expand Down Expand Up @@ -38,6 +39,7 @@
"ignore_stopped": "%text",
"chanop_privs_needed": "⚠ %text",
"no_such_nick": "ⓘ %nick: %text",
"no_such_server": "ⓘ %server: %text",
"unknown_command": "ⓘ %text",
"motd": "%text",
"ctcp": "[CTCP] %text",
Expand Down
38 changes: 36 additions & 2 deletions client/src/models/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -865,9 +865,17 @@
case 'no_such_nick':
tmp = this.panels.getByName(event.nick);
if (tmp) {
tmp.addMsg(' ', styleText('no_such_nick', {nick: event.nick, text: event.reason, channel: event.channel}), 'status');
tmp.addMsg(' ', styleText('no_such_nick', {nick: event.nick, text: event.reason}), 'status');
} else {
this.panels.server.addMsg(' ', styleText('no_such_nick', {nick: event.nick, text: event.reason, channel: event.channel}), 'status');
this.panels.server.addMsg(' ', styleText('no_such_nick', {nick: event.nick, text: event.reason}), 'status');
}
break;
case 'no_such_server':
tmp = this.panels.getByName(event.nick);
if (tmp) {
tmp.addMsg(' ', styleText('no_such_server', {server: event.server, text: event.reason}), 'status');
} else {
this.panels.server.addMsg(' ', styleText('no_such_server', {server: event.server, text: event.reason}), 'status');
}
break;
case 'nickname_in_use':
Expand All @@ -883,6 +891,32 @@

break;

case 'nickname_collision':
this.panels.server.addMsg(' ', styleText('nickname_alreadyinuse', {nick: event.nick, text: translateText('client_models_network_nickname_alreadyinuse', [event.nick]), channel: event.channel}), 'status');
if (this.panels.server !== this.panels.active) {
_kiwi.app.message.text(_kiwi.global.i18n.translate('client_models_network_nickname_alreadyinuse').fetch(event.nick));
}

// Only show the nickchange component if the controlbox is open
if (_kiwi.app.controlbox.$el.css('display') !== 'none') {
(new _kiwi.view.NickChangeBox()).render();
}

break;

case 'banned_nickname_change':
panel.addMsg(' ', styleText('channel_banned', {nick: event.nick, text: translateText('client_models_network_banned', [event.channel, event.reason]), channel: event.channel}), 'status');
_kiwi.app.message.text(_kiwi.global.i18n.translate('client_models_network_banned').fetch(event.channel, event.reason));

break;

case 'nick_change_too_fast':
this.panels.server.addMsg(' ', styleText('nick_change_too_fast', {nick: event.nick, text: translateText('client_models_network_nick_change_too_fast', [event.nick]), channel: event.channel}), 'status');
if (this.panels.server !== this.panels.active) {
_kiwi.app.message.text(_kiwi.global.i18n.translate('client_models_network_nick_change_too_fast').fetch(event.reason));
}
break;

case 'password_mismatch':
this.panels.server.addMsg(' ', styleText('channel_badpassword', {nick: event.nick, text: translateText('client_models_network_badpassword', []), channel: event.channel}), 'status');
break;
Expand Down
4 changes: 4 additions & 0 deletions client/src/translations/en-gb.po
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ msgstr "No such nick"
msgid "client_models_network_banned"
msgstr "You are banned from %s. %s"

#:
msgid "client_models_network_nick_change_too_fast"
msgstr "Nick change too fast. %s"

#:
msgid "client_models_network_channel_badkey"
msgstr "Bad channel key for %s"
Expand Down
14 changes: 14 additions & 0 deletions server/irc/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ irc_numerics = {
'291': 'RPL_HELPOP',
'292': 'RPL_HELPTLR',
'301': 'RPL_AWAY',
'302': 'RPL_USERHOST',
'303': 'RPL_ISON',
'304': 'RPL_ZIPSTATS',
'305': 'RPL_UNAWAY',
'306': 'RPL_NOWAWAY',
'307': 'RPL_WHOISREGNICK',
'310': 'RPL_WHOISHELPOP',
'311': 'RPL_WHOISUSER',
Expand All @@ -94,6 +98,10 @@ irc_numerics = {
'335': 'RPL_WHOISBOT',
'338': 'RPL_WHOISACTUALLY',
'341': 'RPL_INVITING',
'346': 'RPL_INVITELIST',
'347': 'RPL_ENDOFINVITELIST',
'348': 'RPL_EXCEPTLIST',
'349': 'RPL_ENDOFEXCEPTLIST',
'352': 'RPL_WHOREPLY',
'353': 'RPL_NAMEREPLY',
'364': 'RPL_LINKS',
Expand All @@ -110,9 +118,11 @@ irc_numerics = {
'378': 'RPL_WHOISHOST',
'379': 'RPL_WHOISMODES',
'381': 'RPL_NOWOPER',
'391': 'RPL_TIME',
'396': 'RPL_HOSTCLOACKING',
'401': 'ERR_NOSUCHNICK',
'402': 'ERR_NOSUCHSERVER',
'403': 'ERR_NOSUCHCHANNEL',
'404': 'ERR_CANNOTSENDTOCHAN',
'405': 'ERR_TOOMANYCHANNELS',
'406': 'ERR_WASNOSUCHNICK',
Expand All @@ -121,6 +131,9 @@ irc_numerics = {
'423': 'ERR_NOADMININFO',
'432': 'ERR_ERRONEUSNICKNAME',
'433': 'ERR_NICKNAMEINUSE',
'436': 'ERR_NICKCOLLISION',
'437': 'ERR_BANNICKCHANGE',
'438': 'ERR_NICKTOOFAST',
'441': 'ERR_USERNOTINCHANNEL',
'442': 'ERR_NOTONCHANNEL',
'443': 'ERR_USERONCHANNEL',
Expand All @@ -139,6 +152,7 @@ irc_numerics = {
'484': 'ERR_ISCHANSERVICE',
'485': 'ERR_ISREALSERVICE',
'491': 'ERR_NOOPERHOST',
'520': 'ERR_CANTJOINOPERSONLY',
'670': 'RPL_STARTTLS',
'671': 'RPL_WHOISSECURE',
'900': 'RPL_SASLAUTHENTICATED',
Expand Down
42 changes: 42 additions & 0 deletions server/irc/commands/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,46 @@ var handlers = {
channel: command.params[1]
});
},


RPL_INVITELIST: function (command) {
this.emit('channel ' + command.params[1] + ' invitelist', {
channel: command.params[1],
banned: command.params[2],
banned_by: command.params[3],
banned_at: command.params[4]
});
},


RPL_ENDOFINVITELIST: function (command) {
this.emit('channel ' + command.params[1] + ' invitelist_end', {
channel: command.params[1]
});
},


RPL_EXCEPTLIST: function (command) {
this.emit('channel ' + command.params[1] + ' exceptlist', {
channel: command.params[1],
banned: command.params[2],
banned_by: command.params[3],
banned_at: command.params[4]
});
},


RPL_ENDOFEXCEPTLIST: function (command) {
this.emit('channel ' + command.params[1] + ' exceptlist_end', {
channel: command.params[1]
});
},


ERR_NOSUCHCHANNEL: function (command) {
this.emit('channel ' + command.params[1] + ' wasnosuchchannel', {
channel: command.params[1]
});
},

};
36 changes: 32 additions & 4 deletions server/irc/commands/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ var handlers = {
});
},

ERR_NOSUCHSERVER: function (command) {
this.emit('server ' + this.irc_connection.irc_host.hostname + ' no_such_server', {
server: command.params[1],
reason: command.params[command.params.length - 1]
});
},

ERR_CANNOTSENDTOCHAN: function (command) {
this.emit('server ' + this.irc_connection.irc_host.hostname + ' cannot_send_to_channel', {
channel: command.params[1],
Expand Down Expand Up @@ -181,6 +188,27 @@ var handlers = {
});
},

ERR_NICKCOLLISION: function (command) {
this.emit('server ' + this.irc_connection.irc_host.hostname + ' nickname_collision', {
nick: command.params[1],
reason: command.params[command.params.length - 1]
});
},

ERR_BANNICKCHANGE: function (command) {
this.emit('server ' + this.irc_connection.irc_host.hostname + ' banned_nickname_change', {
channel: command.params[1],
reason: command.params[command.params.length - 1]
});
},

ERR_NICKTOOFAST: function (command) {
this.emit('server ' + this.irc_connection.irc_host.hostname + ' nick_change_too_fast', {
nick: command.params[1],
reason: command.params[command.params.length - 1]
});
},

ERR_ERRONEUSNICKNAME: function(command) {
this.emit('server ' + this.irc_connection.irc_host.hostname + ' erroneus_nickname', {
nick: command.params[1],
Expand Down Expand Up @@ -629,25 +657,25 @@ var handlers = {
this.emitGenericNotice(command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]);
},

RPL_NOSUCHSERVER: function (command) {
ERR_NOADMININFO: function (command) {
var params = _.clone(command.params);
params.shift();
this.emitGenericNotice(command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]);
},

ERR_NOADMININFO: function (command) {
ERR_NOTENOUGHPARAMS: function (command) {
var params = _.clone(command.params);
params.shift();
this.emitGenericNotice(command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]);
},

ERR_NOTENOUGHPARAMS: function (command) {
ERR_NOOPERHOST: function (command) {
var params = _.clone(command.params);
params.shift();
this.emitGenericNotice(command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]);
},

ERR_NOOPERHOST: function (command) {
ERR_CANTJOINOPERSONLY: function (command) {
var params = _.clone(command.params);
params.shift();
this.emitGenericNotice(command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]);
Expand Down
24 changes: 24 additions & 0 deletions server/irc/commands/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,30 @@ var handlers = {
});
},

RPL_USERHOST: function (command) {
var params = _.clone(command.params);
params.shift();
this.emitGenericNotice(command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]);
},

RPL_ISON: function (command) {
var params = _.clone(command.params);
params.shift();
this.emitGenericNotice(command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]);
},

RPL_UNAWAY: function (command) {
var params = _.clone(command.params);
params.shift();
this.emitGenericNotice(command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]);
},

RPL_NOWAWAY: function (command) {
var params = _.clone(command.params);
params.shift();
this.emitGenericNotice(command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]);
},

RPL_WHOISUSER: function (command) {
this.emit('user ' + command.params[1] + ' whoisuser', {
nick: command.params[1],
Expand Down
19 changes: 19 additions & 0 deletions server/irc/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var IrcServer = function (irc_connection) {
password_mismatch: onPasswordMismatch,
channel_redirect: onChannelRedirect,
no_such_nick: onNoSuchNick,
no_such_server: onNoSuchServer,
cannot_send_to_channel: onCannotSendToChan,
too_many_channels: onTooManyChannels,
user_not_in_channel: onUserNotInChannel,
Expand All @@ -36,6 +37,8 @@ var IrcServer = function (irc_connection) {
bad_channel_key: onBadChannelKey,
chanop_privs_needed: onChanopPrivsNeeded,
nickname_in_use: onNicknameInUse,
banned_nickname_change: onBannedFromChannel,
nick_change_too_fast: onNickChangeTooFast,
erroneus_nickname: onErroneusNickname,
unknown_command: onUnknownCommand
};
Expand Down Expand Up @@ -164,6 +167,14 @@ function onNoSuchNick(event) {
});
}

function onNoSuchServer(event) {
this.irc_connection.clientEvent('irc_error', {
error: 'no_such_server',
server: event.server,
reason: event.reason
});
}

function onCannotSendToChan(event) {
this.irc_connection.clientEvent('irc_error', {
error: 'cannot_send_to_channel',
Expand Down Expand Up @@ -253,6 +264,14 @@ function onNicknameInUse(event) {
});
}

function onNickChangeTooFast(event) {
this.irc_connection.clientEvent('irc_error', {
error: 'nick_change_too_fast',
nick: event.nick,
reason: event.reason
});
}

function onErroneusNickname(event) {
this.irc_connection.clientEvent('irc_error', {
error: 'erroneus_nickname',
Expand Down