gw.on('onmode', function (event) {\r
var channel, i, prefixes, members, member, find_prefix;\r
\r
+ // Build a nicely formatted string to be displayed to a regular human\r
+ function friendlyModeString (event_modes, alt_target) {\r
+ var modes = {}, return_string;\r
+\r
+ // If no default given, use the main event info\r
+ if (!event_modes) {\r
+ event_modes = event.modes;\r
+ alt_target = event.target;\r
+ }\r
+\r
+ // Reformat the mode object to make it easier to work with\r
+ _.each(event_modes, function (mode){\r
+ var param = mode.param || alt_target || '';\r
+\r
+ // Make sure we have some modes for this param\r
+ if (!modes[param]) {\r
+ modes[param] = {'+':'', '-':''};\r
+ }\r
+\r
+ modes[param][mode.mode[0]] += mode.mode.substr(1);\r
+ });\r
+\r
+ // Put the string together from each mode\r
+ return_string = [];\r
+ _.each(modes, function (modeset, param) {\r
+ var str = '';\r
+ if (modeset['+']) str += '+' + modeset['+'];\r
+ if (modeset['-']) str += '-' + modeset['-'];\r
+ return_string.push(str + ' ' + param);\r
+ });\r
+ return_string = return_string.join(', ');\r
+\r
+ return return_string;\r
+ }\r
+\r
+\r
channel = that.panels.getByName(event.target);\r
if (channel) {\r
prefixes = kiwi.gateway.get('user_prefixes');\r
} else if (event.modes[i].mode[0] === '-') {\r
member.removeMode(event.modes[i].mode[1]);\r
}\r
- channel.addMsg(event.nick, 'set mode ' + event.modes[i].mode + ' ' + event.modes[i].param, 'mode');\r
+ //channel.addMsg('', '=== ' + event.nick + ' set mode ' + event.modes[i].mode + ' ' + event.modes[i].param, 'action mode');\r
}\r
} else {\r
+ // Channel mode being set\r
// TODO: Store this somewhere?\r
- channel.addMsg(event.nick, 'set mode ' + event.modes[i].mode + ' on ' + event.target, 'mode');\r
+ //channel.addMsg('', 'CHANNEL === ' + event.nick + ' set mode ' + event.modes[i].mode + ' on ' + event.target, 'action mode');\r
}\r
}\r
+\r
+ channel.addMsg('', '=== ' + event.nick + ' sets mode ' + friendlyModeString(), 'action mode');\r
} else {\r
// This is probably a mode being set on us.\r
if (event.target.toLowerCase() === kiwi.gateway.get("nick").toLowerCase()) {\r
- that.panels.server.addMsg(event.nick, 'set mode ' + event.modes[i].mode + ' on ' + event.target, 'mode');\r
+ that.panels.server.addMsg('', '=== ' + event.nick + ' set mode ' + friendlyModeString(), 'action mode');\r
} else {\r
- console.log('MODE command recieved for unknown target %s: ', event.target, event.modes[i].mode,); \r
+ console.log('MODE command recieved for unknown target %s: ', event.target, event);\r
}\r
}\r
});\r
kiwi.app.panels.server.addMsg(' ', '=== The nickname ' + data.nick + ' is already in use. Please select a new nickname', 'status');\r
if (kiwi.app.panels.server !== kiwi.app.panels.active) {\r
kiwi.app.message.text('The nickname "' + data.nick + '" is already in use. Please select a new nickname');\r
- }
+ }\r
\r
// Only show the nickchange component if the controlbox is open\r
if (that.controlbox.$el.css('display') !== 'none') {\r
(new kiwi.view.NickChangeBox()).render();\r
}\r
-
+\r
break;\r
default:\r
// We don't know what data contains, so don't do anything with it.\r
\r
\r
return new (Backbone.Model.extend(this))(arguments);\r
-};
+};\r