示例#1
0
def rappel():
    conteur_rappel = 1
    rappel = chemin_vers_fichier_de_note
    while conteur_rappel == 1:
        f = open(rappel, 'r')
        lignes = f.readlines()
        f.close()
        minute = (time.strftime("%H:%M"))
        date = time.strftime('%D')

        for ligne in lignes:
            if date in ligne and minute in ligne:
                ligner = ligne.replace(date, '')
                ligner = ligner.replace(minute, '')

                reponse = (choice(liste_rappel) + ligner)
                print(reponse)
                parole.dit(reponse)
                mon_fichier = open(rappel, "r")
                ancien_contenu = mon_fichier.read()
                mon_fichier.close

                nouveau_contenu = ancien_contenu.replace(ligne, '')
                print(nouveau_contenu)

                mon_fichier = open(chemin_vers_fichier_de_note, "w")
                mon_fichier.write(nouveau_contenu)
                mon_fichier.close()
示例#2
0
def afficher_toutes_les_notes():
  reponse = ""
  for note in liste_note:
   empl = liste_note.index(note)
   empl = int(empl) + 1
   empl = str(empl)
   reponse = reponse + " " + ",note " + str(empl) + (" : ") + note.replace("zh;","")
   parole.dit(reponse)
示例#3
0
def meteo_reveil(ville):
  print("http://api.openweathermap.org/data/2.5/weather?q=" + ville + "&units=metric&appid=eec7b314c20283986153a77fcc6d49cc")
  url = urllib.request.urlopen("http://api.openweathermap.org/data/2.5/weather?q=" + ville + "&units=metric&appid=eec7b314c20283986153a77fcc6d49cc")
  output = url.read().decode('utf-8')
  raw_api_dict = json.loads(output)
  url.close()
  data = dict(
  city=raw_api_dict.get('name'),
  country=raw_api_dict.get('sys').get('country'),
  temp=raw_api_dict.get('main').get('temp'),
  temp_max=raw_api_dict.get('main').get('temp_max'),
  temp_min=raw_api_dict.get('main').get('temp_min'),
  humidity=raw_api_dict.get('main').get('humidity'),
  pressure=raw_api_dict.get('main').get('pressure'),
  sky=raw_api_dict['weather'][0]['description'],
  sunrise=time_converter(raw_api_dict.get('sys').get('sunrise')),
  sunset=time_converter(raw_api_dict.get('sys').get('sunset')),
  wind=raw_api_dict.get('wind').get('speed'),
  wind_deg=raw_api_dict.get('deg'),
  dt=time_converter(raw_api_dict.get('dt')),
  cloudiness=raw_api_dict.get('clouds').get('all')
   )
  m_symbol = '\xb0' + 'C'
  m_symbol = '\xb0' + 'C'
  cielle =  data["sky"]
  if cielle == ("Clear"):
   ciel = ("claire")
   temp = " ,Le temps est " + ciel
  elif cielle == ("Clouds") or cielle == ("broken clouds"):
   ciel = ("nuageux")
   temp = " ,Le temps est " + ciel
  elif cielle == ("Sunny"):
   temp = " ,Le temps est " + ciel
   ciel = ("ensolleilé")
   temp = " ,Le temps est " + ciel
  elif cielle == ("clear sky"):
   ciel = ("dégagé")
   temp = " ,Le temps est " + ciel
  elif cielle == ("overcasts clouds"):
   ciel = ("éxtrémement nuageux")
   temp = " ,Le temps est " + ciel
  elif cielle == ("scattered clouds"):
   ciel = ("nuageux") 
   temp = " ,Le temps est " + ciel
  else:
   temp = ""
  
  if int('{}'.format(data["temp_min"])) <= 0:
   reponse = 'Il est temps de vous levez, monsieur ,Il fait particulièrment froid, aujourdh\'ui'  + temp + ' la température maximal est de {}'.format(data["temp_max"]) + (" degré") + ' et la température minimale de {}'.format(data["temp_min"]) + (" degré")
  elif int('{}'.format(data["temp_max"])) >= 28:
   reponse = 'Il est temps de vous levez, monsieur ,Il fait particulièrment chaud, aujourdh\'ui' + temp + ' la température maximal est de {}'.format(data["temp_max"]) + (" degré") + ' et la température minimale de {}'.format(data["temp_min"]) + (" degré")   
  else:
    reponse =  "Il est temps de vous levez, monsieur ,la température maximal est de {}'.format(data["temp_max"]) + (" degré") + ' et la température minimale de {}'.format(data["temp_min"]) + (" degré")"
  parole.dit(reponse)
