Skip to content

Instantly share code, notes, and snippets.

@LouisJenkinsCS
Last active December 21, 2020 12:37
Show Gist options
  • Save LouisJenkinsCS/3fd06f2e73a861da4d32e7cc6c89f9a9 to your computer and use it in GitHub Desktop.
Save LouisJenkinsCS/3fd06f2e73a861da4d32e7cc6c89f9a9 to your computer and use it in GitHub Desktop.
[Linux] Discord - Delete All DMs, Screenshot (Archive) DMs, Kill Switch, PNG to PDF Conversion

Uses autokey-gtk (sudo apt-get install autokey-gtk) on Linux, which is used to create macros that simulate actions on a keyboard or mouse. Add the above as hotkeys (ensuring that the killswitch is bound as well), open the DM you want, and fire away. Deletion of DMs works bottom up, so beginning at the message to be deleted on upward, and Screenshot DM works top down, so beginning at the page to be 'archived' (saved as a screenshot) on down. When archiving, use python script to convert PNG files to PDF. The converter sorts the files to be appended according to modification time, and hence should work just fine the screenshot DM macro, as it will combined them in the order each page of DMs gets archived. Converter uses converter which relies on imagemagick (sudo apt-get install imagemagick)

#!/bin/python3
import subprocess
import os
batchSize = 256
batches = {}
currBatch = 0;
files = os.listdir(".")
files.sort(key=os.path.getmtime)
for fname in files:
if fname.endswith(".jpg") or fname.endswith(".png"):
if currBatch not in batches:
batches[currBatch] = []
batches[currBatch].append(fname)
if len(batches[currBatch]) >= batchSize:
currBatch += 1
processedAlready = False
for batch in batches.values():
subprocess.run(['convert'] + (['out.pdf'] if not processedAlready else []) + batch + ['out.pdf'])
# Enter script code
import time;
store.set_global_value("STOP", True)
while store.GLOBALS.get("STOP", True):
keyboard.send_key("<space>")
time.sleep(0.25)
keyboard.send_key("<backspace>")
time.sleep(0.25)
keyboard.send_key("<up>")
time.sleep(0.25)
keyboard.press_key("<ctrl>")
keyboard.fake_keypress("a")
keyboard.release_key("<ctrl>")
keyboard.send_key("<backspace>")
keyboard.send_key("<enter>")
time.sleep(0.25)
keyboard.send_key("<enter>")
time.sleep(0.25)
# Enter script code
store.set_global_value("STOP", False)
# Enter script code
import time;
store.set_global_value("STOP", True)
while store.GLOBALS.get("STOP", True):
time.sleep(0.5)
keyboard.press_key("<alt>")
keyboard.fake_keypress("<print_screen>")
keyboard.release_key("<alt>")
time.sleep(1)
keyboard.send_key("<alt>")
time.sleep(0.2)
keyboard.send_key("<alt>")
keyboard.send_key("<page_down>")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment