Message Bot

class praw.reddit.Reddit, name: str = 'InboxBot', func_message: typing.Callable[[praw.models.reddit.message.Message], NoneType] = None, func_message_args: typing.List = None, n_jobs=1)[source]

This bot listens to incoming inbox messages and calls the provided method func_message as func_message(message, *func_message_args) for each message that is new in the inbox.

  • redditpraw.Reddit instance. Check Bot Account Setup on how to create it.
  • name – Bot name
  • func_message – Message function. It needs to accept a praw.models.Message object and may take more arguments. For each new message in the inbox, a praw.models.Message object and all fun_message_args are passed to func_message as arguments.
  • func_message_args – Message function arguments.
  • n_jobs – Number of parallel threads that are started when calling start() to process in the incoming messages.

Example usage:

# Write a parsing method
def parse(message):
   message.reply('Hello you!')

reddit = praw.Reddit(...) # Create a PRAW Reddit instance
bot = MessageBot(reddit=reddit, func_message=parse)

Starts this bot in a separate thread. Therefore, this call is non-blocking.

It will listen to all new inbox messages created.


Stops this bot.

Returns as soon as all running threads have finished processing.