Memberlist resizing #56
[KiwiIRC.git] / server / irc-commands.js
1 var _ = require('underscore');
2
3 var 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
44 var Binder = function (irc_connection, con_num, client) {
45 this.irc_connection = irc_connection;
46 this.con_num = con_num;
47 this.client = client;
48 };
49 module.exports.Binder = Binder;
50
51 Binder.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
64 var listeners = {
65 'RPL_WELCOME': function (command) {
66 var nick = command.params[0];
67 this.irc_connection.registered = true;
68 this.client.sendIRCCommand('connect', {server: this.con_num, 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.write('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], 10), 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.write('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.write('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: command.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: command.params[0], topic: command.trailing});
338 },
339 'MODE': function (command) {
340 var chanmodes = this.irc_connection.options.CHANMODES,
341 prefixes = this.irc_connection.options.PREFIX,
342 always_param = chanmodes[0].concat(chanmodes[1]),
343 modes = [],
344 has_param, i, j, add;
345
346 prefixes = _.reduce(prefixes, function (list, prefix) {
347 list.push(prefix.mode);
348 return list;
349 }, []);
350 always_param = always_param.split('').concat(prefixes);
351
352 has_param = function (mode, add) {
353 if (_.find(always_param, function (m) {
354 return m === mode;
355 })) {
356 return true;
357 } else if (add && _.find(chanmodes[2].split(''), function (m) {
358 return m === mode;
359 })) {
360 return true;
361 } else {
362 return false;
363 }
364 };
365
366 if (!command.params[1]) {
367 command.params[1] = command.trailing;
368 }
369 j = 0;
370 for (i = 0; i < command.params[1].length; i++) {
371 switch (command.params[1][i]) {
372 case '+':
373 add = true;
374 break;
375 case '-':
376 add = false;
377 break;
378 default:
379 if (has_param(command.params[1][i], add)) {
380 modes.push({mode: (add ? '+' : '-') + command.params[1][i], param: command.params[2 + j]});
381 j++;
382 } else {
383 modes.push({mode: (add ? '+' : '-') + command.params[1][i], param: null});
384 }
385 }
386 }
387
388 this.client.sendIRCCommand('mode', {
389 server: this.con_num,
390 target: command.params[0],
391 nick: command.nick || command.prefix || '',
392 modes: modes
393 });
394 },
395 'PRIVMSG': function (command) {
396 /*command.server = this.con_num;
397 command.command = 'PRIVMSG';
398 this.client.sendIRCCommand(command);*/
399 var tmp, namespace;
400 if ((command.trailing.charAt(0) === String.fromCharCode(1)) && (command.trailing.charAt(command.trailing.length - 1) === String.fromCharCode(1))) {
401 //CTCP request
402 if (command.trailing.substr(1, 6) === 'ACTION') {
403 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)});
404 } else if (command.trailing.substr(1, 4) === 'KIWI') {
405 tmp = command.trailing.substr(6, command.trailing.length - 2);
406 namespace = tmp.split(' ', 1)[0];
407 this.client.sendIRCCommand('kiwi', {server: this.con_num, namespace: namespace, data: tmp.substr(namespace.length + 1)});
408 } else if (command.trailing.substr(1, 7) === 'VERSION') {
409 this.irc_connection.write('NOTICE ' + command.nick + ' :' + String.fromCharCode(1) + 'VERSION KiwiIRC' + String.fromCharCode(1));
410 } else {
411 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)});
412 }
413 } else {
414 //{nick: msg.nick, ident: msg.ident, hostname: msg.hostname, channel: msg.params.trim(), msg: msg.trailing}
415 this.client.sendIRCCommand('msg', {server: this.con_num, nick: command.nick, ident: command.ident, hostname: command.hostname, channel: command.params[0], msg: command.trailing});
416 }
417 },
418 'ERROR': function (command) {
419 /*command.server = this.con_num;
420 command.command = 'ERROR';
421 this.client.sendIRCCommand(command);*/
422 //websocket.sendClientEvent('irc_error', {error: 'error', reason: msg.trailing});
423 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'error', reason: command.trailing});
424 },
425 ERR_LINKCHANNEL: function (command) {
426 /*command.server = this.con_num;
427 command.command = 'ERR_LINKCHANNEL';
428 this.client.sendIRCCommand(command);*/
429 //websocket.sendClientEvent('channel_redirect', {from: params[1], to: params[2]});
430 this.client.sendIRCCommand('channel_redirect', {server: this.con_num, from: command.params[1], to: command.params[2]});
431 },
432 ERR_NOSUCHNICK: function (command) {
433 /*command.server = this.con_num;
434 command.command = 'ERR_NOSUCHNICK';
435 this.client.sendIRCCommand(command);*/
436 //websocket.sendClientEvent('irc_error', {error: 'no_such_nick', nick: msg.params.split(" ")[1], reason: msg.trailing});
437 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'no_such_nick', nick: command.params[1], reason: command.trailing});
438 },
439 ERR_CANNOTSENDTOCHAN: function (command) {
440 /*command.server = this.con_num;
441 command.command = 'ERR_CANNOTSENDTOCHAN';
442 this.client.sendIRCCommand(command);*/
443 //websocket.sendClientEvent('irc_error', {error: 'cannot_send_to_chan', channel: msg.params.split(" ")[1], reason: msg.trailing});
444 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'cannot_send_to_chan', channel: command.params[1], reason: command.trailing});
445 },
446 ERR_TOOMANYCHANNELS: function (command) {
447 /*command.server = this.con_num;
448 command.command = 'ERR_TOOMANYCHANNELS';
449 this.client.sendIRCCommand(command);*/
450 //websocket.sendClientEvent('irc_error', {error: 'too_many_channels', channel: msg.params.split(" ")[1], reason: msg.trailing});
451 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'too_many_channels', channel: command.params[1], reason: command.trailing});
452 },
453 ERR_USERNOTINCHANNEL: function (command) {
454 /*command.server = this.con_num;
455 command.command = 'ERR_USERNOTINCHANNEL';
456 this.client.sendIRCCommand(command);*/
457 //websocket.sendClientEvent('irc_error', {error: 'user_not_in_channel', nick: params[0], channel: params[1], reason: msg.trainling});
458 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});
459 },
460 ERR_NOTONCHANNEL: function (command) {
461 /*command.server = this.con_num;
462 command.command = 'ERR_NOTONCHANNEL';
463 this.client.sendIRCCommand(command);*/
464 //websocket.sendClientEvent('irc_error', {error: 'not_on_channel', channel: msg.params.split(" ")[1], reason: msg.trailing});
465 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'not_on_channel', channel: command.params[1], reason: command.trailing});
466 },
467 ERR_CHANNELISFULL: function (command) {
468 /*command.server = this.con_num;
469 command.command = 'ERR_CHANNELISFULL';
470 this.client.sendIRCCommand(command);*/
471 //websocket.sendClientEvent('irc_error', {error: 'channel_is_full', channel: msg.params.split(" ")[1], reason: msg.trailing});
472 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'channel_is_full', channel: command.params[1], reason: command.trailing});
473 },
474 ERR_INVITEONLYCHAN: function (command) {
475 /*command.server = this.con_num;
476 command.command = 'ERR_INVITEONLYCHAN';
477 this.client.sendIRCCommand(command);*/
478 //websocket.sendClientEvent('irc_error', {error: 'invite_only_channel', channel: msg.params.split(" ")[1], reason: msg.trailing});
479 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'invite_only_channel', channel: command.params[1], reason: command.trailing});
480 },
481 ERR_BANNEDFROMCHAN: function (command) {
482 /*command.server = this.con_num;
483 command.command = 'ERR_BANNEDFROMCHAN';
484 this.client.sendIRCCommand(command);*/
485 //websocket.sendClientEvent('irc_error', {error: 'banned_from_channel', channel: msg.params.split(" ")[1], reason: msg.trailing});
486 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'banned_from_channel', channel: command.params[1], reason: command.trailing});
487 },
488 ERR_BADCHANNELKEY: function (command) {
489 /*command.server = this.con_num;
490 command.command = 'ERR_BADCHANNELKEY';
491 this.client.sendIRCCommand(command);*/
492 //websocket.sendClientEvent('irc_error', {error: 'bad_channel_key', channel: msg.params.split(" ")[1], reason: msg.trailing});
493 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'bad_channel_key', channel: command.params[1], reason: command.trailing});
494 },
495 ERR_CHANOPRIVSNEEDED: function (command) {
496 /*command.server = this.con_num;
497 command.command = 'ERR_CHANOPRIVSNEEDED';
498 this.client.sendIRCCommand(command);*/
499 //websocket.sendClientEvent('irc_error', {error: 'chanop_privs_needed', channel: msg.params.split(" ")[1], reason: msg.trailing});
500 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'chanop_privs_needed', channel: command.params[1], reason: command.trailing});
501 },
502 ERR_NICKNAMEINUSE: function (command) {
503 /*command.server = this.con_num;
504 command.command = 'ERR_NICKNAMEINUSE';
505 this.client.sendIRCCommand(command);*/
506 //websocket.sendClientEvent('irc_error', {error: 'nickname_in_use', nick: _.last(msg.params.split(" ")), reason: msg.trailing});
507 this.client.sendIRCCommand('irc_error', {server: this.con_num, error: 'nickname_in_use', nick: command.params[1], reason: command.trailing});
508 },
509 ERR_NOTREGISTERED: function (command) {
510 /*command.server = this.con_num;
511 command.command = 'ERR_NOTREGISTERED';
512 this.client.sendIRCCommand(command);*/
513 }
514 };