@@ -2,6 +2,8 @@ var _ = require('underscore');
22var IRC = require ( 'irc' ) ;
33var SlackClient = require ( 'slack-client' ) ;
44var Log = require ( 'log' ) ;
5+ var Entities = require ( 'html-entities' ) . XmlEntities ;
6+
57
68/**
79 * IRC Bot for syncing messages from IRC to Slack
@@ -23,6 +25,7 @@ var Bot = function (config) {
2325 } ) ;
2426
2527 this . logger = new Log ( process . env . SLACK_LOG_LEVEL || 'info' ) ;
28+ this . entities = new Entities ( ) ;
2629 // default node-irc options
2730 // (@see https://github.com/martynsmith/node-irc/blob/0.3.x/lib/irc.js)
2831 this . irc = {
@@ -244,6 +247,8 @@ Bot.prototype.ircSpeak = function (channel, message, username) {
244247 if ( ! self . config . highlight ) {
245248 username = username . replace ( / ^ ( .) / , '$1\u200C' )
246249 }
250+ username = "<" + username + "> "
251+ message = self . entities . decode ( message )
247252
248253 // IRC max length is 512, minus the CR LF and other headers ...
249254 // In practice, it looks like this:
@@ -255,7 +260,7 @@ Bot.prototype.ircSpeak = function (channel, message, username) {
255260 // 497 = 510 - 13
256261
257262 maxLineLength = 479 - ( self . hostmask . length + self . client . nick . length + self . client . hostMask . length )
258- maxLineLength -= ( channel . length + username . length + 2 )
263+ maxLineLength -= ( channel . length + username . length + 3 )
259264
260265 message . split ( / \s * [ \r \n ] + \s * / ) . forEach ( function ( msg ) {
261266 while ( msg . length > maxLineLength ) {
@@ -264,11 +269,11 @@ Bot.prototype.ircSpeak = function (channel, message, username) {
264269 line = msg . slice ( 0 , length )
265270 msg = msg . slice ( length ) . trim ( )
266271
267- self . logger . info ( 'IRC(' + line . length + ')> ' + channel + ": " + username + ': ' + line ) ;
268- self . client . say ( channel , username + ": " + line ) ;
272+ self . logger . debug ( 'IRC(' + line . length + ')> # ' + channel + " " + username + line ) ;
273+ self . client . say ( channel , username + line ) ;
269274 }
270- self . logger . info ( 'IRC> ' + channel + ": " + username + ': ' + msg ) ;
271- self . client . say ( channel , username + ": " + msg ) ;
275+ self . logger . debug ( 'IRC> # ' + channel + " " + username + msg ) ;
276+ self . client . say ( channel , username + msg ) ;
272277 } ) ;
273278} ;
274279
0 commit comments