Skip to content

Instantly share code, notes, and snippets.

@MegaLoler
Created November 26, 2019 21:03
Show Gist options
  • Save MegaLoler/9486bc579e4344cd116ef0b6d1ef4232 to your computer and use it in GitHub Desktop.
Save MegaLoler/9486bc579e4344cd116ef0b6d1ef4232 to your computer and use it in GitHub Desktop.
script to help a bit with sending my big discord messages lol
#!/usr/bin/env python3
# read in a text file, split it into paragraphs that fit under 2000 characters, add a invisible separator to the end of each except the last, and copy each sequentially and interactively to the clipboard
import pyperclip
import sys
if __name__ == '__main__':
if len(sys.argv) < 2:
print('plese specify tha name o th file as argument to this progrm 2 copythanxx')
else:
with open(sys.argv[1]) as f:
string = f.read().strip() # read the whole file in
ps_raw = string.split('\n\n') # get all the paragraphs unmodified
ps = [p + '\n\N{INVISIBLE SEPARATOR}' for p in ps_raw[:-1]] + [ps_raw[-1]] # add invisible separator to the end of each but the last
# now loop n copy each in sequence
for i, p in enumerate(ps):
print(f'copying paragraph #{i+1} of {len(ps)}')
pyperclip.copy(p)
input('press enter...')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment