Search code examples
pythonpraw

How to read private messages with PRAW?


I'm creating a Reddit bot with praw, and I want to have the bot do things based on private messages sent to it. I searched the documentation for a bit, but couldn't find anything on reading private messages, only sending them. I want to get both the title and the content of the message. So how can I do this?


Solution

  • Didn't find it in the docs, but a friend who knows a bit of raw helped me out.

    Use for message in r.inbox.messages() (where r is an instance of reddit) to get the messages.

    Use message.text to get the content, and message.subject to get the title.