Advertisement
MRtecno98

Project Juno V. 2.0.0

May 2nd, 2017
1,165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.59 KB | None | 0 0
  1. import techcore , os , time , sys , re , pyperclip
  2.  
  3. name = "Juno"
  4.  
  5. operatorRegex = re.compile(r"""(
  6.    ((.*)               #Testo +
  7.    (\s+))?             #Spazi iniziali
  8.    (quanto\s{1}?fa|qual'è\s{1}?il\s{1}?risultato di|calcolami)? #Domanda
  9.     (\s*)       #Spazio
  10.     (\d+)       #Primo Numero
  11.     (\s*)       #Spazio
  12.     (\+|\*|-|/|\*\*)    #Operatore
  13.     (\s*)       #Spazio
  14.     (\d+)       #Secondo Numero
  15.    )""" , re.VERBOSE)
  16.  
  17. scfRegex = re.compile(r"""(
  18.    (vuoi\s{1}giocare\s{1}a\s{1}sasso\s{1}carta\s{1}forbic(e|i)
  19.    |giochiamo\s{1}a\s{1}sasso\s{1}carta\s{1}forbic(e|i)
  20.    |giochiamo\s{1}a\s{1}scf|
  21.    vuoi\s{1}giocare\s{1}a\s{1}scf)
  22.  
  23. )""" , re.VERBOSE)
  24.  
  25. noSaveExitRegex = re.compile(r"""(
  26.  
  27.    ((.*)(\s+))?(esci(\s{1})?senza(\s{1})?salvare)
  28.  
  29. )""" , re.VERBOSE)
  30.  
  31. cryptRegex = re.compile(r"""
  32.    (([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]*)
  33.    (\s{1}))?
  34.    (crypt)
  35.    (\s{1})
  36.    ([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|_]*)
  37.  
  38. """ , re.VERBOSE)
  39.  
  40. deCryptRegex = re.compile(r"""
  41.    (([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]*)
  42.    (\s{1}))?
  43.    (decrypt)
  44.    (\s{1})
  45.    ([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|_]*)
  46.  
  47. """ , re.VERBOSE)
  48.  
  49. if not os.path.isfile("memory.m") :
  50.     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!"}
  51. else :
  52.     memory = techcore.loadFromFile("memory.m")
  53.  
  54. try:
  55.  
  56.     print("Ciao, sono " + name + ", cosa mi vuoi dire?")
  57.     while True :
  58.         d = techcore.semplifyText(input(">>>"))
  59.  
  60.         if d == "" :
  61.             continue
  62.  
  63.         if "resetta la memoria" in d :
  64.             print("Vuoi davvero Cancellare?")
  65.             s = techcore.semplifyText(input(">>>"))
  66.             if "si" in s :
  67.                 os.unlink("memory.m")
  68.                 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}
  69.                 print("Memoria Resettata!")
  70.             else :
  71.                 print("Annullato")
  72.             continue
  73.        
  74.         if operatorRegex.search(d) != None :
  75.             Match = operatorRegex.search(d)
  76.             Num1 = int(Match.group(7))
  77.             Num2 = int(Match.group(11))
  78.             Operator = Match.group(9)
  79.             ris = 0
  80.             if Operator == "+" :
  81.                 ris = Num1 + Num2
  82.             elif Operator == "-" :
  83.                 ris = Num1 - Num2
  84.             elif Operator == "*" :
  85.                 ris = Num1 * Num2
  86.             elif Operator == "/" :
  87.                 ris = Num1 / Num2
  88.             elif Operator == "**" :
  89.                 ris = Num1 ** Num2
  90.  
  91.             if len(str(ris)) < 40 :
  92.                 print("Il risultato è: " + str(ris))
  93.             else :
  94.                 print("Il risultato è:\n" + str(ris))
  95.             continue
  96.  
  97.         if scfRegex.search(d) != None :
  98.             print("\nOk, che vinca il migliore ;)\n")
  99.             time.sleep(1)
  100.             techcore.SCF()
  101.             print("\nBella giocata eh? :)\n")
  102.             time.sleep(1)
  103.             continue
  104.  
  105.         if noSaveExitRegex.search(d) != None :
  106.             print("\nCiao, non salverò!\n")
  107.             time.sleep(1)
  108.             raise NameError
  109.  
  110.         if cryptRegex.search(d) != None :
  111.             Match = cryptRegex.search(d)
  112.             text = Match.group(6)
  113.             cryptText = techcore.crypt(text)
  114.             print("Il testo cryptato è: " + cryptText)
  115.             pyperclip.copy(cryptText)
  116.             print("Testo copiato negli appunti!")
  117.             continue
  118.  
  119.         if deCryptRegex.search(d) != None :
  120.             Match = cryptRegex.search(d)
  121.             text = Match.group(6)
  122.             deCryptText = techcore.deCrypt(text)
  123.             print("Il testo decryptato è: " + deCryptText)
  124.             pyperclip.copy(deCryptText)
  125.             print("Testo copiato negli appunti!")
  126.             continue
  127.        
  128.         if d == "esci" :
  129.             print("\nCiao! Spero di rivederti!\n")
  130.             time.sleep(1)
  131.             sys.exit()
  132.         if d in memory :
  133.             print(memory[d])
  134.         else :
  135.             print("Non ho capito, cosa devo rispondere?")
  136.             n = input(">>>")
  137.             nn = techcore.semplifyText(n)
  138.             if nn != "niente" :
  139.                 memory[d] = n
  140.  
  141. except NameError :
  142.     sys.exit()
  143.  
  144. finally :
  145.     techcore.saveInFile(memory , "memory.m")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement