Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import techcore , os , time , sys , re , pyperclip
- name = "Juno"
- operatorRegex = re.compile(r"""(
- ((.*) #Testo +
- (\s+))? #Spazi iniziali
- (quanto\s{1}?fa|qual'è\s{1}?il\s{1}?risultato di|calcolami)? #Domanda
- (\s*) #Spazio
- (\d+) #Primo Numero
- (\s*) #Spazio
- (\+|\*|-|/|\*\*) #Operatore
- (\s*) #Spazio
- (\d+) #Secondo Numero
- )""" , re.VERBOSE)
- scfRegex = re.compile(r"""(
- (vuoi\s{1}giocare\s{1}a\s{1}sasso\s{1}carta\s{1}forbic(e|i)
- |giochiamo\s{1}a\s{1}sasso\s{1}carta\s{1}forbic(e|i)
- |giochiamo\s{1}a\s{1}scf|
- vuoi\s{1}giocare\s{1}a\s{1}scf)
- )""" , re.VERBOSE)
- noSaveExitRegex = re.compile(r"""(
- ((.*)(\s+))?(esci(\s{1})?senza(\s{1})?salvare)
- )""" , re.VERBOSE)
- cryptRegex = re.compile(r"""
- (([a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z]*)
- (\s{1}))?
- (crypt)
- (\s{1})
- ([a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|_]*)
- """ , re.VERBOSE)
- deCryptRegex = re.compile(r"""
- (([a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z]*)
- (\s{1}))?
- (decrypt)
- (\s{1})
- ([a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|_]*)
- """ , re.VERBOSE)
- if not os.path.isfile("memory.m") :
- memory = {"come ti chiami" : "Mi chiamo " + name , "quanti anni hai" : "2 anni" , "come stai" : "Bene" , "ciao " + name.lower() : "Ciao anche a te" , "bravo " + name.lower() : "Grazie!" , "sai chi sono io" : "Tu sei un Utente!"}
- else :
- memory = techcore.loadFromFile("memory.m")
- try:
- print("Ciao, sono " + name + ", cosa mi vuoi dire?")
- while True :
- d = techcore.semplifyText(input(">>>"))
- if d == "" :
- continue
- if "resetta la memoria" in d :
- print("Vuoi davvero Cancellare?")
- s = techcore.semplifyText(input(">>>"))
- if "si" in s :
- os.unlink("memory.m")
- memory = {"come ti chiami" : "Mi chiamo " + name , "quanti anni hai" : "2 anni" , "come stai" : "Bene" , "ciao " + name.lower() : "Ciao anche a te" , "bravo " + name.lower() : "Grazie!" , "sai chi sono io?" : "Tu sei " + UName}
- print("Memoria Resettata!")
- else :
- print("Annullato")
- continue
- if operatorRegex.search(d) != None :
- Match = operatorRegex.search(d)
- Num1 = int(Match.group(7))
- Num2 = int(Match.group(11))
- Operator = Match.group(9)
- ris = 0
- if Operator == "+" :
- ris = Num1 + Num2
- elif Operator == "-" :
- ris = Num1 - Num2
- elif Operator == "*" :
- ris = Num1 * Num2
- elif Operator == "/" :
- ris = Num1 / Num2
- elif Operator == "**" :
- ris = Num1 ** Num2
- if len(str(ris)) < 40 :
- print("Il risultato è: " + str(ris))
- else :
- print("Il risultato è:\n" + str(ris))
- continue
- if scfRegex.search(d) != None :
- print("\nOk, che vinca il migliore ;)\n")
- time.sleep(1)
- techcore.SCF()
- print("\nBella giocata eh? :)\n")
- time.sleep(1)
- continue
- if noSaveExitRegex.search(d) != None :
- print("\nCiao, non salverò!\n")
- time.sleep(1)
- raise NameError
- if cryptRegex.search(d) != None :
- Match = cryptRegex.search(d)
- text = Match.group(6)
- cryptText = techcore.crypt(text)
- print("Il testo cryptato è: " + cryptText)
- pyperclip.copy(cryptText)
- print("Testo copiato negli appunti!")
- continue
- if deCryptRegex.search(d) != None :
- Match = cryptRegex.search(d)
- text = Match.group(6)
- deCryptText = techcore.deCrypt(text)
- print("Il testo decryptato è: " + deCryptText)
- pyperclip.copy(deCryptText)
- print("Testo copiato negli appunti!")
- continue
- if d == "esci" :
- print("\nCiao! Spero di rivederti!\n")
- time.sleep(1)
- sys.exit()
- if d in memory :
- print(memory[d])
- else :
- print("Non ho capito, cosa devo rispondere?")
- n = input(">>>")
- nn = techcore.semplifyText(n)
- if nn != "niente" :
- memory[d] = n
- except NameError :
- sys.exit()
- finally :
- techcore.saveInFile(memory , "memory.m")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement