Grafting the new server to the new backbone client
[KiwiIRC.git] / server / irc-commands.js
CommitLineData
a8bf3ea4
JA
1var _ = require('underscore');
2
3var irc_numerics = {
4 RPL_WELCOME: '001',
5 RPL_MYINFO: '004',
6 RPL_ISUPPORT: '005',
7 RPL_WHOISUSER: '311',
8 RPL_WHOISSERVER: '312',
9 RPL_WHOISOPERATOR: '313',
10 RPL_WHOISIDLE: '317',
11 RPL_ENDOFWHOIS: '318',
12 RPL_WHOISCHANNELS: '319',
13 RPL_LISTSTART: '321',
14 RPL_LIST: '322',
15 RPL_LISTEND: '323',
16 RPL_NOTOPIC: '331',
17 RPL_TOPIC: '332',
18 RPL_TOPICWHOTIME: '333',
19 RPL_NAMEREPLY: '353',
20 RPL_ENDOFNAMES: '366',
21 RPL_BANLIST: '367',
22 RPL_ENDOFBANLIST: '368',
23 RPL_MOTD: '372',
24 RPL_MOTDSTART: '375',
25 RPL_ENDOFMOTD: '376',
26 RPL_WHOISMODES: '379',
27 ERR_NOSUCHNICK: '401',
28 ERR_CANNOTSENDTOCHAN: '404',
29 ERR_TOOMANYCHANNELS: '405',
30 ERR_NICKNAMEINUSE: '433',
31 ERR_USERNOTINCHANNEL: '441',
32 ERR_NOTONCHANNEL: '442',
33 ERR_NOTREGISTERED: '451',
34 ERR_LINKCHANNEL: '470',
35 ERR_CHANNELISFULL: '471',
36 ERR_INVITEONLYCHAN: '473',
37 ERR_BANNEDFROMCHAN: '474',
38 ERR_BADCHANNELKEY: '475',
39 ERR_CHANOPRIVSNEEDED: '482',
40 RPL_STARTTLS: '670'
41};
42
43
44var Binder = function (irc_connection, con_num, client) {
45 this.irc_connection = irc_connection;
46 this.con_num = con_num;
47 this.client = client;
48};
49module.exports.Binder = Binder;
50
51Binder.prototype.bind_irc_commands = function () {
52 var that = this;
53 _.each(listeners, function (listener, command) {
54 var s = command.substr(0, 4);
55 if ((s === 'RPL_') || (s === 'ERR_')) {
56 command = irc_numerics[command];
57 }
58 that.irc_connection.on('irc_' + command, function () {
59 listener.apply(that, arguments);
60 });
61 });
62};
63
64var listeners = {
65 'RPL_WELCOME': function (command) {
66 var nick = command.params[0];
67 this.irc_connection.registered = true;
68 this.client.sendKiwiCommand({server: this.con_num, command: 'connect', nick: nick});
69 },
70 'RPL_ISUPPORT': function (command) {
71 var options, i, option, matches, j;
72 options = command.params;
73 for (i = 1; i < options.length; i++) {
74 option = options[i].split("=", 2);
75 option[0] = option[0].toUpperCase();
76 this.irc_connection.options[option[0]] = (typeof option[1] !== 'undefined') ? option[1] : true;
77 if (_.include(['NETWORK', 'PREFIX', 'CHANTYPES', 'CHANMODES', 'NAMESX'], option[0])) {
78 if (option[0] === 'PREFIX') {
79 matches = /\(([^)]*)\)(.*)/.exec(option[1]);
80 if ((matches) && (matches.length === 3)) {
81 this.irc_connection.options.PREFIX = [];
82 for (j = 0; j < matches[2].length; j++) {
83 this.irc_connection.options.PREFIX.push({symbol: matches[2].charAt(j), mode: matches[1].charAt(j)});
84 }
85 }
86 } else if (option[0] === 'CHANTYPES') {
87 this.irc_connection.options.CHANTYPES = this.irc_connection.options.CHANTYPES.split('');
88 } else if (option[0] === 'CHANMODES') {
89 this.irc_connection.options.CHANMODES = option[1].split(',');
90 } else if (option[0] === 'NAMESX') {
91 this.irc_connection.send('PROTOCTL NAMESX');
92 }
93 }
94 }
95 //this.client.sendIRCCommand({server: this.con_num, command: 'RPL_ISUPPORT', options: this.irc_connection.options});
96 //websocket.sendClientEvent('options', {server: '', "options": irc_connection.IRC.options});
97 this.client.sendIRCCommand('options', {server: this.con_num, options: this.irc_connection.options});
98 },
99 'RPL_ENDOFWHOIS': function (command) {
100 /*command.server = this.con_num;
101 command.command = 'RPL_ENDOFWHOIS';
102 this.client.sendIRCCommand(command);*/
103 //websocket.sendClientEvent('whois', {server: '', nick: msg.params.split(" ", 3)[1], "msg": msg.trailing, end: true});
104 this.client.sendIRCCommand('whois', {server: this.con_num, nick: command.params[0], msg: command.trailing, end: true});
105 },
106 'RPL_WHOISUSER': function (command) {
107 /*command.server = this.con_num;
108 command.command = 'RPL_WHOISUSER';
109 this.client.sendIRCCommand(command);*/
110 //websocket.sendClientEvent('whois', {server: '', nick: msg.params.split(" ", 3)[1], "msg": msg.trailing, end: false});
111 this.client.sendIRCCommand('whois', {server: this.con_num, nick: command.params[0], msg: command.trailing, end: false});
112 },
113 'RPL_WHOISSERVER': function (command) {
114 /*command.server = this.con_num;
115 command.command = 'RPL_WHOISSERVER';
116 this.client.sendIRCCommand(command);*/
117 //websocket.sendClientEvent('whois', {server: '', nick: msg.params.split(" ", 3)[1], "msg": msg.trailing, end: false});
118 this.client.sendIRCCommand('whois', {server: this.con_num, nick: command.params[0], msg: command.trailing, end: false});
119 },
120 'RPL_WHOISOPERATOR': function (command) {
121 /*command.server = this.con_num;
122 command.command = 'RPL_WHOISOPERATOR';
123 this.client.sendIRCCommand(command);*/
124 //websocket.sendClientEvent('whois', {server: '', nick: msg.params.split(" ", 3)[1], "msg": msg.trailing, end: false});
125 this.client.sendIRCCommand('whois', {server: this.con_num, nick: command.params[0], msg: command.trailing, end: false});
126 },
127 'RPL_WHOISCHANNELS': function (command) {
128 /*command.server = this.con_num;
129 command.command = 'RPL_WHOISCHANNELS';
130 this.client.sendIRCCommand(command);*/
131 //websocket.sendClientEvent('whois', {server: '', nick: msg.params.split(" ", 3)[1], "msg": msg.trailing, end: false});
132 this.client.sendIRCCommand('whois', {server: this.con_num, nick: command.params[0], msg: command.trailing, end: false});
133 },
134 'RPL_WHOISMODES': function (command) {
135 /*command.server = this.con_num;
136 command.command = 'RPL_WHOISMODES';
137 this.client.sendIRCCommand(command);*/
138 //websocket.sendClientEvent('whois', {server: '', nick: msg.params.split(" ", 3)[1], "msg": msg.trailing, end: false});
139 this.client.sendIRCCommand('whois', {server: this.con_num, nick: command.params[0], msg: command.trailing, end: false});
140 },
141 'RPL_WHOISIDLE': function (command) {
142 /*command.server = this.con_num;
143 command.command = 'RPL_WHOISIDLE';
144 this.client.sendIRCCommand(command);*/
145 //websocket.sendClientEvent('whois', {server: '', nick: msg.params.split(" ", 3)[1], "msg": msg.trailing, end: false});
146 this.client.sendIRCCommand('whois', {server: this.con_num, nick: command.params[0], msg: command.trailing, end: false});
147 },
148 'RPL_LISTSTART': function (command) {
149 /*command.server = this.con_num;
150 command.command = 'RPL_LISTSTART';
151 this.client.sendIRCCommand(command);*/
152 this.client.sendIRCCommand('list_start', {server: this.con_num});
153 this.client.buffer.list = [];
154 },
155 'RPL_LISTEND': function (command) {
156 /*command.server = this.con_num;
157 command.command = 'RPL_LISTEND';
158 this.client.sendIRCCommand(command);*/
159 if (this.client.buffer.list.length > 0) {
160 this.client.buffer.list = _.sortBy(this.client.buffer.list, function (channel) {
161 return channel.num_users;
162 });
163 this.client.sendIRCCommand('list_channel', {server: this.con_num, chans: this.client.buffer.list});
164 this.client.buffer.list = [];
165 }
166 this.client.sendIRCCommand('list_end', {server: this.con_num});
167 },
168 'RPL_LIST': function (command) {
169 /*command.server = this.con_num;
170 command.command = 'RPL_LIST';
171 this.client.sendIRCCommand(command);*/
172 this.client.buffer.list.push({server: this.con_num, channel: command.params[1], num_users: parseInt(command.params[2]), topic: command.trailing});
173 if (this.client.buffer.list.length > 200){
174 this.client.buffer.list = _.sortBy(this.client.buffer.list, function (channel) {
175 return channel.num_users;
176 });
177 this.client.sendIRCCommand('list_channel', {server: this.con_num, chans: this.client.buffer.list});
178 this.client.buffer.list = [];
179 }
180 },
181 'RPL_MOTD': function (command) {
182 /*command.server = this.con_num;
183 command.command = 'RPL_MOTD';
184 this.client.sendIRCCommand(command);*/
185 this.client.buffer.motd += command.trailing + '\n';
186 },
187 'RPL_MOTDSTART': function (command) {
188 /*command.server = this.con_num;
189 command.command = 'RPL_MOTDSTART';
190 this.client.sendIRCCommand(command);*/
191 this.client.buffer.motd = '';
192 },
193 'RPL_ENDOFMOTD': function (command) {
194 /*command.server = this.con_num;
195 command.command = 'RPL_ENDOFMOTD';
196 this.client.sendIRCCommand(command);*/
197 //websocket.sendClientEvent('motd', {server: '', 'msg': websocket.kiwi.buffer.motd});
198 this.client.sendIRCCommand('motd', {server: this.con_num, msg: this.client.buffer.motd});
199 },
200 'RPL_NAMEREPLY': function (command) {
201 /*command.server = this.con_num;
202 command.command = 'RPL_NAMEREPLY';
203 this.client.sendIRCCommand(command);*/
204 var members = command.trailing.split(' ');
205 var member_list = [];
206 var that = this;
207 var i = 0;
208 _.each(members, function (member) {
209 var j, k, modes = [];
210 for (j = 0; j < member.length; j++) {
211 for (k = 0; k < that.irc_connection.options.PREFIX.length; k++) {
212 if (member.charAt(j) === that.irc_connection.options.PREFIX[k].symbol) {
213 modes.push(that.irc_connection.options.PREFIX[k].mode);
214 i++;
215 }
216 }
217 }
218 member_list.push({nick: member, modes: modes});
219 if (i++ >= 50) {
220 that.client.sendIRCCommand('userlist', {server: that.con_num, users: member_list, channel: command.params[2]});
221 member_list = [];
222 i = 0;
223 }
224 });
225 if (i > 0) {
226 this.client.sendIRCCommand('userlist', {server: this.con_num, users: member_list, channel: command.params[2]});
227 }
228 },
229 'RPL_ENDOFNAMES': function (command) {
230 /*command.server = this.con_num;
231 command.command = 'RPL_ENDOFNAMES';
232 this.client.sendIRCCommand(command);*/
233 //websocket.sendClientEvent('userlist_end', {server: '', channel: msg.params.split(" ")[1]});
234 this.client.sendIRCCommand('userlist_end', {server: this.con_num, channel: command.params[1]});
235 },
236 'RPL_BANLIST': function (command) {
237 /*command.server = this.con_num;
238 command.command = 'RPL_BANLIST';
239 this.client.sendIRCCommand(command);*/
240 //websocket.sendClientEvent('banlist', {server: '', channel: params[1], banned: params[2], banned_by: params[3], banned_at: params[4]});
241 this.client.sendIRCCommand('banlist', {server: this.con_num, channel: command.params[1], banned: command.params[2], banned_by: command.params[3], banned_at: command.params[4]});
242 },
243 'RPL_ENDOFBANLIST': function (command) {
244 /*command.server = this.con_num;
245 command.command = 'RPL_ENDOFBANLIST';
246 this.client.sendIRCCommand(command);*/
247 //websocket.sendClientEvent('banlist_end', {server: '', channel: msg.params.split(" ")[1]});
248 this.client.sendIRCCommand('banlist_end', {server: this.con_num, channel: command.params[1]});
249 },
250 'RPL_TOPIC': function (command) {
251 /*command.server = this.con_num;
252 command.command = 'RPL_TOPIC';
253 this.client.sendIRCCommand(command);*/
254 //{nick: '', channel: msg.params.split(" ")[1], topic: msg.trailing};
255 this.client.sendIRCCommand('topic', {server: this.con_num, nick: '', channel: command.params[1], topic: command.trailing});
256 },
257 'RPL_NOTOPIC': function (command) {
258 /*command.server = this.con_num;
259 command.command = 'RPL_NOTOPIC';
260 this.client.sendIRCCommand(command);*/
261 this.client.sendIRCCommand('topic', {server: this.con_num, nick: '', channel: command.params[1], topic: ''});
262 },
263 'RPL_TOPICWHOTIME': function (command) {
264 /*command.server = this.con_num;
265 command.command = 'RPL_TOPICWHOTIME';
266 this.client.sendIRCCommand(command);*/
267 //{nick: nick, channel: channel, when: when};
268 this.client.sendIRCCommand('topicsetby', {server: this.con_num, nick: command.params[2], channel: command.params[1], when: command.params[3]});
269 },
270 'PING': function (command) {
271 this.irc_connection.send('PONG ' + command.trailing);
272 },
273 'JOIN': function (command) {
274 var channel;
275 if (typeof command.trailing === 'string' && command.trailing !== '') {
276 channel = command.trailing;
277 } else if (typeof command.params[0] === 'string' && command.params[0] !== '') {
278 channel = command.params[0];
279 }
280 /*command.server = this.con_num;
281 command.command = 'JOIN';
282 command.params = [channel];
283 this.client.sendIRCCommand(command);*/
284 //websocket.sendClientEvent('join', {nick: msg.nick, ident: msg.ident, hostname: msg.hostname, channel: channel});
285 this.client.sendIRCCommand('join', {server: this.con_num, nick: command.nick, ident: command.ident, hostname: command.hostname, channel: channel});
286
287 if (command.nick === this.nick) {
288 this.irc_connection.send('NAMES ' + channel);
289 }
290 },
291 'PART': function (command) {
292 /*command.server = this.con_num;
293 command.command = 'PART';
294 this.client.sendIRCCommand(command);*/
295 //websocket.sendClientEvent('part', {nick: msg.nick, ident: msg.ident, hostname: msg.hostname, channel: msg.params.trim(), message: msg.trailing});
296 this.client.sendIRCCommand('part', {server: this.con_num, nick: command.nick, ident: command.ident, hostname: command.hostname, channel: command.params[0], message: command.trailing});
297 },
298 'KICK': function (command) {
299 /*command.server = this.con_num;
300 command.command = 'KICK';
301 this.client.sendIRCCommand(command);*/
302 //websocket.sendClientEvent('kick', {kicked: params[1], nick: msg.nick, ident: msg.ident, hostname: msg.hostname, channel: params[0].trim(), message: msg.trailing});
303 this.client.sendIRCCommand('kick', {server: this.con_num, kicked: command.params[1], nick: command.nick, ident: command.ident, hostname: command.hostname, channel: params[0], message: command.trailing});
304 },
305 'QUIT': function (command) {
306 /*command.server = this.con_num;
307 command.command = 'QUIT';
308 this.client.sendIRCCommand(command);*/
309 //websocket.sendClientEvent('quit', {nick: msg.nick, ident: msg.ident, hostname: msg.hostname, message: msg.trailing});
310 this.client.sendIRCCommand('quit', {server: this.con_num, nick: command.nick, ident: command.ident, hostname: command.hostname, message: command.trailing});
311 },
312 'NOTICE': function (command) {
313 /*command.server = this.con_num;
314 command.command = 'NOTICE';
315 this.client.sendIRCCommand(command);*/
316 if ((command.trailing.charAt(0) === String.fromCharCode(1)) && (command.trailing.charAt(command.trailing.length - 1) === String.fromCharCode(1))) {
317 // It's a CTCP response
318 //websocket.sendClientEvent('ctcp_response', {nick: msg.nick, ident: msg.ident, hostname: msg.hostname, channel: msg.params.trim(), msg: msg.trailing.substr(1, msg.trailing.length - 2)});
319 this.client.sendIRCCommand('ctcp_response', {server: this.con_num, nick: command.nick, ident: command.ident, hostname: command.hostname, channel: command.params[0], msg: command.trailing.substr(1, command.trailing.length - 2)});
320 } else {
321 //websocket.sendClientEvent('notice', {nick: msg.nick, ident: msg.ident, hostname: msg.hostname, target: msg.params.trim(), msg: msg.trailing});
322 this.client.sendIRCCommand('notice', {server: this.con_num, nick: command.nick, ident: command.ident, hostname: command.hostname, target: command.params[0], msg: command.trailing});
323 }
324 },
325 'NICK': function (command) {
326 /*command.server = this.con_num;
327 command.command = 'NICK';
328 this.client.sendIRCCommand(command);*/
329 //websocket.sendClientEvent('nick', {nick: msg.nick, ident: msg.ident, hostname: msg.hostname, newnick: msg.trailing});
330 this.client.sendIRCCommand('nick', {server: this.con_num, nick: command.nick, ident: command.ident, hostname: command.hostname, newnick: command.trailing});
331 },
332 'TOPIC': function (command) {
333 /*command.server = this.con_num;
334 command.command = 'TOPIC';
335 this.client.sendIRCCommand(command);*/
336 //{nick: msg.nick, channel: msg.params, topic: msg.trailing};
337 this.client.sendIRCCommand('topic', {server: this.con_num, nick: command.nick, channel: msg.params[0], topic: command.trailing});
338 },
339 'MODE': function (command) {
340 /*command.server = this.con_num;
341 command.command = 'MODE';
342 this.client.sendIRCCommand(command);*/
343 var ret = { server: this.con_num, nick: command.nick }
344 switch (command.params.length) {
345 case 1:
346 ret.affected_nick = command.params[0];
347 ret.mode = command.trailing;
348 break;
349 case 2:
350 ret.channel = command.params[0];
351 ret.mode = command.params[1];
352 break;
353 default:
354 ret.channel = command.params[0];
355 ret.mode = command.params[1];
356 ret.affected_nick = command.params[2];
357 break;
358 }
359 this.client.sendIRCCommand('mode', ret);
360 },
361 'PRIVMSG': function (command) {
362 /*command.server = this.con_num;
363 command.command = 'PRIVMSG';
364 this.client.sendIRCCommand(command);*/
365 var tmp, namespace;
366 if ((command.trailing.charAt(0) === String.fromCharCode(1)) && (command.trailing.charAt(command.trailing.length - 1) === String.fromCharCode(1))) {
367 //CTCP request
368 if (command.trailing.substr(1, 6) === 'ACTION') {
369 this.client.sendIRCCommand('action', {server: this.con_num, nick: command.nick, ident: command.ident, hostname: command.hostname, channel: command.params[0], msg: command.trailing.substr(7, command.trailing.length - 2)});
370 } else if (command.trailing.substr(1, 4) === 'KIWI') {
371 tmp = msg.trailing.substr(6, msg.trailing.length - 2);
372 namespace = tmp.split(' ', 1)[0];
373 this.client.sendIRCCommand('kiwi', {server: this.con_num, namespace: namespace, data: tmp.substr(namespace.length + 1)});
374 } else if (msg.trailing.substr(1, 7) === 'VERSION') {
375 this.irc_connection.send('NOTICE ' + command.nick + ' :' + String.fromCharCode(1) + 'VERSION KiwiIRC' + String.fromCharCode(1));
376 } else {
377 this.client.sendIRCCommand('ctcp_request', {server: this.con_num, nick: command.nick, ident: command.ident, hostname: command.hostname, channel: command.params[0], msg: command.trailing.substr(1, command.trailing.length - 2)});
378 }
379 } else {
380 //{nick: msg.nick, ident: msg.ident, hostname: msg.hostname, channel: msg.params.trim(), msg: msg.trailing}
381 this.client.sendIRCCommand('msg', {server: this.con_num, nick: command.nick, ident: command.ident, hostname: command.hostname, channel: command.params[0], msg: command.trailing});
382 }
383 },
384 'ERROR': function (command) {
385 /*command.server = this.con_num;
386 command.command = 'ERROR';
387 this.client.sendIRCCommand(command);*/
388 //websocket.sendClientEvent('irc_error', {error: 'error', reason: msg.trailing});
389 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'error', reason: command.trailing});
390 },
391 ERR_LINKCHANNEL: function (command) {
392 /*command.server = this.con_num;
393 command.command = 'ERR_LINKCHANNEL';
394 this.client.sendIRCCommand(command);*/
395 //websocket.sendClientEvent('channel_redirect', {from: params[1], to: params[2]});
396 this.client.sendIRCCommand('channel_redirect', {server: this.con_num, from: command.params[1], to: command.params[2]});
397 },
398 ERR_NOSUCHNICK: function (command) {
399 /*command.server = this.con_num;
400 command.command = 'ERR_NOSUCHNICK';
401 this.client.sendIRCCommand(command);*/
402 //websocket.sendClientEvent('irc_error', {error: 'no_such_nick', nick: msg.params.split(" ")[1], reason: msg.trailing});
403 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'no_such_nick', nick: command.params[1], reason: command.trailing});
404 },
405 ERR_CANNOTSENDTOCHAN: function (command) {
406 /*command.server = this.con_num;
407 command.command = 'ERR_CANNOTSENDTOCHAN';
408 this.client.sendIRCCommand(command);*/
409 //websocket.sendClientEvent('irc_error', {error: 'cannot_send_to_chan', channel: msg.params.split(" ")[1], reason: msg.trailing});
410 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'cannot_send_to_chan', channel: command.params[1], reason: command.trailing});
411 },
412 ERR_TOOMANYCHANNELS: function (command) {
413 /*command.server = this.con_num;
414 command.command = 'ERR_TOOMANYCHANNELS';
415 this.client.sendIRCCommand(command);*/
416 //websocket.sendClientEvent('irc_error', {error: 'too_many_channels', channel: msg.params.split(" ")[1], reason: msg.trailing});
417 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'too_many_channels', channel: command.params[1], reason: command.trailing});
418 },
419 ERR_USERNOTINCHANNEL: function (command) {
420 /*command.server = this.con_num;
421 command.command = 'ERR_USERNOTINCHANNEL';
422 this.client.sendIRCCommand(command);*/
423 //websocket.sendClientEvent('irc_error', {error: 'user_not_in_channel', nick: params[0], channel: params[1], reason: msg.trainling});
424 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'user_not_in_channel', nick: command.params[0], channel: command.params[1], reason: command.trailing});
425 },
426 ERR_NOTONCHANNEL: function (command) {
427 /*command.server = this.con_num;
428 command.command = 'ERR_NOTONCHANNEL';
429 this.client.sendIRCCommand(command);*/
430 //websocket.sendClientEvent('irc_error', {error: 'not_on_channel', channel: msg.params.split(" ")[1], reason: msg.trailing});
431 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'not_on_channel', channel: command.params[1], reason: command.trailing});
432 },
433 ERR_CHANNELISFULL: function (command) {
434 /*command.server = this.con_num;
435 command.command = 'ERR_CHANNELISFULL';
436 this.client.sendIRCCommand(command);*/
437 //websocket.sendClientEvent('irc_error', {error: 'channel_is_full', channel: msg.params.split(" ")[1], reason: msg.trailing});
438 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'channel_is_full', channel: command.params[1], reason: command.trailing});
439 },
440 ERR_INVITEONLYCHAN: function (command) {
441 /*command.server = this.con_num;
442 command.command = 'ERR_INVITEONLYCHAN';
443 this.client.sendIRCCommand(command);*/
444 //websocket.sendClientEvent('irc_error', {error: 'invite_only_channel', channel: msg.params.split(" ")[1], reason: msg.trailing});
445 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'invite_only_channel', channel: command.params[1], reason: command.trailing});
446 },
447 ERR_BANNEDFROMCHAN: function (command) {
448 /*command.server = this.con_num;
449 command.command = 'ERR_BANNEDFROMCHAN';
450 this.client.sendIRCCommand(command);*/
451 //websocket.sendClientEvent('irc_error', {error: 'banned_from_channel', channel: msg.params.split(" ")[1], reason: msg.trailing});
452 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'banned_from_channel', channel: command.params[1], reason: command.trailing});
453 },
454 ERR_BADCHANNELKEY: function (command) {
455 /*command.server = this.con_num;
456 command.command = 'ERR_BADCHANNELKEY';
457 this.client.sendIRCCommand(command);*/
458 //websocket.sendClientEvent('irc_error', {error: 'bad_channel_key', channel: msg.params.split(" ")[1], reason: msg.trailing});
459 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'bad_channel_key', channel: command.params[1], reason: command.trailing});
460 },
461 ERR_CHANOPRIVSNEEDED: function (command) {
462 /*command.server = this.con_num;
463 command.command = 'ERR_CHANOPRIVSNEEDED';
464 this.client.sendIRCCommand(command);*/
465 //websocket.sendClientEvent('irc_error', {error: 'chanop_privs_needed', channel: msg.params.split(" ")[1], reason: msg.trailing});
466 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'chanop_privs_needed', channel: command.params[1], reason: command.trailing});
467 },
468 ERR_NICKNAMEINUSE: function (command) {
469 /*command.server = this.con_num;
470 command.command = 'ERR_NICKNAMEINUSE';
471 this.client.sendIRCCommand(command);*/
472 //websocket.sendClientEvent('irc_error', {error: 'nickname_in_use', nick: _.last(msg.params.split(" ")), reason: msg.trailing});
473 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'nickname_in_use', nick: command.params[1], reason: command.trailing});
474 },
475 ERR_NOTREGISTERED: function (command) {
476 /*command.server = this.con_num;
477 command.command = 'ERR_NOTREGISTERED';
478 this.client.sendIRCCommand(command);*/
479 }
480};