Commit | Line | Data |
---|---|---|
ce13508b D |
1 | (function () { |
2 | ||
3 | _kiwi.model.Network = Backbone.Model.extend({ | |
4 | defaults: { | |
5 | connection_id: 0, | |
6 | /** | |
7 | * The name of the network | |
8 | * @type String | |
9 | */ | |
10 | name: 'Network', | |
11 | ||
12 | /** | |
13 | * The address (URL) of the network | |
14 | * @type String | |
15 | */ | |
16 | address: '', | |
17 | ||
18 | /** | |
19 | * The current nickname | |
20 | * @type String | |
21 | */ | |
22 | nick: '', | |
23 | ||
24 | /** | |
25 | * The channel prefix for this network | |
26 | * @type String | |
27 | */ | |
28 | channel_prefix: '#', | |
29 | ||
30 | /** | |
31 | * The user prefixes for channel owner/admin/op/voice etc. on this network | |
32 | * @type Array | |
33 | */ | |
34 | user_prefixes: ['~', '&', '@', '+'] | |
35 | }, | |
36 | ||
37 | ||
38 | initialize: function () { | |
39 | this.gateway = _kiwi.global.components.Network(this.get('connection_id')); | |
40 | this.bindGatewayEvents(); | |
41 | ||
c62a9570 | 42 | // Create our panel list (tabs) |
0e546dd4 | 43 | this.panels = new _kiwi.model.PanelList([], this); |
c62a9570 | 44 | //this.panels.network = this; |
0e546dd4 D |
45 | |
46 | // Automatically create a server tab | |
47 | var server_panel = new _kiwi.model.Server({name: 'Server'}); | |
48 | this.panels.add(server_panel); | |
c966123a | 49 | this.panels.server = this.panels.active = server_panel; |
ce13508b D |
50 | }, |
51 | ||
52 | ||
53 | bindGatewayEvents: function () { | |
0e546dd4 | 54 | //this.gateway.on('all', function() {console.log('ALL', this.get('connection_id'), arguments);}); |
ce13508b | 55 | |
4047ee2b | 56 | this.gateway.on('connect', onConnect, this); |
a36b7eb6 | 57 | this.gateway.on('disconnect', onDisconnect, this); |
ce13508b D |
58 | |
59 | this.gateway.on('nick', function(event) { | |
2ffd1291 | 60 | if (event.nick === this.get('nick')) { |
ce13508b D |
61 | this.set('nick', event.newnick); |
62 | } | |
63 | }, this); | |
64 | ||
65 | this.gateway.on('options', onOptions, this); | |
66 | this.gateway.on('motd', onMotd, this); | |
67 | this.gateway.on('join', onJoin, this); | |
68 | this.gateway.on('part', onPart, this); | |
69 | this.gateway.on('quit', onQuit, this); | |
70 | this.gateway.on('kick', onKick, this); | |
71 | this.gateway.on('msg', onMsg, this); | |
e2c54b3e | 72 | this.gateway.on('nick', onNick, this); |
ce13508b D |
73 | this.gateway.on('ctcp_request', onCtcpRequest, this); |
74 | this.gateway.on('ctcp_response', onCtcpResponse, this); | |
75 | this.gateway.on('notice', onNotice, this); | |
76 | this.gateway.on('action', onAction, this); | |
77 | this.gateway.on('topic', onTopic, this); | |
78 | this.gateway.on('topicsetby', onTopicSetBy, this); | |
79 | this.gateway.on('userlist', onUserlist, this); | |
80 | this.gateway.on('userlist_end', onUserlistEnd, this); | |
81 | this.gateway.on('mode', onMode, this); | |
82 | this.gateway.on('whois', onWhois, this); | |
83 | this.gateway.on('away', onAway, this); | |
84 | this.gateway.on('list_start', onListStart, this); | |
f8240e98 | 85 | this.gateway.on('irc_error', onIrcError, this); |
18818abd D |
86 | }, |
87 | ||
88 | ||
89 | /** | |
90 | * Create panels and join the channel | |
91 | * This will not wait for the join event to create a panel. This | |
92 | * increases responsiveness in case of network lag | |
93 | */ | |
94 | createAndJoinChannels: function (channels) { | |
95 | var that = this, | |
96 | panels = []; | |
97 | ||
98 | // Multiple channels may come as comma-delimited | |
99 | if (typeof channels === 'string') { | |
100 | channels = channels.split(','); | |
101 | } | |
102 | ||
103 | $.each(channels, function (index, channel_name_key) { | |
104 | // We may have a channel key so split it off | |
105 | var spli = channel_name_key.trim().split(' '), | |
106 | channel_name = spli[0], | |
107 | channel_key = spli[1] || ''; | |
108 | ||
109 | // Trim any whitespace off the name | |
110 | channel_name = channel_name.trim(); | |
111 | ||
112 | // If not a valid channel name, display a warning | |
113 | if (!_kiwi.app.isChannelName(channel_name)) { | |
114 | that.panels.server.addMsg('', channel_name + ' is not a valid channel name'); | |
115 | _kiwi.app.message.text(channel_name + ' is not a valid channel name', {timeout: 5000}); | |
116 | return; | |
117 | } | |
118 | ||
119 | // Check if we have the panel already. If not, create it | |
120 | channel = that.panels.getByName(channel_name); | |
121 | if (!channel) { | |
122 | channel = new _kiwi.model.Channel({name: channel_name}); | |
123 | that.panels.add(channel); | |
124 | } | |
125 | ||
126 | panels.push(channel); | |
127 | ||
128 | that.gateway.join(channel_name, channel_key); | |
129 | }); | |
130 | ||
131 | return panels; | |
24d27c8c D |
132 | }, |
133 | ||
134 | ||
135 | /** | |
136 | * Join all the open channels we have open | |
137 | * Reconnecting to a network would typically call this. | |
138 | */ | |
139 | rejoinAllChannels: function() { | |
140 | var that = this; | |
141 | ||
142 | this.panels.forEach(function(panel) { | |
143 | if (!panel.isChannel()) | |
144 | return; | |
145 | ||
146 | that.gateway.join(panel.get('name')); | |
147 | }); | |
ce13508b D |
148 | } |
149 | }); | |
150 | ||
151 | ||
a36b7eb6 D |
152 | |
153 | function onDisconnect(event) { | |
154 | $.each(this.panels.models, function (index, panel) { | |
155 | panel.addMsg('', 'Disconnected from the IRC network', 'action quit'); | |
156 | }); | |
157 | } | |
158 | ||
159 | ||
ce13508b | 160 | |
4047ee2b | 161 | function onConnect(event) { |
18818abd D |
162 | var panels, channel_names; |
163 | ||
164 | // Update our nick with what the network gave us | |
4047ee2b D |
165 | this.set('nick', event.nick); |
166 | ||
24d27c8c D |
167 | // If this is a re-connection then we may have some channels to re-join |
168 | this.rejoinAllChannels(); | |
169 | ||
18818abd | 170 | // Auto joining channels |
4047ee2b | 171 | if (this.auto_join && this.auto_join.channel) { |
18818abd D |
172 | panels = this.createAndJoinChannels(this.auto_join.channel + ' ' + (this.auto_join.channel_key || '')); |
173 | ||
174 | // Show the last channel if we have one | |
175 | if (panels) | |
176 | panels[panels.length - 1].view.show(); | |
4047ee2b D |
177 | } |
178 | } | |
179 | ||
180 | ||
181 | ||
ce13508b D |
182 | function onOptions(event) { |
183 | var that = this; | |
184 | ||
185 | $.each(event.options, function (name, value) { | |
186 | switch (name) { | |
187 | case 'CHANTYPES': | |
188 | that.set('channel_prefix', value.join('')); | |
189 | break; | |
190 | case 'NETWORK': | |
191 | that.set('name', value); | |
192 | break; | |
193 | case 'PREFIX': | |
194 | that.set('user_prefixes', value); | |
195 | break; | |
196 | } | |
197 | }); | |
198 | ||
199 | this.set('cap', event.cap); | |
200 | } | |
201 | ||
202 | ||
203 | ||
204 | function onMotd(event) { | |
205 | this.panels.server.addMsg(this.get('name'), event.msg, 'motd'); | |
206 | } | |
207 | ||
208 | ||
209 | ||
210 | function onJoin(event) { | |
211 | var c, members, user; | |
212 | c = this.panels.getByName(event.channel); | |
213 | if (!c) { | |
214 | c = new _kiwi.model.Channel({name: event.channel}); | |
215 | this.panels.add(c); | |
216 | } | |
217 | ||
218 | members = c.get('members'); | |
219 | if (!members) return; | |
220 | ||
221 | user = new _kiwi.model.Member({nick: event.nick, ident: event.ident, hostname: event.hostname}); | |
222 | members.add(user); | |
223 | } | |
224 | ||
225 | ||
226 | ||
227 | function onPart(event) { | |
228 | var channel, members, user, | |
229 | part_options = {}; | |
230 | ||
231 | part_options.type = 'part'; | |
232 | part_options.message = event.message || ''; | |
233 | ||
234 | channel = this.panels.getByName(event.channel); | |
235 | if (!channel) return; | |
236 | ||
237 | // If this is us, close the panel | |
238 | if (event.nick === this.get('nick')) { | |
239 | channel.close(); | |
240 | return; | |
241 | } | |
242 | ||
243 | members = channel.get('members'); | |
244 | if (!members) return; | |
245 | ||
246 | user = members.getByNick(event.nick); | |
247 | if (!user) return; | |
248 | ||
249 | members.remove(user, part_options); | |
250 | } | |
251 | ||
252 | ||
253 | ||
254 | function onQuit(event) { | |
255 | var member, members, | |
256 | quit_options = {}; | |
257 | ||
258 | quit_options.type = 'quit'; | |
259 | quit_options.message = event.message || ''; | |
260 | ||
261 | $.each(this.panels.models, function (index, panel) { | |
262 | if (!panel.isChannel()) return; | |
263 | ||
264 | member = panel.get('members').getByNick(event.nick); | |
265 | if (member) { | |
266 | panel.get('members').remove(member, quit_options); | |
267 | } | |
268 | }); | |
269 | } | |
270 | ||
271 | ||
272 | ||
273 | function onKick(event) { | |
274 | var channel, members, user, | |
275 | part_options = {}; | |
276 | ||
277 | part_options.type = 'kick'; | |
278 | part_options.by = event.nick; | |
279 | part_options.message = event.message || ''; | |
280 | ||
281 | channel = this.panels.getByName(event.channel); | |
282 | if (!channel) return; | |
283 | ||
284 | members = channel.get('members'); | |
285 | if (!members) return; | |
286 | ||
287 | user = members.getByNick(event.kicked); | |
288 | if (!user) return; | |
289 | ||
290 | members.remove(user, part_options); | |
291 | ||
292 | if (event.kicked === this.get('nick')) { | |
293 | members.reset([]); | |
294 | } | |
295 | } | |
296 | ||
297 | ||
298 | ||
299 | function onMsg(event) { | |
300 | var panel, | |
301 | is_pm = (event.channel == this.get('nick')); | |
302 | ||
303 | // An ignored user? don't do anything with it | |
304 | if (_kiwi.gateway.isNickIgnored(event.nick)) { | |
305 | return; | |
306 | } | |
307 | ||
308 | if (is_pm) { | |
309 | // If a panel isn't found for this PM, create one | |
310 | panel = this.panels.getByName(event.nick); | |
311 | if (!panel) { | |
312 | panel = new _kiwi.model.Query({name: event.nick}); | |
313 | this.panels.add(panel); | |
314 | } | |
315 | ||
316 | } else { | |
317 | // If a panel isn't found for this channel, reroute to the | |
318 | // server panel | |
319 | panel = this.panels.getByName(event.channel); | |
320 | if (!panel) { | |
321 | panel = this.panels.server; | |
322 | } | |
323 | } | |
324 | ||
325 | panel.addMsg(event.nick, event.msg); | |
326 | } | |
327 | ||
328 | ||
329 | ||
e2c54b3e D |
330 | function onNick(event) { |
331 | var member; | |
332 | ||
333 | $.each(this.panels.models, function (index, panel) { | |
334 | if (panel.get('name') == event.nick) | |
335 | panel.set('name', event.newnick); | |
336 | ||
337 | if (!panel.isChannel()) return; | |
338 | ||
339 | member = panel.get('members').getByNick(event.nick); | |
340 | if (member) { | |
341 | member.set('nick', event.newnick); | |
342 | panel.addMsg('', '== ' + event.nick + ' is now known as ' + event.newnick, 'action nick'); | |
343 | } | |
344 | }); | |
345 | } | |
346 | ||
347 | ||
348 | ||
ce13508b D |
349 | function onCtcpRequest(event) { |
350 | // An ignored user? don't do anything with it | |
351 | if (_kiwi.gateway.isNickIgnored(event.nick)) { | |
352 | return; | |
353 | } | |
354 | ||
355 | // Reply to a TIME ctcp | |
356 | if (event.msg.toUpperCase() === 'TIME') { | |
e7d65587 | 357 | this.gateway.ctcp(null, false, event.type, event.nick, (new Date()).toString()); |
ce13508b D |
358 | } |
359 | } | |
360 | ||
361 | ||
362 | ||
363 | function onCtcpResponse(event) { | |
364 | // An ignored user? don't do anything with it | |
365 | if (_kiwi.gateway.isNickIgnored(event.nick)) { | |
366 | return; | |
367 | } | |
368 | ||
369 | this.panels.server.addMsg('[' + event.nick + ']', 'CTCP ' + event.msg); | |
370 | } | |
371 | ||
372 | ||
373 | ||
374 | function onNotice(event) { | |
375 | var panel; | |
376 | ||
377 | // An ignored user? don't do anything with it | |
378 | if (event.nick && _kiwi.gateway.isNickIgnored(event.nick)) { | |
379 | return; | |
380 | } | |
381 | ||
382 | // Find a panel for the destination(channel) or who its from | |
383 | panel = this.panels.getByName(event.target) || this.panels.getByName(event.nick); | |
384 | if (!panel) { | |
385 | panel = this.panels.server; | |
386 | } | |
387 | ||
388 | panel.addMsg('[' + (event.nick||'') + ']', event.msg); | |
2119ce7a D |
389 | |
390 | // Show this notice to the active panel if it didn't have a set target | |
391 | if (panel === this.panels.server) | |
392 | _kiwi.app.panels().active.addMsg('[' + (event.nick||'') + ']', event.msg); | |
ce13508b D |
393 | } |
394 | ||
395 | ||
396 | ||
397 | function onAction(event) { | |
398 | var panel, | |
399 | is_pm = (event.channel == this.get('nick')); | |
400 | ||
401 | // An ignored user? don't do anything with it | |
402 | if (_kiwi.gateway.isNickIgnored(event.nick)) { | |
403 | return; | |
404 | } | |
405 | ||
406 | if (is_pm) { | |
407 | // If a panel isn't found for this PM, create one | |
408 | panel = this.panels.getByName(event.nick); | |
409 | if (!panel) { | |
410 | panel = new _kiwi.model.Channel({name: event.nick}); | |
411 | this.panels.add(panel); | |
412 | } | |
413 | ||
414 | } else { | |
415 | // If a panel isn't found for this channel, reroute to the | |
416 | // server panel | |
417 | panel = this.panels.getByName(event.channel); | |
418 | if (!panel) { | |
419 | panel = this.panels.server; | |
420 | } | |
421 | } | |
422 | ||
423 | panel.addMsg('', '* ' + event.nick + ' ' + event.msg, 'action'); | |
424 | } | |
425 | ||
426 | ||
427 | ||
428 | function onTopic(event) { | |
429 | var c; | |
430 | c = this.panels.getByName(event.channel); | |
431 | if (!c) return; | |
432 | ||
433 | // Set the channels topic | |
434 | c.set('topic', event.topic); | |
435 | ||
436 | // If this is the active channel, update the topic bar too | |
437 | if (c.get('name') === this.panels.active.get('name')) { | |
438 | _kiwi.app.topicbar.setCurrentTopic(event.topic); | |
439 | } | |
440 | } | |
441 | ||
442 | ||
443 | ||
444 | function onTopicSetBy(event) { | |
445 | var c, when; | |
446 | c = this.panels.getByName(event.channel); | |
447 | if (!c) return; | |
448 | ||
449 | when = formatDate(new Date(event.when * 1000)); | |
450 | c.addMsg('', 'Topic set by ' + event.nick + ' at ' + when, 'topic'); | |
451 | } | |
452 | ||
453 | ||
454 | ||
455 | function onUserlist(event) { | |
456 | var channel; | |
457 | channel = this.panels.getByName(event.channel); | |
458 | ||
459 | // If we didn't find a channel for this, may aswell leave | |
460 | if (!channel) return; | |
461 | ||
462 | channel.temp_userlist = channel.temp_userlist || []; | |
463 | _.each(event.users, function (item) { | |
464 | var user = new _kiwi.model.Member({nick: item.nick, modes: item.modes}); | |
465 | channel.temp_userlist.push(user); | |
466 | }); | |
467 | } | |
468 | ||
469 | ||
470 | ||
471 | function onUserlistEnd(event) { | |
472 | var channel; | |
473 | channel = this.panels.getByName(event.channel); | |
474 | ||
475 | // If we didn't find a channel for this, may aswell leave | |
476 | if (!channel) return; | |
477 | ||
478 | // Update the members list with the new list | |
479 | channel.get('members').reset(channel.temp_userlist || []); | |
480 | ||
481 | // Clear the temporary userlist | |
482 | delete channel.temp_userlist; | |
483 | } | |
484 | ||
485 | ||
486 | ||
487 | function onMode(event) { | |
488 | var channel, i, prefixes, members, member, find_prefix; | |
489 | ||
490 | // Build a nicely formatted string to be displayed to a regular human | |
491 | function friendlyModeString (event_modes, alt_target) { | |
492 | var modes = {}, return_string; | |
493 | ||
494 | // If no default given, use the main event info | |
495 | if (!event_modes) { | |
496 | event_modes = event.modes; | |
497 | alt_target = event.target; | |
498 | } | |
499 | ||
500 | // Reformat the mode object to make it easier to work with | |
501 | _.each(event_modes, function (mode){ | |
502 | var param = mode.param || alt_target || ''; | |
503 | ||
504 | // Make sure we have some modes for this param | |
505 | if (!modes[param]) { | |
506 | modes[param] = {'+':'', '-':''}; | |
507 | } | |
508 | ||
509 | modes[param][mode.mode[0]] += mode.mode.substr(1); | |
510 | }); | |
511 | ||
512 | // Put the string together from each mode | |
513 | return_string = []; | |
514 | _.each(modes, function (modeset, param) { | |
515 | var str = ''; | |
516 | if (modeset['+']) str += '+' + modeset['+']; | |
517 | if (modeset['-']) str += '-' + modeset['-']; | |
518 | return_string.push(str + ' ' + param); | |
519 | }); | |
520 | return_string = return_string.join(', '); | |
521 | ||
522 | return return_string; | |
523 | } | |
524 | ||
525 | ||
526 | channel = this.panels.getByName(event.target); | |
527 | if (channel) { | |
528 | prefixes = this.get('user_prefixes'); | |
529 | find_prefix = function (p) { | |
530 | return event.modes[i].mode[1] === p.mode; | |
531 | }; | |
532 | for (i = 0; i < event.modes.length; i++) { | |
533 | if (_.any(prefixes, find_prefix)) { | |
534 | if (!members) { | |
535 | members = channel.get('members'); | |
536 | } | |
537 | member = members.getByNick(event.modes[i].param); | |
538 | if (!member) { | |
539 | console.log('MODE command recieved for unknown member %s on channel %s', event.modes[i].param, event.target); | |
540 | return; | |
541 | } else { | |
542 | if (event.modes[i].mode[0] === '+') { | |
543 | member.addMode(event.modes[i].mode[1]); | |
544 | } else if (event.modes[i].mode[0] === '-') { | |
545 | member.removeMode(event.modes[i].mode[1]); | |
546 | } | |
547 | members.sort(); | |
548 | //channel.addMsg('', '== ' + event.nick + ' set mode ' + event.modes[i].mode + ' ' + event.modes[i].param, 'action mode'); | |
549 | } | |
550 | } else { | |
551 | // Channel mode being set | |
552 | // TODO: Store this somewhere? | |
553 | //channel.addMsg('', 'CHANNEL === ' + event.nick + ' set mode ' + event.modes[i].mode + ' on ' + event.target, 'action mode'); | |
554 | } | |
555 | } | |
556 | ||
557 | channel.addMsg('', '== ' + event.nick + ' sets mode ' + friendlyModeString(), 'action mode'); | |
558 | } else { | |
559 | // This is probably a mode being set on us. | |
560 | if (event.target.toLowerCase() === this.get("nick").toLowerCase()) { | |
561 | this.panels.server.addMsg('', '== ' + event.nick + ' set mode ' + friendlyModeString(), 'action mode'); | |
562 | } else { | |
563 | console.log('MODE command recieved for unknown target %s: ', event.target, event); | |
564 | } | |
565 | } | |
566 | } | |
567 | ||
568 | ||
569 | ||
570 | function onWhois(event) { | |
571 | var logon_date, idle_time = '', panel; | |
572 | ||
573 | if (event.end) | |
574 | return; | |
575 | ||
576 | if (typeof event.idle !== 'undefined') { | |
577 | idle_time = secondsToTime(parseInt(event.idle, 10)); | |
578 | idle_time = idle_time.h.toString().lpad(2, "0") + ':' + idle_time.m.toString().lpad(2, "0") + ':' + idle_time.s.toString().lpad(2, "0"); | |
579 | } | |
580 | ||
e7d65587 | 581 | panel = _kiwi.app.panels().active; |
ce13508b D |
582 | if (event.ident) { |
583 | panel.addMsg(event.nick, event.nick + ' [' + event.nick + '!' + event.ident + '@' + event.host + '] * ' + event.msg, 'whois'); | |
584 | } else if (event.chans) { | |
585 | panel.addMsg(event.nick, 'Channels: ' + event.chans, 'whois'); | |
586 | } else if (event.irc_server) { | |
587 | panel.addMsg(event.nick, 'Connected to server: ' + event.irc_server, 'whois'); | |
588 | } else if (event.msg) { | |
589 | panel.addMsg(event.nick, event.msg, 'whois'); | |
590 | } else if (event.logon) { | |
591 | logon_date = new Date(); | |
592 | logon_date.setTime(event.logon * 1000); | |
593 | logon_date = formatDate(logon_date); | |
594 | ||
595 | panel.addMsg(event.nick, 'idle for ' + idle_time + ', signed on ' + logon_date, 'whois'); | |
f701d5ba D |
596 | } else if (event.away_reason) { |
597 | panel.addMsg(event.nick, 'Away: ' + event.away_reason, 'whois'); | |
ce13508b D |
598 | } else { |
599 | panel.addMsg(event.nick, 'idle for ' + idle_time, 'whois'); | |
600 | } | |
601 | } | |
602 | ||
603 | ||
604 | ||
605 | function onAway(event) { | |
606 | $.each(this.panels.models, function (index, panel) { | |
607 | if (!panel.isChannel()) return; | |
608 | ||
609 | member = panel.get('members').getByNick(event.nick); | |
610 | if (member) { | |
611 | member.set('away', !(!event.trailing)); | |
612 | } | |
613 | }); | |
614 | } | |
615 | ||
616 | ||
617 | ||
618 | function onListStart(event) { | |
b24da6ba D |
619 | var chanlist = _kiwi.model.Applet.loadOnce('kiwi_chanlist'); |
620 | chanlist.view.show(); | |
ce13508b D |
621 | } |
622 | ||
623 | ||
624 | ||
625 | function onIrcError(event) { | |
626 | var panel, tmp; | |
627 | ||
f8240e98 | 628 | if (event.channel !== undefined && !(panel = this.panels.getByName(event.channel))) { |
ce13508b D |
629 | panel = this.panels.server; |
630 | } | |
631 | ||
632 | switch (event.error) { | |
633 | case 'banned_from_channel': | |
634 | panel.addMsg(' ', '== You are banned from ' + event.channel + '. ' + event.reason, 'status'); | |
635 | _kiwi.app.message.text('You are banned from ' + event.channel + '. ' + event.reason); | |
636 | break; | |
637 | case 'bad_channel_key': | |
638 | panel.addMsg(' ', '== Bad channel key for ' + event.channel, 'status'); | |
639 | _kiwi.app.message.text('Bad channel key or password for ' + event.channel); | |
640 | break; | |
641 | case 'invite_only_channel': | |
642 | panel.addMsg(' ', '== ' + event.channel + ' is invite only.', 'status'); | |
643 | _kiwi.app.message.text(event.channel + ' is invite only'); | |
644 | break; | |
645 | case 'channel_is_full': | |
646 | panel.addMsg(' ', '== ' + event.channel + ' is full.', 'status'); | |
647 | _kiwi.app.message.text(event.channel + ' is full'); | |
648 | break; | |
649 | case 'chanop_privs_needed': | |
650 | panel.addMsg(' ', '== ' + event.reason, 'status'); | |
651 | _kiwi.app.message.text(event.reason + ' (' + event.channel + ')'); | |
652 | break; | |
653 | case 'no_such_nick': | |
654 | tmp = this.panels.getByName(event.nick); | |
655 | if (tmp) { | |
656 | tmp.addMsg(' ', '== ' + event.nick + ': ' + event.reason, 'status'); | |
657 | } else { | |
658 | this.panels.server.addMsg(' ', '== ' + event.nick + ': ' + event.reason, 'status'); | |
659 | } | |
660 | break; | |
661 | case 'nickname_in_use': | |
662 | this.panels.server.addMsg(' ', '== The nickname ' + event.nick + ' is already in use. Please select a new nickname', 'status'); | |
663 | if (this.panels.server !== thia.panels.active) { | |
664 | _kiwi.app.message.text('The nickname "' + event.nick + '" is already in use. Please select a new nickname'); | |
665 | } | |
666 | ||
667 | // Only show the nickchange component if the controlbox is open | |
668 | if (that.controlbox.$el.css('display') !== 'none') { | |
669 | (new _kiwi.view.NickChangeBox()).render(); | |
670 | } | |
671 | ||
672 | break; | |
673 | ||
674 | case 'password_mismatch': | |
675 | this.panels.server.addMsg(' ', '== Incorrect password given', 'status'); | |
676 | break; | |
677 | default: | |
678 | // We don't know what data contains, so don't do anything with it. | |
679 | //_kiwi.front.tabviews.server.addMsg(null, ' ', '== ' + data, 'status'); | |
680 | } | |
681 | } | |
682 | } | |
683 | ||
684 | )(); |