3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-25 05:19:29 +01:00

applets/ty.py: URL-encode form data

This commit is contained in:
Pragmatic Software 2022-04-08 09:10:07 -07:00
parent 3d311296eb
commit acbebddacc

10
applets/ty.py vendored
View File

@ -6,11 +6,17 @@ import subprocess
url = 'https://based.lol/run.ty' url = 'https://based.lol/run.ty'
if len(sys.argv) <= 1: if len(sys.argv) <= 1:
print('Usage: ty` <code> [-stdin=<input>]') print('usage: ty` <code> [-stdin=<input>]')
sys.exit(0) sys.exit(0)
cmd = ' '.join(sys.argv[1:]).replace('\\n', '\n') cmd = ' '.join(sys.argv[1:]).replace('\\n', '\n')
[code, *input] = cmd.split('-stdin=') [code, *input] = cmd.split('-stdin=')
print(subprocess.run(['curl', url, '-F', f'code={code}', '-F', f'input={"".join(input)}'], text=True, capture_output=True).stdout.rstrip()) print(
subprocess.run([
'curl', url,
'--data-urlencode', f'code={code}',
'--data-urlencode', f'input={"".join(input)}'
], text=True, capture_output=True).stdout.rstrip()
)