import time
import emoji

# Put your commands here
COMMAND1 = "testing testing"
COMMAND2 = "roger roger"

BLUEON = str("blue on")
BLUEOFF = str("blue off")

REDON = str("red on")
REDOFF = str("red off")

GREENON = str("green on")
GREENOFF = str("green off")

YELLOWON = str("yellow on")
YELLOWOFF = str("yellow off")

CLOCK = str("update clock")
SCRAMBLE = str('scramble the 7')
HACKER = str('hack the 7')

SINGLEREADING = str('light')

def setup():
    import RPi.GPIO as GPIO

    import slackbot_wems.chris.light as lite
    import slackbot_wems.chris.segment7 as segment
    
    GPIO.setmode(GPIO.BCM)
    GPIO.setwarnings(False)

    # Pin Setup
    GPIO.setup(17, GPIO.OUT) # BLUE LED
    GPIO.setup(27, GPIO.OUT) # RED LED
    GPIO.setup(5, GPIO.OUT) # GREEN LED
    GPIO.setup(22, GPIO.OUT) # YELLOW LED
    
    GPIO.setup(12, GPIO.OUT) # LDR 

setup = False

# Your handling code goes in this function
def handle_command(command):
    """
        Determine if the command is valid. If so, take action and return
        a response, if necessary.

    """

    if not setup:
        setup_gpio()
        setup = True

    response = ""
    if command.find(COMMAND1) >= 0:
        response = str("Surprise!")    
    elif command.find(COMMAND2) >= 0:
        response = (emoji.emojize('Python\n is\n :thumbs_up: :thumbs_up: :thumbs_up:'))

# Blue LED Commands
    elif command.find(BLUEON) >= 0:
        GPIO.output(17, True)
        response = emoji.emojize("" + "Turning :radio_button: ON...")

    elif command.find(BLUEOFF) >= 0:
        GPIO.output(17, False)
        response = emoji.emojize("" + "Turning :radio_button: OFF...")
    
# Red LED Commands
    elif command.find(REDON) >= 0:
        GPIO.output(27, True)
        response = emoji.emojize("" + "Turning :red_circle: ON...")

    elif command.find(REDOFF) >= 0:
        GPIO.output(27, False)
        response = emoji.emojize("" + "Turning :red_circle: OFF...")
   
# Green LED Commands
    elif command.find(GREENON) >= 0:
        GPIO.output(5, True)
        response = emoji.emojize("" + "Turning :green_apple: ON...")

    elif command.find(GREENOFF) >= 0:
        GPIO.output(5, False)
        response = emoji.emojize("" + "Turning :green_apple: OFF...")
   
# Yellow LED Commands
    elif command.find(YELLOWON) >= 0:
        GPIO.output(22, True)
        response = emoji.emojize("" + "Turning :sunny: ON...")

    elif command.find(YELLOWOFF) >= 0:
        GPIO.output(22, False)
        response = emoji.emojize("" + "Turning :sunny: OFF...")

# 7 Segment Commands
    elif command.find(CLOCK) >= 0:
        print('Updating the clock!')
        response = segment.updateClock()

    elif command.find(SCRAMBLE) >= 0:
        print(emoji.emojize(":egg: There is nothing better than scrambled eggs! :egg:"))
        response = segment.scramble()

    elif command.find(HACKER) >= 0:
        print('Message')
        response = segment.hacker()
    
    elif command.find(SINGLEREADING) >= 0:
        a = lite.printReading()
        a = int(a)
        time.sleep(1)
        print(a)
        response = ('Here is what the LDR Sensor said to me: ' + str(a)) 

    return response


