Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sutterismine1/587ca691c7615fdc950fce04fd1ef929 to your computer and use it in GitHub Desktop.
Save sutterismine1/587ca691c7615fdc950fce04fd1ef929 to your computer and use it in GitHub Desktop.
import praw, os, time
reddit = praw.Reddit(client_id='*',
client_secret='*',
user_agent='WallStResearch-Bot by u/sutterismine',
username='WallStResearch-Bot',
password='*') #
if not os.path.isfile("posts_replied_to.txt"):
posts_replied_to = []
else:
with open("posts_replied_to.txt", "r") as f:
posts_replied_to = f.read()
posts_replied_to = posts_replied_to.split("\n")
print(posts_replied_to)
posts_replied_to = list(filter(None, posts_replied_to))
sourcesub = reddit.subreddit('wallstreetbets+forex+algotrading+financialcareers+biotechplays+dividends+middleclassfinance+trading+daytrading+stocks+pennystocks+investmentclub+stock_picks+canadianinvestor+robinhoodpennystocks+smallstreetbets+economics+teslainvestorsclub+webull+cryptocurrency+securityanalysis+investing+wallstreetbets+options+finance+robinhood+wallstreetelites+stockmarket+personalfinance')
destinationsub = reddit.subreddit('wallstreetresearch')
while True:
for post in sourcesub.stream.submissions():
if post.id not in posts_replied_to:
if "DD" in str(post.link_flair_text) or "Due Diligence" in str(post.link_flair_text):
print('post found')
try:
postid = post.id
ogtitle = post.title
ogtext = post.selftext
localt = time.localtime()
year = localt[0]
mday = localt[2]
month = localt[1]
date = f"{month}/{mday}/{year}"
data = {'sr': destinationsub, 'title': ogtitle + " [" + date + "]", 'kind': 'crosspost', 'crosspost_fullname': 't3_' + postid}
crosspost = reddit.post('/api/submit', data=data)
post.reply(f'''I have crossposted this post to r/WallStreetResearch, have a good day!
{crosspost.permalink}
I am a bot and this action was performed automatically. Please contact u_sutterismine to have this subreddit blacklisted.''')
crosspost.reply(f"Saved text in case it gets removed: " + ogtext)
posts_replied_to.append(postid)
with open("posts_replied_to.txt", "w") as f:
for post_id in posts_replied_to:
f.write(post_id + "\n")
print('waiting for ratelimit')
time.sleep(480)
except Exception as E:
print(E)
break
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment