Run the sed substitute command on reddit comments
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LICENSE
README.md
blacklist.json
praw.ini
reddit-sedbot.py
requirements.pip

README.md

reddit-sedbot

Run the sed substitute command on reddit comments.

example screenshot

I am running it with the user /u/_sed_.

Examples

"i am a bad person" - /u/sad_redditor
| "sed s/bad/good/" - /u/wholesome_redditor
|| "i am a good person" - /u/_sed_

"sudo apt-get install gentoo" - /u/linux_redditor
| "sed s/-get//" - /u/snarky_redditor
|| "sudo apt install gentoo" - /u/_sed_

"my hovercraft is full of eels" - /u/casual_redditor
| "sed s/[aeiouy]/o/g s/$/!/" - /u/cheeky_redditor
|| "mo hovorcroft os foll of ools!" - /u/_sed_

See more sed examples at http://www.grymoire.com/Unix/Sed.html

What it does

  1. Matches reddit comments that start with sed and include the pattern s/pattern/replacement/flag
  2. Runs the command echo "parent comment" | sed "s/pattern/replacement/flag" using subprocess.Popen
  3. Replies with the output of the command

Full regex: /(?:\s+|^)s\/((?:[^/\\]|\\.)+)\/((?:[^/\\]|\\.)*)\/([0-9gI]*)/

Is it safe to let reddit run commands in your terminal?

If the subprocess.Popen argument shell was True, then no, absolutely not.

But since the bot doesn't have shell = True, the command

echo "hello`rm -rf ~/*\`world"

prints out

hello`rm -rf ~/*`world

and it's all good. I hope.

Don't try this command in your terminal!

I want to run it myself for some reason

Download praw, add your API keys to the praw.ini file and run reddit-sedbot.py