Beispiel #1
0
    def fans(self):

        if ("ON" in self.message):
            '''turn lights on'''
            print("here")
            TTS("Turning fans on!")
            # GPIO.output(2,False)

        elif "OFF" in self.message:
            '''turn lights off'''
            TTS("Turning fans off!")
Beispiel #2
0
    def wikipedia_search(message):
        global SongPlaying
        global youtube_instance

        summary = wikipedia.summary(message[14:], sentences=1)

        if (SongPlaying == True):
            youtube_instance.instructions("PAUSE")
            TTS(summary)
            youtube_instance.instructions("RESUME")

        else:
            TTS(summary)
Beispiel #3
0
    def lights(self):

        if ("ON" in self.message):
            '''turn lights on'''
            obj = TTS("Turning lights on!")
            del obj
            # GPIO.output(3,False)
            print("Here")

        elif "OFF" in self.message:
            '''turn lights off'''
            obj = TTS("Turning lights off!")
            del obj
Beispiel #4
0
    def play_anthem():

        global SongPlaying
        print("playing a song...")
        TTS("Playing a song")
        SongPlaying = True
        youtube_instance.play_anthem()
Beispiel #5
0
    def play_my_playlist():

        global youtube_instance
        global SongPlaying
        print("In play my playlist...")
        TTS("Playing your playlist...")
        SongPlaying = True
        youtube_instance.play_playlist()
Beispiel #6
0
    def on_message(client, userdata, mssg):
        global user_id
        if "GladOs/userid" in mssg.topic:
            id = str(mssg.payload)[2:-1]

            print("In mqttclient to get userid", id)
            user_id = id
            TTS("New user id received. Welcome,", id)

        execute(client)
Beispiel #7
0
    def setpassword(message, client):
        global youtube_instance
        global password
        global user_id
        print("In set password")

        with open(os.path.join(sys.path[0], "assets/ussername_pass.json"),
                  'r+') as passfile:
            data = json.load(passfile)
            email = data["email"]
            passs = data["password"]
            credentials = message[9:]
            username, password_ = credentials.split(",")
            print(username)
            print(password_)
            if passs == "":
                print("Here")
                hashpass = hashlib.sha256(str.encode(password_)).hexdigest()
                print(hashpass)
                data = {"email": username, "password": hashpass}
                passfile.seek(0)
                json.dump(data, passfile)
                passfile.truncate()
                youtube_instance = Youtube(username, password_)
                password = password_
                client.publish("GladOs/messages/raspberry2phone" + user_id,
                               "Everything OK")
                TTS("I am ready to take your commands master!")
            else:

                if (hashlib.sha256(
                        str.encode(password_)).hexdigest() == passs):
                    print("Here")
                    youtube_instance = Youtube(username, password_)
                    client.publish("GladOs/messages/raspberry2phone" + user_id,
                                   "Everything OK")
                    TTS("I am ready to take your commands master!")
                else:
                    client.publish("GladOs/messages/raspberry2phone" + user_id,
                                   "Wrong password enter again!")
Beispiel #8
0
 def playsong(self,message):
     TTS("Playing "+self.song)
     
     self.browser.get("https://www.google.com")
     self.song = message
     search = self.browser.find_element_by_name('q')
     search.send_keys(self.song+" Youtube")
     search.send_keys(Keys.RETURN)
     self.VIDEOSTAT=1
     try:
         self.browser.find_element_by_xpath("//*[@id='rso']/div[1]/div/div/div/div[1]/div[2]/div/div/div[2]/h3/a/h3").click()
     except:
         self.browser.find_element_by_xpath("//*[@id='rso']/div/div/div[1]/div/div/div[1]/a/h3").click()
Beispiel #9
0
    def setpassword(message, client):
        global youtube_instance
        global password
        global user_id
        print("In set password")

        credentials = message[9:]
        username, password_ = credentials.split(",")
        print(username)
        print(password_)

        youtube_instance.login(username, password_)

        if (youtube_instance.loginstate == 1):
            password = password_
            client.publish("GladOs/messages/raspberry2phone" + user_id,
                           "Everything OK")
            TTS("I am ready to take your commands master!")
        else:
            client.publish("GladOs/messages/raspberry2phone" + user_id,
                           "Wrong password enter again!")
            TTS("Something is wrong. Please try again. Make sure you are entering the correct password and email."
                )
Beispiel #10
0
    def resetAcc(client):
        global active

        with open(os.path.join(sys.path[0], "assets/ussername_pass.json"),
                  'r+') as passfile:
            data = {"email": "", "password": ""}
            passfile.seek(0)
            json.dump(data, passfile)
            passfile.truncate()
        with open(os.path.join(sys.path[0], "assets/user_id.json"),
                  'r+') as user_id_file:
            data = {"username": ""}
            user_id_file.seek(0)
            json.dump(data, user_id_file)
            user_id_file.truncate()

        print("I have reset myself master!")
        TTS("I have reset myself master!")
        client.disconnect()
        active = False
        sys.exit()
Beispiel #11
0
    def resetAcc(client):
        global active

        with open(os.path.join(sys.path[0], "assets/user_id.json"),
                  'r+') as user_id_file:
            data = {"username": ""}
            user_id_file.seek(0)
            json.dump(data, user_id_file)
            user_id_file.truncate()

        with open(os.path.join(sys.path[0], "assets/my_playlist.json"),
                  'r+') as playlist_file:
            data = {"songs": []}
            playlist_file.seek(0)
            json.dump(data, playlist_file)
            playlist_file.truncate()

        TTS("I have reset myself master!")
        client.disconnect()
        active = False
        sys.exit()
Beispiel #12
0
 def instantiate_dialogflow(message):
     df_obj = DialogFlow(message)
     if (df_obj.response):
         TTS(df_obj.response)
Beispiel #13
0
 def welcome_user(id):
     TTS("Welcome back " + id)
Beispiel #14
0
'''this is the beginning of the script'''
'''initially we check whether the user had loggin in before or not'''
'''if he had then we will use that logged in username and proceed'''
'''otherwise the mqtt client listens to the userid channel to receive the username from phone'''
with open(os.path.join(sys.path[0], "assets/user_id.json")) as user_id_file:
    data = json.load(user_id_file)
    user_id = data["username"]
    print(user_id)
    if (user_id == ""):
        mqtt_thred_to_get_userid = threading.Thread(
            target=mqttclient_to_get_userid)
        mqtt_thred_to_get_userid.daemon = True
        mqtt_thred_to_get_userid.start()
    else:
        TTS("Welcome back " + user_id)
'''this loop checks whether the username had been passed or not.'''
'''if new username is passed it is written onto disk'''
while (True):
    if (len(user_id) > 0):
        with open(os.path.join(sys.path[0], "assets/user_id.json"),
                  'r+') as user_id_file:
            data = {"username": user_id}
            user_id_file.seek(0)
            json.dump(data, user_id_file)
            user_id_file.truncate()
        break
youtube_instance = Youtube()
'''calling the main message thread from here'''
mqtt_thred = threading.Thread(target=mqttclient)
mqtt_thred.daemon = True