var panel,\r
is_pm = (event.channel == _kiwi.gateway.get('nick'));\r
\r
+ // An ignored user? don't do anything with it\r
+ if (gw.isNickIgnored(event.nick)) {\r
+ return;\r
+ }\r
+\r
if (is_pm) {\r
// If a panel isn't found for this PM, create one\r
panel = that.panels.getByName(event.nick);\r
panel = that.panels.server;\r
}\r
}\r
- \r
+\r
panel.addMsg(event.nick, event.msg);\r
});\r
\r
\r
gw.on('onctcp_request', function (event) {\r
+ // An ignored user? don't do anything with it\r
+ if (gw.isNickIgnored(event.nick)) {\r
+ return;\r
+ }\r
+\r
// Reply to a TIME ctcp\r
if (event.msg.toUpperCase() === 'TIME') {\r
gw.ctcp(false, event.type, event.nick, (new Date()).toString());\r
\r
\r
gw.on('onctcp_response', function (event) {\r
+ // An ignored user? don't do anything with it\r
+ if (gw.isNickIgnored(event.nick)) {\r
+ return;\r
+ }\r
+ \r
that.panels.server.addMsg('[' + event.nick + ']', 'CTCP ' + event.msg);\r
});\r
\r
gw.on('onnotice', function (event) {\r
var panel;\r
\r
+ // An ignored user? don't do anything with it\r
+ if (event.nick && gw.isNickIgnored(event.nick)) {\r
+ return;\r
+ }\r
+\r
// Find a panel for the destination(channel) or who its from\r
panel = that.panels.getByName(event.target) || that.panels.getByName(event.nick);\r
if (!panel) {\r
var panel,\r
is_pm = (event.channel == _kiwi.gateway.get('nick'));\r
\r
+ // An ignored user? don't do anything with it\r
+ if (gw.isNickIgnored(event.nick)) {\r
+ return;\r
+ }\r
+\r
if (is_pm) {\r
// If a panel isn't found for this PM, create one\r
panel = that.panels.getByName(event.nick);\r
controlbox.preprocessor.aliases[name] = rule;\r
});\r
\r
+ \r
+ controlbox.on('command:ignore', function (ev) {\r
+ var list = _kiwi.gateway.get('ignore_list');\r
+\r
+ // No parameters passed so list them\r
+ if (!ev.params[0]) {\r
+ if (list.length > 0) {\r
+ _kiwi.app.panels.active.addMsg(' ', 'Ignored nicks:');\r
+ $.each(list, function (idx, ignored_pattern) {\r
+ _kiwi.app.panels.active.addMsg(' ', ignored_pattern);\r
+ });\r
+ } else {\r
+ _kiwi.app.panels.active.addMsg(' ', 'Not ignoring anybody');\r
+ }\r
+ return;\r
+ }\r
+\r
+ // We have a parameter, so add it\r
+ list.push(ev.params[0]);\r
+ _kiwi.gateway.set('ignore_list', list);\r
+ _kiwi.app.panels.active.addMsg(' ', 'Ignoring ' + ev.params[0]);\r
+ });\r
+\r
+\r
+ controlbox.on('command:unignore', function (ev) {\r
+ var list = _kiwi.gateway.get('ignore_list');\r
+\r
+ if (!ev.params[0]) {\r
+ _kiwi.app.panels.active.addMsg(' ', 'Specifiy which nick you wish to stop ignoring');\r
+ return;\r
+ }\r
+\r
+ list = _.reject(list, function(pattern) {\r
+ return pattern === ev.params[0];\r
+ });\r
+\r
+ _kiwi.gateway.set('ignore_list', list);\r
+\r
+ _kiwi.app.panels.active.addMsg(' ', 'Stopped ignoring ' + ev.params[0]);\r
+ });\r
+\r
+\r
controlbox.on('command:applet', appletCommand);\r
controlbox.on('command:settings', settingsCommand);\r
controlbox.on('command:script', scriptCommand);\r
* The URL to the Kiwi server\r
* @type String\r
*/\r
- kiwi_server: '//kiwi'\r
+ kiwi_server: '//kiwi',\r
+\r
+ /**\r
+ * List of nicks we are ignoring\r
+ * @type Array\r
+ */\r
+ ignore_list: []\r
};\r
\r
\r
};\r
\r
\r
+ // Check a nick alongside our ignore list\r
+ this.isNickIgnored = function (nick) {\r
+ var idx, list = this.get('ignore_list');\r
+ var pattern, regex;\r
+\r
+ for (idx = 0; idx < list.length; idx++) {\r
+ pattern = list[idx].replace(/([.+^$[\]\\(){}|-])/g, "\\$1")\r
+ .replace('*', '.*')\r
+ .replace('?', '.');\r
+\r
+ regex = new RegExp(pattern, 'i');\r
+ if (regex.test(nick)) return true;\r
+ }\r
+\r
+ return false;\r
+ }\r
+\r
+\r
return new (Backbone.Model.extend(this))(arguments);\r
};
\ No newline at end of file