SubmissionBot(reddit: praw.reddit.Reddit, name: str = 'SubmissionBot', func_submission: typing.Callable[[praw.models.reddit.comment.Comment], NoneType] = None, func_submission_args: typing.List = None, subreddits: typing.Iterable = None, n_jobs=4)¶
Bottr Bot instance that can take a method
func_submissionand calls that method as
Can listen to new submissions made on a given list of subreddits.
- reddit –
praw.Redditinstance. Check here on how to create it.
- name – Bot name
- func_submission – Submission function. It needs to accept a
praw.models.Submissionobject and may take more arguments. For each submission created in
praw.models.Submissionobject and all
fun_submission_argsare passed to
- func_submission_args – submission function arguments.
- subreddits – List of subreddit names. Example:
['AskReddit', 'Videos', ...]
- n_jobs – Number of parallel threads that are started when calling
start()to process in the incoming submissions.
# Write a parsing method def parse(submission): if 'banana' in submission.title: submission.reply('This submission is bananas.') reddit = praw.Reddit(...) # Create a PRAW Reddit instance bot = SubmissionBot(reddit=reddit, func_submission=parse) bot.start()
Starts this bot in a separate thread. Therefore, this call is non-blocking.
It will listen to all new submissions created in the
Stops this bot.
Returns as soon as all running threads have finished processing.
- reddit –