from log import gobblogger
from config import config, settings

CFG_RESPONSE_MAIL_HEADER = "Config confirmed"
CFG_RESPONSE_MAIL_HEADER_FAIL = "Config failed!"


def check_messages(r):
    unread = r.inbox.unread()
    for new in unread:
        if new.author == settings.REDDIT_ACC_OWNER:
            process(r, new.body)
        new.mark_read()


def process(r, body):
    split = body.split(' ')
    if body.startswith('turn on'):
        config.set_currently_running('on')
        send_confirmation_message(r, CFG_RESPONSE_MAIL_HEADER, 'Turning Bot on')
        gobblogger.info("Received turn on config message")

    elif body.startswith('turn off'):
        config.set_currently_running('off')
        send_confirmation_message(r, CFG_RESPONSE_MAIL_HEADER, 'Turning Bot off')
        gobblogger.info("Received turn off config message")

    elif body.startswith('errmsg on'):
        config.set_error_messaging('on')
        send_confirmation_message(r, CFG_RESPONSE_MAIL_HEADER, 'Turning Error Messaging on')
        gobblogger.info("Received errmsg on config message")

    elif body.startswith('errmsg off'):
        config.set_error_messaging('off')
        send_confirmation_message(r, CFG_RESPONSE_MAIL_HEADER,
                                  'Turning Error Messaging off')
        gobblogger.info("Received errmsg off config message")
    elif len(split) == 3 and split[0] == 'waittime':
        confirm = split[1] == 'main' or split[1] == 'msgs' or split[1] == 'manager'
        if split[1] == 'main':
            config.set_wait_time_main(split[2])
        if split[1] == 'msgs':
            config.set_wait_time_check_messages(split[2])
        if split[1] == 'manager':
            config.set_wait_time_manager(split[2])
        if confirm:
            send_confirmation_message(r, CFG_RESPONSE_MAIL_HEADER,
                                      "Successfully configured waittime " + split[1] + " to " + str(split[2]))
            gobblogger.info("Received waittime config message")

def send_confirmation_message(reddit, header, body):
    reddit.redditor(settings.REDDIT_ACC_OWNER).message(header, body)

@@ -153,16 +153,318 @@
 iled!%22%0A%0A
+CFG_HELP = %22%22%22%0ACommands help:%0A%0Aturn on/off - Controls running main thread (scanning and posting to reddit)%0A%0Aerrmsg on/off - Controls whether to receive error notifications%0A%0Awaittime main/msgs/manager x - sets the waiting delay of each of the threads, should be a divisor of 3600%0A%0Ahelp - this info%0A%0A%22%22%22%0A
 %0Adef che
@@ -582,16 +582,41 @@
 CC_OWNER
+ and new.subject == 'cfg'
 :%0A      
@@ -650,16 +650,20 @@
         
+    
 new.mark
@@ -790,28 +790,28 @@
 tly_running(
-'on'
+True
 )%0A        se
@@ -1012,29 +1012,29 @@
 tly_running(
-'off'
+False
 )%0A        se
@@ -1244,12 +1244,12 @@
 ing(
-'on'
+True
 )%0A  
@@ -1480,13 +1480,13 @@
 ing(
-'off'
+False
 )%0A  
@@ -1673,16 +1673,17 @@
 ssage%22)%0A
+%0A
     elif
@@ -2327,16 +2327,181 @@
 sage%22)%0A%0A
+    elif body.startswith('help'):%0A        send_confirmation_message(r, CFG_RESPONSE_MAIL_HEADER, CFG_HELP)%0A        gobblogger.info(%22Received help request message%22)%0A%0A
 def send

Add help interface