this.gateway.on('part', onPart, this);
this.gateway.on('quit', onQuit, this);
this.gateway.on('kick', onKick, this);
- this.gateway.on('msg', onMsg, this);
+ this.gateway.on('message', onMessage, this);
this.gateway.on('nick', onNick, this);
this.gateway.on('ctcp_request', onCtcpRequest, this);
this.gateway.on('ctcp_response', onCtcpResponse, this);
- this.gateway.on('notice', onNotice, this);
- this.gateway.on('action', onAction, this);
this.gateway.on('topic', onTopic, this);
this.gateway.on('topicsetby', onTopicSetBy, this);
this.gateway.on('userlist', onUserlist, this);
- function onMsg(event) {
+ function onMessage(event) {
var panel,
- is_pm = (event.target.toLowerCase() == this.get('nick').toLowerCase());
+ is_pm = ((event.target || '').toLowerCase() == this.get('nick').toLowerCase());
// An ignored user? don't do anything with it
if (this.isNickIgnored(event.nick)) {
return;
}
- if (is_pm) {
+ if (event.type == 'notice') {
+ if (event.from_server) {
+ panel = this.panels.server;
+
+ } else {
+ panel = this.panels.getByName(event.target) || this.panels.getByName(event.nick);
+
+ // Forward ChanServ messages to its associated channel
+ if (event.nick && event.nick.toLowerCase() == 'chanserv' && event.msg.charAt(0) == '[') {
+ channel_name = /\[([^ \]]+)\]/gi.exec(event.msg);
+ if (channel_name && channel_name[1]) {
+ channel_name = channel_name[1];
+
+ panel = this.panels.getByName(channel_name);
+ }
+ }
+
+ }
+
+ if (!panel) {
+ panel = this.panels.server;
+ }
+
+ } else if (is_pm) {
// If a panel isn't found for this PM, create one
panel = this.panels.getByName(event.nick);
if (!panel) {
}
} else {
- // If a panel isn't found for this channel, reroute to the
+ // If a panel isn't found for this target, reroute to the
// server panel
panel = this.panels.getByName(event.target);
if (!panel) {
}
}
- panel.addMsg(event.nick, styleText('privmsg', {text: event.msg}), 'privmsg', {time: event.time});
+ switch (event.type){
+ case 'message':
+ panel.addMsg(event.nick, styleText('privmsg', {text: event.msg}), 'privmsg', {time: event.time});
+ break;
+
+ case 'action':
+ panel.addMsg('', styleText('action', {nick: event.nick, text: event.msg}), 'action', {time: event.time});
+ break;
+
+ case 'notice':
+ panel.addMsg('[' + (event.nick||'') + ']', styleText('notice', {text: event.msg}), 'notice', {time: event.time});
+
+ // Show this notice to the active panel if it didn't have a set target, but only in an active channel or query window
+ active_panel = _kiwi.app.panels().active;
+
+ if (!event.from_server && panel === this.panels.server && active_panel !== this.panels.server) {
+ if (active_panel.get('network') === this && (active_panel.isChannel() || active_panel.isQuery()))
+ active_panel.addMsg('[' + (event.nick||'') + ']', styleText('notice', {text: event.msg}), 'notice', {time: event.time});
+ }
+ break;
+ }
}
- function onNotice(event) {
- var panel, active_panel, channel_name;
-
- // An ignored user? don't do anything with it
- if (!event.from_server && event.nick && this.isNickIgnored(event.nick)) {
- return;
- }
-
- // Find a panel for the destination(channel) or who its from
- if (!event.from_server) {
- panel = this.panels.getByName(event.target) || this.panels.getByName(event.nick);
-
- // Forward ChanServ messages to its associated channel
- if (event.nick && event.nick.toLowerCase() == 'chanserv' && event.msg.charAt(0) == '[') {
- channel_name = /\[([^ \]]+)\]/gi.exec(event.msg);
- if (channel_name && channel_name[1]) {
- channel_name = channel_name[1];
-
- panel = this.panels.getByName(channel_name);
- }
- }
-
- if (!panel) {
- panel = this.panels.server;
- }
- } else {
- panel = this.panels.server;
- }
-
- panel.addMsg('[' + (event.nick||'') + ']', styleText('notice', {text: event.msg}), 'notice', {time: event.time});
-
- // Show this notice to the active panel if it didn't have a set target, but only in an active channel or query window
- active_panel = _kiwi.app.panels().active;
-
- if (!event.from_server && panel === this.panels.server && active_panel !== this.panels.server) {
- if (active_panel.isChannel() || active_panel.isQuery())
- _kiwi.app.panels().active.addMsg('[' + (event.nick||'') + ']', styleText('notice', {text: event.msg}), 'notice', {time: event.time});
- }
- }
-
-
-
- function onAction(event) {
- var panel,
- is_pm = (event.target.toLowerCase() == this.get('nick').toLowerCase());
-
- // An ignored user? don't do anything with it
- if (this.isNickIgnored(event.nick)) {
- return;
- }
-
- if (is_pm) {
- // If a panel isn't found for this PM, create one
- panel = this.panels.getByName(event.nick);
- if (!panel) {
- panel = new _kiwi.model.Channel({name: event.nick, network: this});
- this.panels.add(panel);
- }
-
- } else {
- // If a panel isn't found for this channel, reroute to the
- // server panel
- panel = this.panels.getByName(event.target);
- if (!panel) {
- panel = this.panels.server;
- }
- }
-
- panel.addMsg('', styleText('action', {nick: event.nick, text: event.msg}), 'action', {time: event.time});
- }
-
-
-
function onTopic(event) {
var c;
c = this.panels.getByName(event.channel);