/NSFW-Redgifs-Reddit-Bot

This NSFW bot will scrape gifs from redgifs.com and post them to your subreddit.

Primary LanguageJavaScript

Redgifs => Reddit Post

Table of Contents

About

!!WARNING!! This bot is NSFW!

This bot will scrape gifs from https://www.redgifs.com/ and post them to your subreddit at an interval, until turned off.

Getting Started

These instructions will get you a copy of the project up and running on your local machine.

Prerequisites

The first step is to install the correct version of NodeJS for your system. You can find the official downloads here: https://nodejs.org/en/download/

Setting Up Your Script App

You'll have to create a new account for your bot before you move any further.
Once the account is created, log in, go to reddit.com/prefs/apps to fill out the form to create a new script app.

Creating Post Flairs

The bot will select a flair template id that you choose to make its posts stand out from other users. The steps to set this up are fairly straightforward: First go to your Mod Dashboard by navigating to https://www.reddit.com/r/YOUR_SUB_NAME/about/modqueue

  1. Click ADD FLAIR

  1. Fill out the form:
    • The default text will be overwritten by the bot, but is required for you to enter before submitting
    • CSS class can be left blank
    • You may decide to make this a Mod Only flair, but you will need to add the bot as a mod to your server for it to work
    • Edit the background color and text color the way you like
    • You may choose to edit the post appearance.
    • Upload images, change the color of the post. Play around until you find something you like.
    • When you are finished editing the appearance, click SAVE

  1. Now COPY ID and you are going to paste this into your pw.env file, which is explained in the next step.

Environment Variables

Now that you've set up your bot account, granted it permissions (if nececary) on your subreddit, created a script app and gotten your flair id, it's time to download the source code and paste in your environment variables.

Download the .zip file containing the source code on this page. Unzip it and save it to your computer somewhere. Now open up the pw.envEXAMPLE file.
Also have open reddit.com/prefs/apps as you'll need to copy/paste the items you'll find there.
USER_AGENT is just a name that the server will identify your bot by. It can be whatever you want.
CLIENT_ID and CLIENT_SECRET are fround in prefs/apps.
REDDIT_USER is your bots username.
REDDIT_PASS is its password.
MASTER_SUB is the subreddit it will work on.
DEBUG_NETWORK should be set to false unless any problems arise.
INTERVAL how often (in minutes) the bot will submit a new post.
FLAIR_TEMPLATE_ID is obtained when you created your flair template in the Mod Dashboard. FLAIR_TEXT the text that will be set in the post flair.

USER_AGENT='FROM PREFS/APPS'
CLIENT_ID='FROM PREFS/APPS'
CLIENT_SECRET='FROM PREFS/APPS'
REDDIT_USER='BOTS USERNAME'
REDDIT_PASS='BOTS PASSWORD'
MASTER_SUB='YOUR SUBREDDIT'
DEBUG_NETWORK='false'
INTERVAL='10'
FLAIR_TEMPLATE_ID='SHOULD LOOK LIKE THIS: ecfe4d36-1831-11eb-9371-0ed75c0ba1df'
FLAIR_TEXT='REDGIFS'

Once these fields are completely filled out, remove EXAMPLE from the end of the filename.

pw.envEXAMPLE = pw.env

Usage

Installing

Once you've got your pw.env file correctly filled out and renamed, you may run the installer.

Double-click INSTALL.bat to run the isntaller script. Linux and Mac users may use the command npm install to install.

Once the installer is finished running, you may use RUN.bat to run. Linux and Mac users may use the command node src/bot.js to run.

Running

To run the bot, double-click RUN.bat

The bot will:

  1. Scrape redgifs.com/featured/categories for a list of categories to choose from.
  2. It will pick a category at random and then navigate to the category's new section.
  3. It will select a random gif from the page and then return with a title and url.
  4. Reddit will take that title and url and post them to your subreddit. If you have defined a custom post flair, they will be assigned the flair you set in pw.env.
  5. The bot will sleep for a number of minutes as defined in the pw.env file, then continuously run until shut off.