f4f46f21537ad5c51daa4d1d63b5902e415afdf0
3 _kiwi
.model
.Network
= Backbone
.Model
.extend({
7 * The name of the network
13 * The address (URL) of the network
19 * The port for the network
25 * If this network uses SSL
31 * The password to connect to this network
37 * The current nickname
43 * The channel prefix for this network
49 * The user prefixes for channel owner/admin/op/voice etc. on this network
53 {symbol
: '~', mode
: 'q'},
54 {symbol
: '&', mode
: 'a'},
55 {symbol
: '@', mode
: 'o'},
56 {symbol
: '%', mode
: 'h'},
57 {symbol
: '+', mode
: 'v'}
61 * List of nicks we are ignoring
68 initialize: function () {
69 // If we already have a connection, bind our events
70 if (typeof this.get('connection_id') !== 'undefined') {
71 this.gateway
= _kiwi
.global
.components
.Network(this.get('connection_id'));
72 this.bindGatewayEvents();
75 // Create our panel list (tabs)
76 this.panels
= new _kiwi
.model
.PanelList([], this);
77 //this.panels.network = this;
79 // Automatically create a server tab
80 var server_panel
= new _kiwi
.model
.Server({name
: 'Server', network
: this});
81 this.panels
.add(server_panel
);
82 this.panels
.server
= this.panels
.active
= server_panel
;
86 reconnect: function(callback_fn
) {
89 nick
: this.get('nick'),
90 host
: this.get('address'),
91 port
: this.get('port'),
93 password
: this.get('password')
96 _kiwi
.gateway
.makeIrcConnection(server_info
, function(err
, connection_id
) {
98 that
.gateway
.dispose();
100 that
.set('connection_id', connection_id
);
101 that
.gateway
= _kiwi
.global
.components
.Network(that
.get('connection_id'));
102 that
.bindGatewayEvents();
104 // Reset each of the panels connection ID
105 that
.panels
.forEach(function(panel
) {
106 panel
.set('connection_id', connection_id
);
109 callback_fn
&& callback_fn(err
);
112 console
.log("_kiwi.gateway.socket.on('error')", {reason
: err
});
113 callback_fn
&& callback_fn(err
);
119 bindGatewayEvents: function () {
120 //this.gateway.on('all', function() {console.log('ALL', this.get('connection_id'), arguments);});
122 this.gateway
.on('connect', onConnect
, this);
123 this.gateway
.on('disconnect', onDisconnect
, this);
125 this.gateway
.on('nick', function(event
) {
126 if (event
.nick
=== this.get('nick')) {
127 this.set('nick', event
.newnick
);
131 this.gateway
.on('options', onOptions
, this);
132 this.gateway
.on('motd', onMotd
, this);
133 this.gateway
.on('channel:join', onJoin
, this);
134 this.gateway
.on('channel:part', onPart
, this);
135 this.gateway
.on('channel:kick', onKick
, this);
136 this.gateway
.on('quit', onQuit
, this);
137 this.gateway
.on('message', onMessage
, this);
138 this.gateway
.on('nick', onNick
, this);
139 this.gateway
.on('ctcp_request', onCtcpRequest
, this);
140 this.gateway
.on('ctcp_response', onCtcpResponse
, this);
141 this.gateway
.on('topic', onTopic
, this);
142 this.gateway
.on('topicsetby', onTopicSetBy
, this);
143 this.gateway
.on('userlist', onUserlist
, this);
144 this.gateway
.on('userlist_end', onUserlistEnd
, this);
145 this.gateway
.on('banlist', onBanlist
, this);
146 this.gateway
.on('mode', onMode
, this);
147 this.gateway
.on('whois', onWhois
, this);
148 this.gateway
.on('whowas', onWhowas
, this);
149 this.gateway
.on('away', onAway
, this);
150 this.gateway
.on('list_start', onListStart
, this);
151 this.gateway
.on('irc_error', onIrcError
, this);
152 this.gateway
.on('unknown_command', onUnknownCommand
, this);
153 this.gateway
.on('channel_info', onChannelInfo
, this);
154 this.gateway
.on('wallops', onWallops
, this);
159 * Create panels and join the channel
160 * This will not wait for the join event to create a panel. This
161 * increases responsiveness in case of network lag
163 createAndJoinChannels: function (channels
) {
167 // Multiple channels may come as comma-delimited
168 if (typeof channels
=== 'string') {
169 channels
= channels
.split(',');
172 $.each(channels
, function (index
, channel_name_key
) {
173 // We may have a channel key so split it off
174 var spli
= channel_name_key
.trim().split(' '),
175 channel_name
= spli
[0],
176 channel_key
= spli
[1] || '';
178 // Trim any whitespace off the name
179 channel_name
= channel_name
.trim();
181 // Add channel_prefix in front of the first channel if missing
182 if (that
.get('channel_prefix').indexOf(channel_name
[0]) === -1) {
183 // Could be many prefixes but '#' is highly likely the required one
184 channel_name
= '#' + channel_name
;
187 // Check if we have the panel already. If not, create it
188 channel
= that
.panels
.getByName(channel_name
);
190 channel
= new _kiwi
.model
.Channel({name
: channel_name
, network
: that
});
191 that
.panels
.add(channel
);
194 panels
.push(channel
);
196 that
.gateway
.join(channel_name
, channel_key
);
205 * Join all the open channels we have open
206 * Reconnecting to a network would typically call this.
208 rejoinAllChannels: function() {
211 this.panels
.forEach(function(panel
) {
212 if (!panel
.isChannel())
215 that
.gateway
.join(panel
.get('name'));
219 isChannelName: function (channel_name
) {
220 var channel_prefix
= this.get('channel_prefix');
222 if (!channel_name
|| !channel_name
.length
) return false;
223 return (channel_prefix
.indexOf(channel_name
[0]) > -1);
226 // Check a nick alongside our ignore list
227 isNickIgnored: function (nick
) {
228 var idx
, list
= this.get('ignore_list');
231 for (idx
= 0; idx
< list
.length
; idx
++) {
232 pattern
= list
[idx
].replace(/([.+^$[\]\\(){}|-])/g, "\\$1")
236 regex
= new RegExp(pattern
, 'i');
237 if (regex
.test(nick
)) return true;
243 // Create a new query panel
244 createQuery: function (nick
) {
248 // Check if we have the panel already. If not, create it
249 query
= that
.panels
.getByName(nick
);
251 query
= new _kiwi
.model
.Query({name
: nick
});
252 that
.panels
.add(query
);
255 // In all cases, show the demanded query
264 function onDisconnect(event
) {
265 $.each(this.panels
.models
, function (index
, panel
) {
266 if (!panel
.isApplet()) {
267 panel
.addMsg('', styleText('network_disconnected', {text
: translateText('client_models_network_disconnected', [])}), 'action quit');
274 function onConnect(event
) {
275 var panels
, channel_names
;
277 // Update our nick with what the network gave us
278 this.set('nick', event
.nick
);
280 // If this is a re-connection then we may have some channels to re-join
281 this.rejoinAllChannels();
283 // Auto joining channels
284 if (this.auto_join
&& this.auto_join
.channel
) {
285 panels
= this.createAndJoinChannels(this.auto_join
.channel
+ ' ' + (this.auto_join
.key
|| ''));
287 // Show the last channel if we have one
289 panels
[panels
.length
- 1].view
.show();
291 delete this.auto_join
;
297 function onOptions(event
) {
300 $.each(event
.options
, function (name
, value
) {
303 that
.set('channel_prefix', value
.join(''));
306 that
.set('name', value
);
309 that
.set('user_prefixes', value
);
314 this.set('cap', event
.cap
);
319 function onMotd(event
) {
320 this.panels
.server
.addMsg(this.get('name'), styleText('motd', {text
: event
.msg
}), 'motd');
325 function onJoin(event
) {
326 var c
, members
, user
;
327 c
= this.panels
.getByName(event
.channel
);
329 c
= new _kiwi
.model
.Channel({name
: event
.channel
, network
: this});
333 members
= c
.get('members');
334 if (!members
) return;
336 // Do we already have this member?
337 if (members
.getByNick(event
.nick
)) {
341 user
= new _kiwi
.model
.Member({
344 hostname
: event
.hostname
,
345 user_prefixes
: this.get('user_prefixes')
348 _kiwi
.global
.events
.emit('channel:join', {channel
: event
.channel
, user
: user
})
350 members
.add(user
, {kiwi
: event
});
356 function onPart(event
) {
357 var channel
, members
, user
,
360 part_options
.type
= 'part';
361 part_options
.message
= event
.message
|| '';
362 part_options
.time
= event
.time
;
364 channel
= this.panels
.getByName(event
.channel
);
365 if (!channel
) return;
367 // If this is us, close the panel
368 if (event
.nick
=== this.get('nick')) {
373 members
= channel
.get('members');
374 if (!members
) return;
376 user
= members
.getByNick(event
.nick
);
379 _kiwi
.global
.events
.emit('channel:leave', {channel
: event
.channel
, user
: user
, type
: 'part', message
: part_options
.message
})
381 members
.remove(user
, {kiwi
: part_options
});
387 function onQuit(event
) {
391 quit_options
.type
= 'quit';
392 quit_options
.message
= event
.message
|| '';
393 quit_options
.time
= event
.time
;
395 $.each(this.panels
.models
, function (index
, panel
) {
396 // Let any query panels know they quit
397 if (panel
.isQuery() && panel
.get('name').toLowerCase() === event
.nick
.toLowerCase()) {
398 panel
.addMsg(' ', styleText('channel_quit', {
400 text
: translateText('client_models_channel_quit', [quit_options
.message
])
401 }), 'action quit', {time
: quit_options
.time
});
404 // Remove the nick from any channels
405 if (panel
.isChannel()) {
406 member
= panel
.get('members').getByNick(event
.nick
);
408 _kiwi
.global
.events
.emit('channel:leave', {channel
: panel
.get('name'), user
: member
, type
: 'quit', message
: part_options
.message
})
410 panel
.get('members').remove(member
, {kiwi
: quit_options
});
419 function onKick(event
) {
420 var channel
, members
, user
,
423 part_options
.type
= 'kick';
424 part_options
.by
= event
.nick
;
425 part_options
.message
= event
.message
|| '';
426 part_options
.current_user_kicked
= (event
.kicked
== this.get('nick'));
427 part_options
.current_user_initiated
= (event
.nick
== this.get('nick'));
428 part_options
.time
= event
.time
;
430 channel
= this.panels
.getByName(event
.channel
);
431 if (!channel
) return;
433 members
= channel
.get('members');
434 if (!members
) return;
436 user
= members
.getByNick(event
.kicked
);
440 _kiwi
.global
.events
.emit('channel:leave', {channel
: event
.channel
, user
: user
, type
: 'kick', message
: part_options
.message
})
442 members
.remove(user
, {kiwi
: part_options
});
444 if (part_options
.current_user_kicked
) {
452 function onMessage(event
) {
453 _kiwi
.global
.events
.emit('message:new', {network
: this, message
: event
})
454 .then(_
.bind(function() {
456 is_pm
= ((event
.target
|| '').toLowerCase() == this.get('nick').toLowerCase());
458 // An ignored user? don't do anything with it
459 if (this.isNickIgnored(event
.nick
)) {
463 if (event
.type
== 'notice') {
464 if (event
.from_server
) {
465 panel
= this.panels
.server
;
468 panel
= this.panels
.getByName(event
.target
) || this.panels
.getByName(event
.nick
);
470 // Forward ChanServ messages to its associated channel
471 if (event
.nick
&& event
.nick
.toLowerCase() == 'chanserv' && event
.msg
.charAt(0) == '[') {
472 channel_name
= /\[([^ \]]+)\]/gi.exec(event
.msg
);
473 if (channel_name
&& channel_name
[1]) {
474 channel_name
= channel_name
[1];
476 panel
= this.panels
.getByName(channel_name
);
483 panel
= this.panels
.server
;
487 // If a panel isn't found for this PM, create one
488 panel
= this.panels
.getByName(event
.nick
);
490 panel
= new _kiwi
.model
.Query({name
: event
.nick
, network
: this});
491 this.panels
.add(panel
);
495 // If a panel isn't found for this target, reroute to the
497 panel
= this.panels
.getByName(event
.target
);
499 panel
= this.panels
.server
;
505 panel
.addMsg(event
.nick
, styleText('privmsg', {text
: event
.msg
}), 'privmsg', {time
: event
.time
});
509 panel
.addMsg('', styleText('action', {nick
: event
.nick
, text
: event
.msg
}), 'action', {time
: event
.time
});
513 panel
.addMsg('[' + (event
.nick
||'') + ']', styleText('notice', {text
: event
.msg
}), 'notice', {time
: event
.time
});
515 // Show this notice to the active panel if it didn't have a set target, but only in an active channel or query window
516 active_panel
= _kiwi
.app
.panels().active
;
518 if (!event
.from_server
&& panel
=== this.panels
.server
&& active_panel
!== this.panels
.server
) {
519 if (active_panel
.get('network') === this && (active_panel
.isChannel() || active_panel
.isQuery()))
520 active_panel
.addMsg('[' + (event
.nick
||'') + ']', styleText('notice', {text
: event
.msg
}), 'notice', {time
: event
.time
});
529 function onNick(event
) {
532 $.each(this.panels
.models
, function (index
, panel
) {
533 if (panel
.get('name') == event
.nick
)
534 panel
.set('name', event
.newnick
);
536 if (!panel
.isChannel()) return;
538 member
= panel
.get('members').getByNick(event
.nick
);
540 member
.set('nick', event
.newnick
);
541 panel
.addMsg('', styleText('nick_changed', {nick
: event
.nick
, text
: translateText('client_models_network_nickname_changed', [event
.newnick
]), channel
: name
}), 'action nick', {time
: event
.time
});
548 function onCtcpRequest(event
) {
549 // An ignored user? don't do anything with it
550 if (this.isNickIgnored(event
.nick
)) {
554 // Reply to a TIME ctcp
555 if (event
.msg
.toUpperCase() === 'TIME') {
556 this.gateway
.ctcpResponse(event
.type
, event
.nick
, (new Date()).toString());
557 } else if(event
.type
.toUpperCase() === 'PING') { // CTCP PING reply
558 this.gateway
.ctcpResponse(event
.type
, event
.nick
, event
.msg
.substr(5));
564 function onCtcpResponse(event
) {
565 // An ignored user? don't do anything with it
566 if (this.isNickIgnored(event
.nick
)) {
570 this.panels
.server
.addMsg('[' + event
.nick
+ ']', styleText('ctcp', {text
: event
.msg
}), 'ctcp', {time
: event
.time
});
575 function onTopic(event
) {
577 c
= this.panels
.getByName(event
.channel
);
580 // Set the channels topic
581 c
.set('topic', event
.topic
);
583 // If this is the active channel, update the topic bar too
584 if (c
.get('name') === this.panels
.active
.get('name')) {
585 _kiwi
.app
.topicbar
.setCurrentTopic(event
.topic
);
591 function onTopicSetBy(event
) {
593 c
= this.panels
.getByName(event
.channel
);
596 when
= new Date(event
.when
* 1000);
597 c
.set('topic_set_by', {nick
: event
.nick
, when
: when
});
602 function onChannelInfo(event
) {
603 var channel
= this.panels
.getByName(event
.channel
);
604 if (!channel
) return;
607 channel
.set('info_url', event
.url
);
608 } else if (event
.modes
) {
609 channel
.set('info_modes', event
.modes
);
615 function onUserlist(event
) {
617 channel
= this.panels
.getByName(event
.channel
);
619 // If we didn't find a channel for this, may aswell leave
620 if (!channel
) return;
622 channel
.temp_userlist
= channel
.temp_userlist
|| [];
623 _
.each(event
.users
, function (item
) {
624 var user
= new _kiwi
.model
.Member({
627 user_prefixes
: that
.get('user_prefixes')
629 channel
.temp_userlist
.push(user
);
635 function onUserlistEnd(event
) {
637 channel
= this.panels
.getByName(event
.channel
);
639 // If we didn't find a channel for this, may aswell leave
640 if (!channel
) return;
642 // Update the members list with the new list
643 channel
.get('members').reset(channel
.temp_userlist
|| []);
645 // Clear the temporary userlist
646 delete channel
.temp_userlist
;
651 function onBanlist(event
) {
652 var channel
= this.panels
.getByName(event
.channel
);
656 channel
.set('banlist', event
.bans
|| []);
661 function onMode(event
) {
662 var channel
, i
, prefixes
, members
, member
, find_prefix
,
663 request_updated_banlist
= false;
665 // Build a nicely formatted string to be displayed to a regular human
666 function friendlyModeString (event_modes
, alt_target
) {
667 var modes
= {}, return_string
;
669 // If no default given, use the main event info
671 event_modes
= event
.modes
;
672 alt_target
= event
.target
;
675 // Reformat the mode object to make it easier to work with
676 _
.each(event_modes
, function (mode
){
677 var param
= mode
.param
|| alt_target
|| '';
679 // Make sure we have some modes for this param
681 modes
[param
] = {'+':'', '-':''};
684 modes
[param
][mode
.mode
[0]] += mode
.mode
.substr(1);
687 // Put the string together from each mode
689 _
.each(modes
, function (modeset
, param
) {
691 if (modeset
['+']) str
+= '+' + modeset
['+'];
692 if (modeset
['-']) str
+= '-' + modeset
['-'];
693 return_string
.push(str
+ ' ' + param
);
695 return_string
= return_string
.join(', ');
697 return return_string
;
701 channel
= this.panels
.getByName(event
.target
);
703 prefixes
= this.get('user_prefixes');
704 find_prefix = function (p
) {
705 return event
.modes
[i
].mode
[1] === p
.mode
;
707 for (i
= 0; i
< event
.modes
.length
; i
++) {
708 if (_
.any(prefixes
, find_prefix
)) {
710 members
= channel
.get('members');
712 member
= members
.getByNick(event
.modes
[i
].param
);
714 console
.log('MODE command recieved for unknown member %s on channel %s', event
.modes
[i
].param
, event
.target
);
717 if (event
.modes
[i
].mode
[0] === '+') {
718 member
.addMode(event
.modes
[i
].mode
[1]);
719 } else if (event
.modes
[i
].mode
[0] === '-') {
720 member
.removeMode(event
.modes
[i
].mode
[1]);
725 // Channel mode being set
726 // TODO: Store this somewhere?
727 //channel.addMsg('', 'CHANNEL === ' + event.nick + ' set mode ' + event.modes[i].mode + ' on ' + event.target, 'action mode');
730 // TODO: Be smart, remove this specific ban from the banlist rather than request a whole banlist
731 if (event
.modes
[i
].mode
[1] == 'b')
732 request_updated_banlist
= true;
735 channel
.addMsg('', styleText('mode', {nick
: event
.nick
, text
: translateText('client_models_network_mode', [friendlyModeString()]), channel
: event
.target
}), 'action mode', {time
: event
.time
});
737 // TODO: Be smart, remove the specific ban from the banlist rather than request a whole banlist
738 if (request_updated_banlist
)
739 this.gateway
.raw('MODE ' + channel
.get('name') + ' +b');
742 // This is probably a mode being set on us.
743 if (event
.target
.toLowerCase() === this.get("nick").toLowerCase()) {
744 this.panels
.server
.addMsg('', styleText('selfmode', {nick
: event
.nick
, text
: translateText('client_models_network_mode', [friendlyModeString()]), channel
: event
.target
}), 'action mode');
746 console
.log('MODE command recieved for unknown target %s: ', event
.target
, event
);
753 function onWhois(event
) {
754 var logon_date
, idle_time
= '', panel
;
759 if (typeof event
.idle
!== 'undefined') {
760 idle_time
= secondsToTime(parseInt(event
.idle
, 10));
761 idle_time
= idle_time
.h
.toString().lpad(2, "0") + ':' + idle_time
.m
.toString().lpad(2, "0") + ':' + idle_time
.s
.toString().lpad(2, "0");
764 panel
= _kiwi
.app
.panels().active
;
766 panel
.addMsg(event
.nick
, styleText('whois_ident', {nick
: event
.nick
, ident
: event
.ident
, host
: event
.hostname
, text
: event
.msg
}), 'whois');
768 } else if (event
.chans
) {
769 panel
.addMsg(event
.nick
, styleText('whois_channels', {nick
: event
.nick
, text
: translateText('client_models_network_channels', [event
.chans
])}), 'whois');
770 } else if (event
.irc_server
) {
771 panel
.addMsg(event
.nick
, styleText('whois_server', {nick
: event
.nick
, text
: translateText('client_models_network_server', [event
.irc_server
, event
.server_info
])}), 'whois');
772 } else if (event
.msg
) {
773 panel
.addMsg(event
.nick
, styleText('whois', {text
: event
.msg
}), 'whois');
774 } else if (event
.logon
) {
775 logon_date
= new Date();
776 logon_date
.setTime(event
.logon
* 1000);
777 logon_date
= formatDate(logon_date
);
779 panel
.addMsg(event
.nick
, styleText('whois_idle_and_signon', {nick
: event
.nick
, text
: translateText('client_models_network_idle_and_signon', [idle_time
, logon_date
])}), 'whois');
780 } else if (event
.away_reason
) {
781 panel
.addMsg(event
.nick
, styleText('whois_away', {nick
: event
.nick
, text
: translateText('client_models_network_away', [event
.away_reason
])}), 'whois');
783 panel
.addMsg(event
.nick
, styleText('whois_idle', {nick
: event
.nick
, text
: translateText('client_models_network_idle', [idle_time
])}), 'whois');
787 function onWhowas(event
) {
793 panel
= _kiwi
.app
.panels().active
;
794 if (event
.hostname
) {
795 panel
.addMsg(event
.nick
, styleText('who', {nick
: event
.nick
, ident
: event
.ident
, host
: event
.hostname
, realname
: event
.real_name
, text
: event
.msg
}), 'whois');
797 panel
.addMsg(event
.nick
, styleText('whois_notfound', {nick
: event
.nick
, text
: translateText('client_models_network_nickname_notfound', [])}), 'whois');
802 function onAway(event
) {
803 $.each(this.panels
.models
, function (index
, panel
) {
804 if (!panel
.isChannel()) return;
806 member
= panel
.get('members').getByNick(event
.nick
);
808 member
.set('away', !(!event
.reason
));
815 function onListStart(event
) {
816 var chanlist
= _kiwi
.model
.Applet
.loadOnce('kiwi_chanlist');
817 chanlist
.view
.show();
822 function onIrcError(event
) {
825 if (event
.channel
!== undefined && !(panel
= this.panels
.getByName(event
.channel
))) {
826 panel
= this.panels
.server
;
829 switch (event
.error
) {
830 case 'banned_from_channel':
831 panel
.addMsg(' ', styleText('channel_banned', {nick
: event
.nick
, text
: translateText('client_models_network_banned', [event
.channel
, event
.reason
]), channel
: event
.channel
}), 'status');
832 _kiwi
.app
.message
.text(_kiwi
.global
.i18n
.translate('client_models_network_banned').fetch(event
.channel
, event
.reason
));
834 case 'bad_channel_key':
835 panel
.addMsg(' ', styleText('channel_badkey', {nick
: event
.nick
, text
: translateText('client_models_network_channel_badkey', [event
.channel
]), channel
: event
.channel
}), 'status');
836 _kiwi
.app
.message
.text(_kiwi
.global
.i18n
.translate('client_models_network_channel_badkey').fetch(event
.channel
));
838 case 'invite_only_channel':
839 panel
.addMsg(' ', styleText('channel_inviteonly', {nick
: event
.nick
, text
: translateText('client_models_network_channel_inviteonly', [event
.nick
, event
.channel
]), channel
: event
.channel
}), 'status');
840 _kiwi
.app
.message
.text(event
.channel
+ ' ' + _kiwi
.global
.i18n
.translate('client_models_network_channel_inviteonly').fetch());
842 case 'user_on_channel':
843 panel
.addMsg(' ', styleText('channel_alreadyin', {nick
: event
.nick
, text
: translateText('client_models_network_channel_alreadyin'), channel
: event
.channel
}));
845 case 'channel_is_full':
846 panel
.addMsg(' ', styleText('channel_limitreached', {nick
: event
.nick
, text
: translateText('client_models_network_channel_limitreached', [event
.channel
]), channel
: event
.channel
}), 'status');
847 _kiwi
.app
.message
.text(event
.channel
+ ' ' + _kiwi
.global
.i18n
.translate('client_models_network_channel_limitreached').fetch(event
.channel
));
849 case 'chanop_privs_needed':
850 panel
.addMsg(' ', styleText('chanop_privs_needed', {text
: event
.reason
, channel
: event
.channel
}), 'status');
851 _kiwi
.app
.message
.text(event
.reason
+ ' (' + event
.channel
+ ')');
853 case 'cannot_send_to_channel':
854 panel
.addMsg(' ', '== ' + _kiwi
.global
.i18n
.translate('Cannot send message to channel, you are not voiced').fetch(event
.channel
, event
.reason
), 'status');
857 tmp
= this.panels
.getByName(event
.nick
);
859 tmp
.addMsg(' ', styleText('no_such_nick', {nick
: event
.nick
, text
: event
.reason
, channel
: event
.channel
}), 'status');
861 this.panels
.server
.addMsg(' ', styleText('no_such_nick', {nick
: event
.nick
, text
: event
.reason
, channel
: event
.channel
}), 'status');
864 case 'nickname_in_use':
865 this.panels
.server
.addMsg(' ', styleText('nickname_alreadyinuse', {nick
: event
.nick
, text
: translateText('client_models_network_nickname_alreadyinuse', [event
.nick
]), channel
: event
.channel
}), 'status');
866 if (this.panels
.server
!== this.panels
.active
) {
867 _kiwi
.app
.message
.text(_kiwi
.global
.i18n
.translate('client_models_network_nickname_alreadyinuse').fetch(event
.nick
));
870 // Only show the nickchange component if the controlbox is open
871 if (_kiwi
.app
.controlbox
.$el
.css('display') !== 'none') {
872 (new _kiwi
.view
.NickChangeBox()).render();
877 case 'password_mismatch':
878 this.panels
.server
.addMsg(' ', styleText('channel_badpassword', {nick
: event
.nick
, text
: translateText('client_models_network_badpassword', []), channel
: event
.channel
}), 'status');
883 this.panels
.server
.addMsg(' ', styleText('general_error', {text
: event
.reason
}), 'status');
888 // We don't know what data contains, so don't do anything with it.
889 //_kiwi.front.tabviews.server.addMsg(null, ' ', '== ' + data, 'status');
894 function onUnknownCommand(event
) {
895 var display_params
= _
.clone(event
.params
);
897 // A lot of commands have our nick as the first parameter. This is redundant for us
898 if (display_params
[0] && display_params
[0] == this.get('nick')) {
899 display_params
.shift();
902 this.panels
.server
.addMsg('', styleText('unknown_command', {text
: '[' + event
.command
+ '] ' + display_params
.join(', ', '')}));
906 function onWallops(event
) {
907 var active_panel
= _kiwi
.app
.panels().active
;
909 // Send to server panel
910 this.panels
.server
.addMsg('[' + (event
.nick
||'') + ']', styleText('wallops', {text
: event
.msg
}), 'wallops', {time
: event
.time
});
912 // Send to active panel if its a channel/query *and* it's related to this network
913 if (active_panel
!== this.panels
.server
&& (active_panel
.isChannel() || active_panel
.isQuery()) && active_panel
.get('network') === this)
914 active_panel
.addMsg('[' + (event
.nick
||'') + ']', styleText('wallops', {text
: event
.msg
}), 'wallops', {time
: event
.time
});