os.system("shutdown /s /t 0") elif(parsedBody.find("Speak")!=-1): print("I'll Tell You!") os.system('nircmd.exe speak text "'+parsedBody[5:]) elif(parsedBody == "Screen Off"): print("Turning Screen Off") os.system('nircmd.exe monitor off') elif(parsedBody =="Screen On"): print("Turning Screen On") os.system('nircmd.exe monitor on') elif(parsedBody =="Open tray"): print("Opening cd tray") os.system('nircmd.exe cdrom open') pb = Pushbullet(KEY) pb.delete_pushes()#start with fresh server, no existing commands pb.refresh() oldCreated= "" pushType= "" while(True): pushes = pb.get_pushes() if(len(pushes)>0): latest= str(pushes[0]) latestSep= latest.split(",") print(pushes[0]) print('\n')
def turn_off(device): print("turning off device") def open(text): print("opening..") if text[0].strip().lower() == "youtube": webbrowser.open('http://youtube.com', new=2) command_dict = {"turn on": turn_on, "turn off": turn_off, "open": open} pb = Pushbullet(API_KEY) pb.delete_pushes() def main(): s = Listener(account=pb, on_push=on_push, http_proxy_host=HTTP_PROXY_HOST, http_proxy_port=HTTP_PROXY_PORT) try: s.run_forever() except KeyboardInterrupt: s.close() if __name__ == '__main__':