}
+/**
+ * Formats a kiwi message to IRC format
+ */
+function formatToIrcMsg(message) {
+ // Format any colour codes (eg. $c4)
+ message = message.replace(/%C(\d)/ig, function(match, colour_number) {
+ return String.fromCharCode(3) + colour_number.toString();
+ });
+
+ var formatters = {
+ B: '\x02', // Bold
+ I: '\x1D', // Italics
+ U: '\x1F', // Underline
+ O: '\x0F' // Out / Clear formatting
+ };
+ message = message.replace(/%([BIUO])/ig, function(match, format_code) {
+ if (typeof formatters[format_code.toUpperCase()] !== 'undefined')
+ return formatters[format_code.toUpperCase()];
+ });
+
+ return message;
+}
+
+
/**
* Formats a message. Adds bold, underline and colouring
* @param {String} msg The message to format
}\r
\r
function msgCommand (ev) {\r
- var destination = ev.params[0],\r
+ var message,\r
+ destination = ev.params[0],\r
panel = that.connections.active_connection.panels.getByName(destination) || that.panels().server;\r
\r
ev.params.shift();\r
+ message = formatToIrcMsg(ev.params.join(' '));\r
\r
- panel.addMsg(_kiwi.app.connections.active_connection.get('nick'), ev.params.join(' '));\r
- _kiwi.gateway.privmsg(null, destination, ev.params.join(' '));\r
+ panel.addMsg(_kiwi.app.connections.active_connection.get('nick'), message);\r
+ _kiwi.gateway.privmsg(null, destination, message);\r
}\r
\r
function actionCommand (ev) {\r