示例#4
0
def bonjour():
    vérifie_jour = time.strftime('%d/%m')
    if vérifie_jour == ('12/24') or vérifie_jour == ('12/25'):
        hello = ("Joyeux noël, Monsieur")
    else:
        if (heure) <= ("11"):
            hello = choice(bonjourm)
        elif (heure) <= ("17") and (heure) > ("11"):
            hello = choice(liste_bonjour)
        elif (heure) <= ("24") and (heure) > ("17"):
            hello = choice(bonjours)
        help = choice(liste_help)
        parole.dit(hello + " " + help)
示例#5
0
def actualite():
 stop = 0
 global stop
 res = requests.get("https://news.google.com/news?cf=all&hl=fr&pz=2&ned=fr&topic=t&output=rss")
 doc = lxml.etree.fromstring(res.content)
 for item in doc.xpath('//item'):
   title = item.find('title').text
   threading.Thread(target=parole.dit(title)).start()
   if stop == 1:
   	break
示例#6
0
def alerte():
    def rafraichir():
        mail = imaplib.IMAP4_SSL('imap.outlook.com')
        mail.login(adresse_email, mot_de_passe_de_ladresse)
        mail.list()
        mail.select("inbox")
        result, data = mail.search(None, "ALL")
        ids = data[0]
        id_list = ids.split()
        latest_email_id = id_list[-1]
        result, data = mail.fetch(latest_email_id, "(RFC822)")
        raw_email = data[0][1]
        return raw_email

    dernierMail = rafraichir()
    while u == 0:
        mailApresRafraichissement = rafraichir()
        if dernierMail != mailApresRafraichissement:
            global notif
            notif += 1
            parole.dit("Vous avez reçu un nouveau mail, Monsieur")
            dernierMail = mailApresRafraichissement
示例#7
0
def affichier_une_note(phrase):
   if int(len(liste_note)) == 0:
     parole.dit("Il n\'y a aucune note enregistrer dans ma mémoire Monsieur") 
   else: 
    chiffre_dans_la_phrase = re.findall('\d+', phrase)
    nombre_de_note = len(liste_note)
    conteur_de_nombre = 0
    for chiffre in chiffre_dans_la_phrase:
     recup = chifre
     chiffre = int(chiffre) - 1
     chiffre = str(chiffre)
     for note in liste_note: 
      emplacement_note = liste_note.index(note)
      if int(chifre) - int(emplacement_note) == 0: 
       parole.dit("La note numéro " + recup + " est : " + note.replace("zh;",""))
      else:
         conteur_de_nombre = conteur_de_nombre + 1
      if conteur_de_nombre == nombre_de_note:
         parole.dit("La note que vous soubaité afficher n'éxiste pas") 
示例#8
0
def éfface(phrase):
 chiffre = re.findall('\d+', phrase)
 nombre_vérification = len(liste_note)
 conteur_de_nombre = 0
 nombre_de_note = len(liste_note)
 if nombre_de_note == 0:
   parole.dit("Il n\'ya aucun note enregistrer dans ma mémoire")
 else:
  for chifre in chiffre:
   chifre = int(chifre) - 1
   chifre = str(chifre)
   for note in liste_note:
    emplacement_note = liste_note.index(note)
    if int(chifre) - int(emplacement_note) == 0:
       del liste_note[int(chifre)]
       fichier_de_note = open(chemin_vers_fichier_de_note, "w")
       fichier_de_note.write( " ".join(str(x) for x in liste_note))
       fichier_de_note.close()
       parole.dit("La note est supprimé !")
    else:
       conteur_de_nombre = conteur_de_nombre + 1
       if conteur_de_nombre == nombre_vérification:
         parole.dit("La note que vous m'avez demandé d'éffacer n'éxiste pas, Monsieur")
示例#9
0
def remove_all():
  liste_note = []
  fichier_de_note = open(chemin_vers_fichier_de_note, "w") 
  fichier_de_note.write("")
  fichier_de_note.close()
  parole.dit("J\'ai supprimé toutes les notes")
def traitement():
 while vérification == 1:
 #conexion avec le fichier snowboy
  connexion_principale = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  connexion_principale.bind((hote, port))
  connexion_principale.listen(5)
  print("Le serveur écoute à présent sur le port {}".format(port))
  serveur_lance = True
  clients_connectes = []
  
  while serveur_lance:
   connexions_demandees, wlist, xlist = select.select([connexion_principale], [], [], 0.05)
   for connexion in connexions_demandees:
      connexion_avec_client, infos_connexion = connexion.accept()
      clients_connectes.append(connexion_avec_client)
   clients_a_lire = []
   try:
      clients_a_lire, wlist, xlist = select.select(clients_connectes,
              [], [], 0.05)
   except select.error:
       pass
   else:
    for client in clients_a_lire:
     msg_recu = client.recv(1024)
     requete = msg_recu.decode()
     print(requete)
     os.system("killall python")
