Submission Bot¶
-
class
bottr.bot.
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)[source]¶ Bottr Bot instance that can take a method
func_submission
and calls that method asfunc_submission(submission, *func_submission_args)
Can listen to new submissions made on a given list of subreddits.
Parameters: - reddit –
praw.Reddit
instance. Check here on how to create it. - name – Bot name
- func_submission – Submission function. It needs to accept a
praw.models.Submission
object and may take more arguments. For each submission created insubreddits
, apraw.models.Submission
object and allfun_submission_args
are passed tofunc_submission
as arguments. - 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.
Example usage:
# 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()
-
start
()¶ Starts this bot in a separate thread. Therefore, this call is non-blocking.
It will listen to all new submissions created in the
subreddits
list.
-
stop
()¶ Stops this bot.
Returns as soon as all running threads have finished processing.
- reddit –