[((584, 606), 'RPi.GPIO.setmode', 'GPIO.setmode', (['GPIO.BCM'], {}), '(GPIO.BCM)\n', (596, 606), True, 'import RPi.GPIO as GPIO\n'), ((611, 634), 'RPi.GPIO.setwarnings', 'GPIO.setwarnings', (['(False)'], {}), '(False)\n', (627, 634), True, 'import RPi.GPIO as GPIO\n'), ((656, 680), 'RPi.GPIO.setup', 'GPIO.setup', (['(17)', 'GPIO.OUT'], {}), '(17, GPIO.OUT)\n', (666, 680), True, 'import RPi.GPIO as GPIO\n'), ((696, 720), 'RPi.GPIO.setup', 'GPIO.setup', (['(27)', 'GPIO.OUT'], {}), '(27, GPIO.OUT)\n', (706, 720), True, 'import RPi.GPIO as GPIO\n'), ((735, 758), 'RPi.GPIO.setup', 'GPIO.setup', (['(5)', 'GPIO.OUT'], {}), '(5, GPIO.OUT)\n', (745, 758), True, 'import RPi.GPIO as GPIO\n'), ((775, 799), 'RPi.GPIO.setup', 'GPIO.setup', (['(22)', 'GPIO.OUT'], {}), '(22, GPIO.OUT)\n', (785, 799), True, 'import RPi.GPIO as GPIO\n'), ((822, 846), 'RPi.GPIO.setup', 'GPIO.setup', (['(12)', 'GPIO.OUT'], {}), '(12, GPIO.OUT)\n', (832, 846), True, 'import RPi.GPIO as GPIO\n'), ((1280, 1348), 'emoji.emojize', 'emoji.emojize', (['"""Python\n is\n :thumbs_up: :thumbs_up: :thumbs_up:"""'], {}), '("""Python\n is\n :thumbs_up: :thumbs_up: :thumbs_up:""")\n', (1293, 1348), False, 'import emoji\n'), ((1413, 1434), 'RPi.GPIO.output', 'GPIO.output', (['(17)', '(True)'], {}), '(17, True)\n', (1424, 1434), True, 'import RPi.GPIO as GPIO\n'), ((1454, 1504), 'emoji.emojize', 'emoji.emojize', (["('' + 'Turning :radio_button: ON...')"], {}), "('' + 'Turning :radio_button: ON...')\n", (1467, 1504), False, 'import emoji\n'), ((1551, 1573), 'RPi.GPIO.output', 'GPIO.output', (['(17)', '(False)'], {}), '(17, False)\n', (1562, 1573), True, 'import RPi.GPIO as GPIO\n'), ((1593, 1644), 'emoji.emojize', 'emoji.emojize', (["('' + 'Turning :radio_button: OFF...')"], {}), "('' + 'Turning :radio_button: OFF...')\n", (1606, 1644), False, 'import emoji\n'), ((1712, 1733), 'RPi.GPIO.output', 'GPIO.output', (['(27)', '(True)'], {}), '(27, True)\n', (1723, 1733), True, 'import RPi.GPIO as GPIO\n'), ((1753, 1801), 'emoji.emojize', 'emoji.emojize', (["('' + 'Turning :red_circle: ON...')"], {}), "('' + 'Turning :red_circle: ON...')\n", (1766, 1801), False, 'import emoji\n'), ((1847, 1869), 'RPi.GPIO.output', 'GPIO.output', (['(27)', '(False)'], {}), '(27, False)\n', (1858, 1869), True, 'import RPi.GPIO as GPIO\n'), ((1889, 1938), 'emoji.emojize', 'emoji.emojize', (["('' + 'Turning :red_circle: OFF...')"], {}), "('' + 'Turning :red_circle: OFF...')\n", (1902, 1938), False, 'import emoji\n'), ((2009, 2029), 'RPi.GPIO.output', 'GPIO.output', (['(5)', '(True)'], {}), '(5, True)\n', (2020, 2029), True, 'import RPi.GPIO as GPIO\n'), ((2049, 2098), 'emoji.emojize', 'emoji.emojize', (["('' + 'Turning :green_apple: ON...')"], {}), "('' + 'Turning :green_apple: ON...')\n", (2062, 2098), False, 'import emoji\n'), ((2146, 2167), 'RPi.GPIO.output', 'GPIO.output', (['(5)', '(False)'], {}), '(5, False)\n', (2157, 2167), True, 'import RPi.GPIO as GPIO\n'), ((2187, 2237), 'emoji.emojize', 'emoji.emojize', (["('' + 'Turning :green_apple: OFF...')"], {}), "('' + 'Turning :green_apple: OFF...')\n", (2200, 2237), False, 'import emoji\n'), ((2310, 2331), 'RPi.GPIO.output', 'GPIO.output', (['(22)', '(True)'], {}), '(22, True)\n', (2321, 2331), True, 'import RPi.GPIO as GPIO\n'), ((2351, 2394), 'emoji.emojize', 'emoji.emojize', (["('' + 'Turning :sunny: ON...')"], {}), "('' + 'Turning :sunny: ON...')\n", (2364, 2394), False, 'import emoji\n'), ((2443, 2465), 'RPi.GPIO.output', 'GPIO.output', (['(22)', '(False)'], {}), '(22, False)\n', (2454, 2465), True, 'import RPi.GPIO as GPIO\n'), ((2485, 2529), 'emoji.emojize', 'emoji.emojize', (["('' + 'Turning :sunny: OFF...')"], {}), "('' + 'Turning :sunny: OFF...')\n", (2498, 2529), False, 'import emoji\n'), ((2643, 2664), 'slackbot_wems.chris.segment7.updateClock', 'segment.updateClock', ([], {}), '()\n', (2662, 2664), True, 'import slackbot_wems.chris.segment7 as segment\n'), ((2812, 2830), 'slackbot_wems.chris.segment7.scramble', 'segment.scramble', ([], {}), '()\n', (2828, 2830), True, 'import slackbot_wems.chris.segment7 as segment\n'), ((2718, 2791), 'emoji.emojize', 'emoji.emojize', (['""":egg: There is nothing better than scrambled eggs! :egg:"""'], {}), "(':egg: There is nothing better than scrambled eggs! :egg:')\n", (2731, 2791), False, 'import emoji\n'), ((2912, 2928), 'slackbot_wems.chris.segment7.hacker', 'segment.hacker', ([], {}), '()\n', (2926, 2928), True, 'import slackbot_wems.chris.segment7 as segment\n'), ((2989, 3008), 'slackbot_wems.chris.light.printReading', 'lite.printReading', ([], {}), '()\n', (3006, 3008), True, 'import slackbot_wems.chris.light as lite\n'), ((3036, 3049), 'time.sleep', 'time.sleep', (['(1)'], {}), '(1)\n', (3046, 3049), False, 'import time\n')]