From 507b5f48b080c74d1cd6badb85620e12a2b55895 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 31 Mar 2024 18:58:22 -0700 Subject: [PATCH] Add makespam.py. --- makespam.py | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 makespam.py diff --git a/makespam.py b/makespam.py new file mode 100644 index 0000000..6703570 --- /dev/null +++ b/makespam.py @@ -0,0 +1,70 @@ +import time +import textwrap +import re +import html +import pyperclip + +TEMPLATE = ''' +
+{selectheaders} +
+ Headers +
+{headers}
+        
+
+ +
+ +{body} +
+''' + + +print('Copy the body...') +pyperclip.copy('') +while pyperclip.paste() == '': + time.sleep(0.5) +body = html.escape(pyperclip.paste()) +body = body.replace('\r', '') +body = [line.strip() for line in body.splitlines()] +body = [line for line in body if line] +body = ['

' + line + '

' for line in body] +body = '\n'.join(body) +body = textwrap.indent(body, ' ') + +print('Copy the headers...') +pyperclip.copy('') +while pyperclip.paste() == '': + time.sleep(0.5) +headers = html.escape(pyperclip.paste()) +headers = headers.replace('\r', '') +headers = [line.rstrip() for line in headers.splitlines()] +headers = [line for line in headers if line] +headers = '\n'.join(headers) + +keyed = {} +for line in headers.splitlines(): + key = re.search(r'^([A-Za-z\-]+): ', line, flags=re.MULTILINE) + if key is None: + continue + key = key.group(1) + line = line.replace(key + ':', '

' + key + ':') + keyed[key] = line + +selectheaders = [ + keyed.get('From'), + keyed.get('Reply-To'), + keyed.get('Return-Path'), + keyed.get('To'), + keyed.get('Bcc'), + keyed.get('Subject'), + keyed.get('Date'), +] +selectheaders = [s for s in selectheaders if s] +selectheaders = '\n'.join(selectheaders) +selectheaders = textwrap.indent(selectheaders, ' ') + +spam = TEMPLATE.format(body=body, headers=headers, selectheaders=selectheaders) +print(spam) +pyperclip.copy(spam) \ No newline at end of file