var ZenIRCBot = require('zenircbot-api').ZenIRCBot;
var zen = new ZenIRCBot;
var sub = zen.get_redis_client();
var channels = ['#pdxbots']

zen.register_commands(
    "rtd.js",
    [
	{
	    name: "oncall",
	    description: "Adds caller to on call list."
	}, {
	    name: "offcall",
	    description: "Removes call from on call list."
	}, {
	    name: "help",
	    description: "Pings on call people and records question."
	}, {
	    name: "info",
	    description: "Gives basic information about using the commands."
	}
    ]
)

sub.subscribe('in');
sub.on('message', function(channel, message){
    var msg = JSON.parse(message);
    if (msg.version == 1 && msg.type == 'directed_privmsg'
	&& channels.indexOf(msg.data.channel) != -1) {
	
	if (/^info$/.test(msg.data.message.trim())) {
	    zen.send_privmsg(msg.data.channel,
			     'Welcome to #readthedocs, if you have a ' +
			     'question please prefix it with !help in order ' +
			     'to notify the volunteer support people.')
	    zen.send_privmsg(msg.data.channel,
			     'Please allow some time for a response as we ' +
			     'may be asleep or otherwise busy.')
	    zen.send_privmsg(msg.data.channel,
			     "If you don't get a response please file an issue here: " +
			     "https://github.com/rtfd/readthedocs.org/issues")
	}
    }
})

@@ -1,21 +1,38 @@
 var 
-ZenIRCBot
+fs = require('fs')%0Avar api
  = requi
@@ -54,19 +54,57 @@
 pi')
-.ZenIRCBot;
+;%0Avar bot_config = api.load_config('../bot.json')
 %0Avar
@@ -114,16 +114,20 @@
 n = new 
+api.
 ZenIRCBo
@@ -131,71 +131,380 @@
 CBot
-;%0Avar sub = zen.get_redis_client();%0Avar channels = %5B'#pdxbots'%5D
+(bot_config.redis.host,%0A                            bot_config.redis.port,%0A                            bot_config.redis.db)%0Avar sub = zen.get_redis_client();%0Avar channels = %5B'#readthedocs'%5D%0A%0Afs.exists('./rtfd/rtfd.json', function (exists) %7B%0A    if (exists) %7B%0A        var conf = api.load_config('./rtfd/rtfd.json')%0A        channels = channels.concat(conf.channels)%0A    %7D%0A%7D)
 %0A%0Aze
@@ -548,12 +548,26 @@
   %5B%0A
-%09%7B%0A%09
+        %7B%0A        
     
@@ -578,25 +578,32 @@
 : %22oncall%22,%0A
-%09
+        
     descript
@@ -630,39 +630,53 @@
  on call list.%22%0A
-%09%7D, %7B%0A%09
+        %7D, %7B%0A        
     name: %22offca
@@ -680,17 +680,24 @@
 fcall%22,%0A
-%09
+        
     desc
@@ -739,23 +739,37 @@
  list.%22%0A
-%09%7D, %7B%0A%09
+        %7D, %7B%0A        
     name
@@ -778,17 +778,24 @@
 %22help%22,%0A
-%09
+        
     desc
@@ -852,15 +852,29 @@
 n.%22%0A
-%09%7D, %7B%0A%09
+        %7D, %7B%0A        
     
@@ -887,17 +887,24 @@
 %22info%22,%0A
-%09
+        
     desc
@@ -964,17 +964,24 @@
 mands.%22%0A
-%09
+        
 %7D%0A    %5D%0A
@@ -1085,16 +1085,168 @@
 ssage);%0A
+    console.log(%5Bmsg.version == 1, msg.type == 'directed_privmsg',%0A                channels.indexOf(msg.data.channel) != -1%5D)%0A    console.log(msg.type)%0A
     if (
@@ -1299,12 +1299,19 @@
 msg'
-%0A%09&&
+ &&%0A       
  cha
@@ -1355,11 +1355,17 @@
 ) %7B%0A
-%09%0A%09
+%0A        
 if (
@@ -1406,17 +1406,24 @@
 m())) %7B%0A
-%09
+        
     zen.
@@ -1449,27 +1449,48 @@
 ta.channel,%0A
-%09%09%09
+                        
      'Welcom
@@ -1522,27 +1522,48 @@
  have a ' +%0A
-%09%09%09
+                        
      'questi
@@ -1602,27 +1602,48 @@
 n order ' +%0A
-%09%09%09
+                        
      'to not
@@ -1674,29 +1674,36 @@
 t people.')%0A
-%09
+     
     
+   
 zen.send_pri
@@ -1721,27 +1721,48 @@
 ta.channel,%0A
-%09%09%09
+                        
      'Please
@@ -1803,19 +1803,40 @@
  we ' +%0A
-%09%09%09
+                        
      'ma
@@ -1868,17 +1868,24 @@
 busy.')%0A
-%09
+        
     zen.
@@ -1915,19 +1915,40 @@
 hannel,%0A
-%09%09%09
+                        
      %22If
@@ -1992,27 +1992,82 @@
  an 
-issue here: %22 +%0A%09%09%09
+%22 +%0A                             %22issue here: %22 +%0A                        
     
@@ -2121,9 +2121,16 @@
 s%22)%0A
-%09
+        
 %7D%0A  

change default channel