#Si le mot clé "Cisco" est détécté
     if requete == 1:
     	phrase = reconnaissance_vocale.reconnaissance()
     	content_french = [phrase]
        for i in content_french:
         phd = (word_tokenize(i, language='french'))
         print(phd)
        if "close" in phrase:
        	exit()
        elif "heure" in phrase and "note" not in phrase or "heure" in phrase and "rappel" not in phrase or "heure" in phrase and "réveil" not in phrase:
            heure = (time.strftime("Il est %H heures %M monsieur."))
            parole.dit(heure)
            snowboy()
        elif "lance" in phrase and "internet" in phrase and "recherche" not in phrase or "ouvre" in phrase and "google" in phrase and "recherche" not in phrase:
            webbrowser.open("https://www.google.fr")
            parole.dit("C\'est fait !")
            snowboy()
        elif "raconte" in phrase and "histoire" in phrase and "rappel" not in phrase and "note" not in phrase:
            reponse = choice(['C\'est l\'histoire d\'un assistant virtuel trés intélligent','Et il vécurent heureux et eurent baucoup d\'enfants'])
            parole.dit(reponse)
            snowboy() 
        elif "je" in phrase and "t'aime" in phrase and "note" not in phrase and "rappel" not in phrase:
        	parole.dit("Merci !")
        	snowboy()
        elif "lance" in phrase and "youtubez" in phrase and "recherche" not in phrase or "ouvre" in phrase and "youtube" in phrase and "recherche" not in phrase:
            webbrowser.open("www.youtube.com")
            parole.dit("Tout de suite Monsieur")
            snowboy()
        elif "combien" in phrase and "apareil" in phrase and "conécté" in phrase and "note" not in phrase and "rappel":
        	parole.dit("je regarde sa")
        	nombre = détéction_apareil.combien_dapareil()
        	if liste_apareil = []:
        		parole.dit("Il n'ya aucun appareil conécté a votre réseau")
            else:
            	parole.dit("Il ya" + nomnbre + "conécté a votre réseau Monsieau" )
            snowboy()
        elif "prend" in phrase and "note" in phrase or "ajoute" in phrase and "note" in phrase:
        	phrase = phrase.replace("prend","")         
            phrase = phrase.replace("note","")
            phrase = phrase.replace("ajoute","")
            note = phrase
            note.add_note(note)
            snowboy()
        elif "combien" in phrase and "note" in phrase or "combien" in a and "note" in phrase:
        	nombre_de_note = note.combien()
        	snowboy()
        elif "éfface" in a and "tout" not in a or "supprime" in a and "tout" not in a:
            note.éfface(phrase)
            snowboy()
        elif "éfface" in phrase and "tout" in phrase and "note" in phrase:
        	note.remove_all()
 	snowboy()
 elif "éfface" in a and "tout" not in a or "supprime" in a and "tout" not in a:
     note.éfface(phrase)
     snowboy()
 elif "éfface" in phrase and "tout" in phrase and "note" in phrase:
 	note.remove_all()
     snowboy()
 elif "li" in phrase and "note" in phrase and "tout" not in phrase:
 	note.affichier_une_note(phrase)
 	snowboy()
 elif "li" in phrase and "note" in phrase and "tout" in phrase:
 	note.afficher_toutes_les_notes()
 	snowboy()
 elif "vérifie" in phrase and "mail" in phrase and "note" not in phrase and "rappel" not in phrase or "combien" in phrase and "non" in phrase and "mail" in phrase and "note" not in phrase and "rappel" not in phrase:
     notif = alerte_mail.notif()
     parole.dit("Vous avez " + notif + " mail non lue")
     snowboy()
 elif "présente" in phrase and "toi" in phrase and "note" not in phrase and rappel not in phrase:
 	reponse = ("bonjour, je m'apelle CISCO et je suis votre nouvelle assistant virtuel, je suis capable d'éxécuté des tache plus ou moins simple sur votre PC")
     parole.dit(reponse)
     snowboy()
 elif "tu" in phrase and "sert" in phrase and "quoi" in phrase and "note" not in phrase and rappel not in phrase:
     reponse = "Je suis capable d'éxécuter des tache plus ou moins simple sur votre pc, vos apareil domotique, je peut aussi répondre a beaucoup de vos question, vous rappéler ce que vous souhaiter vous réveiller tout les matin et de nombreuse autre chose"
     parole.dit(reponse)
     snowboy()
 elif "actualité" in phrase and "higt" nit in phrase and "numérique" not in phrase and "note" not in phrase and "rappel" not in phrase:
     threading.Thread(target=actualité.reconnaissance_actualité).start()
     actualité.actualite()
     snowboy()
 elif "musique" in phrase and "note" not in phrase and "rappel" not in phrase:
 	threading.Thread(target=musique.reconnaissance.musique).start()