Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import time
- import re
- import datetime
- reddit = praw.Reddit(client_id='',
- client_secret='',
- username='',
- password='',
- user_agent='')
- print("Reddit account: connected")
- # searching text file for post
- def check_reply(post_id):
- with open("already_replied.txt", "r") as f:
- contents = f.readlines()
- if contents == []:
- return False
- for line in contents:
- line = str(line.replace("\n", ""))
- post_id = str(post_id.replace(" ", ""))
- if line == post_id:
- return True
- else:
- return False
- # adding submission id to file
- def add_reply(post_id):
- with open("already_replied.txt", "w") as f:
- f.write(post_id + "\n")
- # setting global variables
- subreddit = reddit.subreddit("Memeeconomy")
- submissions = subreddit.stream.submissions()
- # setting blacklisted words.
- blacklisted_words = ['Test', 'test']
- for submission in submissions:
- # check time
- time_created = submission.created_utc
- time_now = time.time()
- # check if the meme came from SOL
- if re.search("SOL Enterprises", str(submission.author_flair_text), re.IGNORECASE):
- if time_now-time_created < 600:
- for word in blacklisted_words:
- # attempting to not comment on traps
- if word in submission.title:
- print("Trap meme found.")
- continue
- if check_reply(submission.id) is False:
- for reply in submission.comments.list():
- if reply.author == "MemeInvestor_bot":
- print("Replying to post {0}".format(submission.title))
- add_reply(submission.id)
- time.sleep(1)
- reply.reply("!invest 100%")
- print("Replied")
- time.sleep(1)
- submission.upvote()
- print("Going to sleep for 4 hours")
- time.sleep(14100)
- else:
- continue
- else:
- print("Already posted on {}".format(submission.title))
- else:
- print("SOL meme found but posted too long ago: {0}".format(submission.title))
- else:
- continue
- print("Sleeping")
- time.sleep(20)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement