From 7f85ffb996b66fef9fea689f2b4f5eb5a68b25e5 Mon Sep 17 00:00:00 2001 From: C20H25N3O Date: Sun, 23 Aug 2020 16:24:48 +0000 Subject: [PATCH] Added Script --- main.pyw | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 main.pyw diff --git a/main.pyw b/main.pyw new file mode 100644 index 0000000..fbb0ff8 --- /dev/null +++ b/main.pyw @@ -0,0 +1,53 @@ +from gtts import gTTS +from PIL import Image +from playsound import playsound +import os +import ctypes +import time +import shutil +import random + + +bg_path = os.path.normpath("C:/perawareBg") +bmp_path = os.path.normpath("C:/perawareBg/small_joe.bmp") +#defines the paths normalized for background() + +def hacked(text): #defines the function that saves, and plays input as text-to-speech + tts = gTTS(text=text, lang="en") + filename = "hacked.mp3" + tts.save(filename) + playsound(filename) + + +def makebg(): #resizes the image smaller in order to have low resolution and saves it for background() + img = Image.open("assets/joe.jpg") + bmp = img.resize((round(img.size[0]*.25), round(img.size[1]*.25))) + bmp.save(bmp_path) + + +def background(): + os.mkdir(bg_path) #makes a directory "C:/perawareBg" + makebg() + ctypes.windll.user32.SystemParametersInfoW(20, 0, bmp_path, 0) #saves "C:/perawareBg" to desktop wallpaper + time.sleep(1) #we needed a small pause so we would not remove the image before it was set to desktop + + +def clean(): #defines the function that removes the created folder and file + shutil.rmtree(bg_path) #we used shutil.rmtree as we could delete the file and folder in one line + os.remove("hacked.mp3") + + +def audio(): #defines the function that plays Joe Pera saying "nice" every 6 to 15 seconds then calls itself + time.sleep(random.randint(6, 15)) + playsound("assets/sound.wav") + audio() + + +def main(): #main function + hacked("You have been hacked by the legendary comedian Joe Pera") #passes a line as input to hacked() + background() + clean() + audio() + + +main()