Esempio n. 1
0
def notesOperations(order):
    if any(x in order for x in notesAddConstants):
        addNewNote()
        jc.jarvisTalk("Nota finalizada")
    elif any(x in order for x in knowNotes):
        enumerateNotes()
    elif any(x in order for x in noteContent):
        doThingsInNotes(order, "leer")
    elif any(x in order for x in modifyNote):
        doThingsInNotes(order, "actualizar")
    elif any(x in order for x in delteNote):
        doThingsInNotes(order, "borrar")
Esempio n. 2
0
def addNewNote():
    try:

        fileName = ""

        while len(fileName) == 0:
            jc.jarvisTalk("¿Cómo quieres llamar a la nota?")
            fileName = jc.listen().lower()
            if len(fileName) == 0:
                jc.jarvisTalk("No has dicho nada")
        fileName = "".join(fileName.split(" ")) + ".txt"
        jc.jarvisTalk("Nombre establecido. " + fileName.replace("txt", "") +
                      ". Creando archivo.")
        subprocess.call(["touch ./core/notes/" + fileName], shell=True)
        jc.jarvisTalk("Archivo creado.")
        addRowsToNote(fileName)

    except:
        jc.jarvisTalk("Ooops. Me he quedado pillada")
Esempio n. 3
0
def enumerateNotes():
    allNotes = getAllNotes()
    if len(allNotes) > 0:
        jc.jarvisTalk("Tus notas son:")
        jc.jarvisTalk(allNotes)
    else:
        jc.jarvisTalk("No existen notas")
Esempio n. 4
0
def doThingsInNotes(order, mode):

    allNotes = getAllNotes()
    if len(allNotes) > 0:
        fileName = "".join(order.split("nota")[1]).strip()
        if len(fileName) == 0:
            jc.jarvisTalk("¿Cuál de ellas?")
            fileName = "".join(jc.listen().lower().split(" ")) + ".txt"
        else:
            fileName = "".join(fileName.split(" ")) + ".txt"

        if fileName.replace("txt", "") not in getAllNotes():
            jc.jarvisTalk("No he encontrado la nota " + fileName + ".")
            jc.jarvisTalk("¿Quieres saber cuáles tienes?")
            answer = jc.listen()
            if answer == "sí":
                enumerateNotes()
                jc.jarvisTalk("¿Qué nota quieres " + mode + "?")
                doThingsInNotes("nota " + jc.listen(), mode)

        else:
            noteSwitchOperato(fileName, mode)
    else:
        jc.jarvisTalk("No tienes notas")
Esempio n. 5
0
def addRowsToNote(fileName):
    jc.jarvisTalk("Comienzo a tomar notas. Para finalizar di: Finalizar nota")
    newLine = ""
    while newLine != "finalizar nota":
        newLine = makeTrans(jc.listen())
        if len(newLine) > 0 and newLine != "finalizar nota":
            subprocess.call(
                ["echo '" + newLine + ".' >> ./core/notes/" + fileName],
                shell=True)
            jc.jarvisTalk(choice(afirmativeNoteWrited))
        elif len(newLine) == 0:
            jc.jarvisTalk("No has dicho nada")
Esempio n. 6
0
def noteSwitchOperato(fileName, mode):
    try:
        if mode == "leer":
            noteContent = getShellOutput("cat ./core/notes/" + fileName)
            jc.jarvisTalk(noteContent)
        elif mode == "actualizar":
            addRowsToNote(fileName)
        elif mode == "borrar":
            subprocess.call(["rm ./core/notes/" + fileName], shell=True)
        jc.jarvisTalk("Nota" + noteAsnwers[mode])

    except:
        jc.jarvisTalk("Error en los parámetros")
Esempio n. 7
0
def deleteNote():

    answer = ""
    while len(answer) == 0:
        jc.jarvisTalk("¿Qué nota quieres eliminar?")
Esempio n. 8
0
def getAllNotes():
    try:
        return getShellOutput("ls ./core/notes/").replace("txt", "")
    except:
        jc.jarvisTalk("No existen notas")
        return ""
Esempio n. 9
0
def findRoutes():
    jc.jarvisTalk("Establece un punto de partida")
    origin = jc.listen()
    jc.jarvisTalk("Añade un destino")
    destination = jc.listen()
    moreDestinations = []
    answer = ""
    jc.jarvisTalk("Para finalizar di. Finalizar ruta")
    while "finalizar ruta" not in answer:
        try:
            jc.jarvisTalk(random.choice(destinations))
            answer = jc.listen()
            if len(answer) > 0 and "finaliza" not in answer:
                jc.jarvisTalk(random.choice(destinationAnswer))
                moreDestinations.append(jc.listen())
            elif "finaliza" not in answer:
                jc.jarvisTalk("No has dicho nada")
        except:
            jc.jarvisTalk(random.choice(iDontUnderstand))
    jc.jarvisTalk("Petición finalizada. Buscando rutas.")
    url = (
        "https://www.google.es/maps/dir/"
        + ",+".join(origin.split(" "))
        + "/"
        + ",+".join(destination.split(" "))
    )

    for dest in moreDestinations:
        url += "/" + ",+".join(dest.split(" "))

    openGoogle(url)
    jc.jarvisTalk("¡Buen viaje!")
Esempio n. 10
0
import sys
import subprocess

sys.path.insert(0, "./core")
import core.jarvisCore as jc
from random import choice
from core.talk.constants import *
from core.orders.constants import *
from core.orders.system.recording import *
import core.orders.web_operations.scraping as sc

mainThread = True

while mainThread:
    if "María" in jc.listen().strip():
        jc.jarvisTalk(choice(awaitingOrders))
        newOrder = jc.listen().strip()
        print("NEW ORDER " + newOrder)
        if any(x in newOrder for x in disconectingOrders):
            mainThread = False
            jc.jarvisTalk(choice(byeBye))

        elif "iniciar" in newOrder:
            jc.initOrderProtocol(newOrder)

        elif "busca" in newOrder:
            jc.searchInBrowserProtocol(newOrder)

        elif (any(order in newOrder for order in answerQuestionOrders)
              or "cuál" in newOrder):
            jc.answerQuestionsProtocol(newOrder)