Skip to content

Instantly share code, notes, and snippets.

@Kaleidosium
Last active November 14, 2018 12:34
Show Gist options
  • Save Kaleidosium/e80cb21b168a38c33048a5353cd97e99 to your computer and use it in GitHub Desktop.
Save Kaleidosium/e80cb21b168a38c33048a5353cd97e99 to your computer and use it in GitHub Desktop.
Template for a Python 3 Reddit Bot
import praw #Make sure you have Praw already, if not get it from here https://pypi.org/project/praw/ .
#Also make sure to put the Text in the Quotes.
def bot_login():
print ("Logging in...")
r = praw.Reddit(username = "", #Insert Reddit Username here, must be an actual account.
password = "", #Insert Reddit Account's Password.
client_id = "", #Put the line below the personal use script text here.
client_secret ="", #Put the secret here.
user_agent = "") #Put whatever here.
print ("Logged in!")
return r
def run_bot(r):
print ("Obtaining 25 comments...")
for comment in r.subreddit('test').comments(limit=25):
if "" in comment.body: #The Bot will reply to this statement.
print ("String with \"\" found in comment ") + comment.id #The Bot will reply to this statement but format it like this \"Test\".
comment.reply("") #This text is what the bot will be replying to the comment.
print ("Replied to comment ") + comment.id
r = bot_login()
run_bot(r)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment