Reddit bot, please, help me.

zelosn

Registered Member
Joined
Sep 15, 2017
Messages
91
Reaction score
16
Hello, I want a Reddit bot that I add in its many content, image, and URL then publishes it on my subreddit. Do you know anything like this?
 
If you know Python you can use Praw library like this :

Python:
import psycopg2
import praw
import time
import random


def random_post(records_data):
    rand_post = random.choice(records_data)
    return rand_post


def get_record():
    conn = psycopg2.connect("dbname='xxx' user='xxx' host='xxx' password='xxx'")
    cur = conn.cursor()

    cur.execute("SELECT * FROM xxx ORDER BY -id LIMIT 100")
    records = cur.fetchall()

    return records


def post(record):
    print(record)
    # praw variables
    reddit = praw.Reddit(client_id='your client id',
                         client_secret='your client secret',
                         user_agent='My_bot',
                         username='your username',
                         password='your pass!')

    subreddit = reddit.subreddit('your subreddit')
    
    # post name
    url = record[1]
    
    # for my website, I must modify url from database like this :
    url = url.replace(' ', '%20')
    url = 'https://xxx.com/video/' + url

    # subreddit.submit (post_name, url, resubmit=True/False, nsfw=True/False)
    my_post = subreddit.submit(record[1], url=url, resubmit=False, nsfw=True)


a = get_record()
b = random_post(a)
post(b)
 
Hello, I want a Reddit bot that I add in its many content, image, and URL then publishes it on my subreddit. Do you know anything like this?
I have my own reddit bot but not sure if that is what you want to be honnest.
 
Back
Top