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