Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def script_app():
return Reddit(
client_id="dummy client",
client_secret="dummy secret",
redirect_uri="https://dummy.tld/",
user_agent="dummy",
)
def getRedditUserLikedSavedSubmissions(user_name, user_password, client_id, client_secret,
request_limit = 10, saveLiked = True, saveSaved = True,
earlyOutPointSaved = None, earlyOutPointLiked = None,
unlikeLiked = False, unsaveSaved = False):
r = praw.Reddit(client_id = client_id,
client_secret=client_secret,
username=user_name,
password=user_password,
user_agent=user_agent)
logger.log('\n\nCommunicating with reddit. This should only take a minute...\n')
savedLinks = None
if saveSaved:
logger.log('\tGetting saved links...')
savedLinks = r.user.me().saved(limit=request_limit)
savedLinks = list(savedLinks)
likedLinks = None
if saveLiked:
logger.log('\tGetting liked links...')
def update_post(message):
"""Updates the Reddit post with the specified Markdown message.
Parameters
----------
message : str
The Markdown formatted message.
"""
# We initialize Reddit.
reddit = praw.Reddit(client_id=config.APP_ID, client_secret=config.APP_SECRET,
user_agent=config.USER_AGENT, username=config.REDDIT_USERNAME,
password=config.REDDIT_PASSWORD)
# We update the Reddit theads.
for post_id in config.POST_IDS:
reddit.submission(post_id).edit(message)
def __init__(self):
self._praw_client = praw.Reddit(client_id=Config.CLIENT_ID,
client_secret=Config.CLIENT_SECRET,
user_agent=Config.USER_AGENT,
username=Config.USERNAME,
password=Config.PASSWORD)
'misc-2002-japan': 'World Cup - Japan 2002',
'misc-2006-germany': 'World Cup - Germany 2006',
'misc-2010-south-africa': 'World Cup - S.Africa 2010',
'misc-2014-rio': 'World Cup - Rio 2014',
'misc-2014-rio2': 'Rio 2014 Logo',
'misc-bundes': 'Bundesliga',
'misc-chmpl': 'Champions League',
'misc-faprem': 'FA Premier League',
'misc-seriea': 'Serie A',
'misc-wil': 'FC Wil',
'misc-pahang': 'Pahang FA',
'misc-fcman': 'FC United of Manchester',
'misc-afctel': 'AFC Telford'
}
print "Fired: " + strftime("%Y-%m-%d %H:%M:%S", gmtime())
r = praw.Reddit(user_agent='Some bot name for some subreddit')
r.login('some_user_name', 'some_password')
for msg in r.get_unread(limit=None):
subj = str(msg.subject)
print "Subject: " + subj
if subj == 'crest':
print msg
auth = str(msg.author)
body = str(msg.body)
print "Author: " + auth
print "Message content: " + body
sub = r.get_subreddit('football')
if body in teams:
ftext = str(teams[body])
sub.set_flair(auth, ftext, body)
with open('log.txt', 'a') as logfile:
tn = strftime("%Y-%m-%d %H:%M:%S", gmtime())
#!/usr/bin/env python3.3 -O
# The most common words bot. By /u/drkabob
# Finds the top most common words in a reddit comment thread
# Copyright 2013 Nathan Hakkakzadeh. All rights reserved.
import praw, sys, collections
from bottle import get, request, run
# Before we do anything, we need to grab a list of the most common words to ignore
with open("commonwords.txt", "r") as words:
commonwords = [word.lower().rstrip() for word in words]
r = praw.Reddit(user_agent="PRAW Most Common Word Bot. By /u/drkabob")
# Login would go here if it is necessary.
# Function that actually does the dirty work
# Returns an ordered dictionary with the words in order of how popular
# link: Comment thread we want to parse
# top: How many of the top words do we want to get (Default: 5)
# WARNING: This function is SLOOOOOOW and will block the entire script.
# You should REALLY run this in a thread.
def get_top_words(link, top=5):
# Get the submission...
submission = r.get_submission(link)
# We need to go deeper...
submission.replace_more_comments()
comments = praw.helpers.flatten_tree(submission.comments)
def uploadGifToReddit(imgurLink, username, password):
global gifName
r = praw.Reddit(user_agent="How its made!!")
r.login(redditUsername, redditPassword)
subreddit = r.get_subreddit("LewisTestsBots")
print("Uploading link to reddit")
subreddit.submit(title="How it's made " + str(gifName), url=imgurLink)
os.rename('./log/log.txt','./log/log.old'+str(random.randint(0,6553500)))
n_upvotes = 0
n_downvotes = 0
print "Saving old log file, creating new file.."
log(time.strftime("%Y-%m-%d %H:%M:%S")+' New daily log begins.. \n')
#sends the log.txt to my email address and moves the log to a new file..
return
def log(string_data):
with open("./log/log.txt", "a") as myfile:
myfile.write(string_data)
return
r = praw.Reddit(user_agent='Some unique text not containing bot')
r_login()
subreddit = r.get_subreddit('any subreddit you want') #lazy so no need to error check..
print '>>>Reddit /r/bitcoin bot..<<<'
print 'Downvoting:', downvoters
print 'Upvoting:', upvoters
print '>>>active - logging to ./log/log.txt<<<'
schedule.every().day.at("07:00").do(log_work)
schedule.every().day.at("19:00").do(log_work)
while True:
def connect_to_reddit():
global reddit
# Connecting to Reddit
user_agent = 'SALES__B0T - A Sales Notifier R0B0T'
reddit = praw.Reddit(user_agent=user_agent)
# TODO Use OAuth instead of this login method
reddit.login(accountinfo.username, accountinfo.password, disable_warning=True)
import praw
import datetime
from datetime import timezone
import database
import settings
reddit = praw.Reddit(client_id=settings.reddit_client_id,
client_secret=settings.reddit_client_secret, password=settings.reddit_client_password,
user_agent=settings.reddit_client_user_agent, username=settings.reddit_client_username)
class Submission():
def __init__(self, subredditid, submission_id, subreddit, permalink, link, title, author, upvotes, downvotes, amountcomments, comments, timecreated, timegathered, visited, alreadyIn):
self.subredditid = subredditid
self.subreddit = subreddit
self.permalink = permalink
self.submission_id = submission_id
self.link = link
self.title = title
self.author = author
self.upvotes = upvotes
self.downvotes = downvotes