@@ -17,6 +17,7 @@ var SlackToIRC = function(config) {
1717 showSlackChannel : false ,
1818 serverPort : 80 ,
1919 httpsServerPort : 443 ,
20+ isDisplayInfo : true ,
2021 isHttpsConnecttion : false
2122 } ) ;
2223
@@ -55,7 +56,7 @@ SlackToIRC.prototype._server = function() {
5556 if ( req . method === 'POST' ) {
5657 this . _requestHandler ( req , res ) ;
5758 } else {
58- res . end ( 'Recieved request (not post).' ) ;
59+ res . end ( this . config . isDisplayInfo ? this . _getIndexHtml ( ) : 'Recieved request (not post).' ) ;
5960 }
6061 } . bind ( this ) ) ;
6162
@@ -117,4 +118,39 @@ SlackToIRC.prototype._decodeMessage = function(text) {
117118 . decodeAngel ( ) . encodeAmpersand ( ) . toString ( ) ;
118119} ;
119120
121+ SlackToIRC . prototype . _getIndexHtml = function ( ) {
122+ var html = '' ;
123+
124+ html += '<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8">'
125+ + '<title>Slack IRC Messages Syncbot</title>'
126+ + '<style>table, tr, td, th{border: 1px solid black; border-spacing: 0;} td, th{padding:.4em;}</style>'
127+ + '</head><body>'
128+ + '<h1>Slack IRC Messages Syncbot</h1>'
129+ + '<h2>Sync Channels</h2>'
130+ + '<table>'
131+ + '<thead><tr><th>IRC Channel</th><th>Slack Channel</th></tr></thead>'
132+ + '<tbody>' + this . _objectToHtmlTr ( this . config . channels ) + '</tbody>'
133+ + '</table>'
134+ + '<h2>Binding Users</h2>'
135+ + '<table>'
136+ + '<thead><tr><th>IRC Acoount</th><th>Slack Account</th></tr></thead>'
137+ + '<tbody>' + this . _objectToHtmlTr ( this . config . users ) + '</tbody>'
138+ + '</table>'
139+ + '<h2>Banned IRC Nicks</h2><p>' + this . config . bannedIRCNicks . join ( ', ' ) + '</p>'
140+ + '<p><a href="https://github.com/fntsrlike/slack-irc-syncbot">[Github]</a><p>'
141+ + '</body></html>' ;
142+
143+ return html ;
144+ }
145+
146+ SlackToIRC . prototype . _objectToHtmlTr = function ( object ) {
147+ var html = '' ;
148+
149+ for ( var key in object ) {
150+ html += '<tr><td>' + key + '</td><td>' + object [ key ] + '</td></tr>' ;
151+ }
152+
153+ return html ;
154+ }
155+
120156module . exports = SlackToIRC ;
0 commit comments