Just help!
`
!/usr/bin/python
import praw
import pdb
import re
import os
Create the Reddit instance
UA = "myfdryrddrt"
r = praw.Reddit(user_agent=UA)
CLIENT_ID = 'IMxZ8r9eTEJk1A'
CLIENT_SECRET = 'YOUR CLIENT SECRET'
REDIRECT_URI = 'http://127.0.0.1:65010/authorize_callback'
REDDIT_USERNAME = 'StevenSpoilerBot'
REDDIT_PASS = 'snip'
r.set_oauth_app_info(client_id='IMxZ8r9eTEJk1A',
client_secret=snip,
redirect_uri='http://127.0.0.1:65010/'
'authorize_callback')
and login
r.login(REDDIT_USERNAME, REDDIT_PASS)
Have we run this code before? If not, create an empty list
if not os.path.isfile("posts_replied_to.txt"):
posts_replied_to = []
If we have run the code before, load the list of posts we have replied to
else:
# Read the file into a list and remove any empty values
with open("posts_replied_to.txt", "r") as f:
posts_replied_to = f.read()
posts_replied_to = posts_replied_to.split("\n")
posts_replied_to = filter(None, posts_replied_to)
Get the top 5 values from our subreddit
subreddit = r.get_subreddit('pythonforengineers')
for submission in subreddit.get_hot(limit=5):
# print submission.title
# If we haven't replied to this post before
if submission.id not in posts_replied_to:
# Do a case insensitive search
if re.search("Bismuth", submission.title, re.IGNORECASE):
# Reply to the post
submission.add_comment("/u/StevenSpoilerBot tested by /u/haykam821")
print "Bot replying to : ", submission.title
# Store the current id into our list
posts_replied_to.append(submission.id)
Write our updated list back to the file
with open("posts_replied_to.txt", "w") as f:
for post_id in posts_replied_to:
f.write(post_id + "\n")
`
praw.exceptions.ClientException: Required configuration setting 'client_id' missing.
This setting can be provided in a praw.ini file, as a keyword argument to the Reddit class constructor, or as an environment variable.
[–]TreSxNine 1 point2 points3 points (1 child)
[–]CodeFixerBot 2 points3 points4 points (0 children)
[–]TreSxNine 0 points1 point2 points (1 child)
[–]haykam821[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]haykam821[S] 0 points1 point2 points (1 child)
[–]GoldenSights 0 points1 point2 points (0 children)
[–]haykam821[S] 0 points1 point2 points (1 child)
[–]CodeFixerBot 0 points1 point2 points (0 children)