Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Importing required Libraries
- import imaplib, time, RPi.GPIO as GPIO
- # Variables
- username = "YOUR GOOGLE ACCOUNT EMAIL"
- password = "YOUR GOOGLE ACCOUNT PASSWORD"
- def init():
- print("[*] Initialising Connection to IMAP-Server...")
- mail = imaplib.IMAP4_SSL('imap.gmail.com')
- mail.login(username, password)
- print("[+] Selecting Inbox...")
- print("[*] Initialising GPIOs...")
- GPIO.setmode(GPIO.BCM)
- GPIO.setup(17, GPIO.OUT)
- GPIO.setup(27, GPIO.OUT)
- GPIO.setup(22, GPIO.OUT)
- return mail
- def stage1():
- print("[+] Selected STAGE1")
- GPIO.output(17, 1)
- def stage2():
- print("[+] Selected STAGE2")
- GPIO.output(27, 1)
- def stage3():
- print("[+] Selected STAGE3")
- GPIO.output(22, 1)
- def dark():
- GPIO.output(17, 0)
- GPIO.output(27, 0)
- GPIO.output(22, 0)
- def retrMail(obj):
- print("[*] Retrieving new unread Mails... ", end="")
- obj.select("inbox")
- return len(obj.search(None, 'Unseen')[1][0].split())
- def analyze(new):
- if new >= 1 and new <= 3:
- dark()
- stage1()
- elif new >= 4 and new <= 10:
- dark()
- stage1()
- stage2()
- elif new >= 10:
- dark()
- stage1()
- stage2()
- stage3()
- else:
- print("[-] No unread Mails. Switching to dark")
- dark()
- def main():
- obj = init()
- new = retrMail(obj)
- print(new)
- analyze(new)
- try:
- while 1:
- time.sleep(660) # 11 Minutes = 660 Seconds
- new = retrMail(obj)
- print(new)
- analyze(new)
- except KeyboardInterrupt:
- GPIO.cleanup()
- exit(0)
- main()
Add Comment
Please, Sign In to add comment