reddit.inbox¶
-
class
asyncpraw.models.
Inbox
(reddit: asyncpraw.Reddit, _data: Optional[Dict[str, Any]])¶ Inbox is a Listing class that represents the Inbox.
-
__init__
(reddit: asyncpraw.Reddit, _data: Optional[Dict[str, Any]])¶ Initialize a PRAWModel instance.
- Parameters
reddit – An instance of
Reddit
.
-
all
(**generator_kwargs: Union[str, int, Dict[str, str]]) → AsyncIterator[Union[asyncpraw.models.Message, asyncpraw.models.Comment]]¶ Return a
ListingGenerator
for all inbox comments and messages.Additional keyword arguments are passed in the initialization of
ListingGenerator
.To output the type and ID of all items available via this listing do:
async for item in reddit.inbox.all(limit=None): print(repr(item))
-
await
collapse
(items: List[asyncpraw.models.Message])¶ Mark an inbox message as collapsed.
- Parameters
items – A list containing instances of
Message
.
Requests are batched at 25 items (reddit limit).
For example, to collapse all unread Messages, try:
from asyncpraw.models import Message unread_messages = [] async for item in reddit.inbox.unread(limit=None): if isinstance(item, Message): unread_messages.append(item) await reddit.inbox.collapse(unread_messages)
See also
-
comment_replies
(**generator_kwargs: Union[str, int, Dict[str, str]]) → AsyncIterator[asyncpraw.models.Comment]¶ Return a
ListingGenerator
for comment replies.Additional keyword arguments are passed in the initialization of
ListingGenerator
.To output the author of one request worth of comment replies try:
async for reply in reddit.inbox.comment_replies(): print(reply.author)
-
await
mark_read
(items: List[Union[asyncpraw.models.Comment, asyncpraw.models.Message]])¶ Mark Comments or Messages as read.
- Parameters
items – A list containing instances of
Comment
and/orMessage
to be be marked as read relative to the authorized user’s inbox.
Requests are batched at 25 items (reddit limit).
For example, to mark all unread Messages as read, try:
from asyncpraw.models import Message unread_messages = [] async for item in reddit.inbox.unread(limit=None): if isinstance(item, Message): unread_messages.append(item) await reddit.inbox.mark_read(unread_messages)
See also
-
await
mark_unread
(items: List[Union[asyncpraw.models.Comment, asyncpraw.models.Message]])¶ Unmark Comments or Messages as read.
- Parameters
items – A list containing instances of
Comment
and/orMessage
to be be marked as unread relative to the authorized user’s inbox.
Requests are batched at 25 items (reddit limit).
For example, to mark the first 10 items as unread try:
to_unread = [msg async for msg in reddit.inbox.all(limit=10)] await reddit.inbox.mark_unread(to_unread)
See also
-
mentions
(**generator_kwargs: Union[str, int, Dict[str, str]]) → AsyncIterator[asyncpraw.models.Comment]¶ Return a
ListingGenerator
for mentions.A mention is
Comment
in which the authorized redditor is named in its body likeu/redditor_name
.Additional keyword arguments are passed in the initialization of
ListingGenerator
.For example, to output the author and body of the first 25 mentions try:
async for mention in reddit.inbox.mentions(limit=25): print(f"{mention.author}\n{mention.body}\n")
-
await
message
(message_id: str) → asyncpraw.models.Message¶ Return a Message corresponding to
message_id
.- Parameters
message_id – The base36 id of a message.
For example:
message = await reddit.inbox.message("7bnlgu")
-
messages
(**generator_kwargs: Union[str, int, Dict[str, str]]) → AsyncIterator[asyncpraw.models.Message]¶ Return a
ListingGenerator
for inbox messages.Additional keyword arguments are passed in the initialization of
ListingGenerator
.For example, to output the subject of the most recent 5 messages try:
async for message in reddit.inbox.messages(limit=5): print(message.subject)
-
classmethod
parse
(data: Dict[str, Any], reddit: asyncpraw.Reddit) → Any¶ Return an instance of
cls
fromdata
.- Parameters
data – The structured data.
reddit – An instance of
Reddit
.
-
sent
(**generator_kwargs: Union[str, int, Dict[str, str]]) → AsyncIterator[asyncpraw.models.Message]¶ Return a
ListingGenerator
for sent messages.Additional keyword arguments are passed in the initialization of
ListingGenerator
.For example, to output the recipient of the most recent 15 messages try:
async for message in reddit.inbox.sent(limit=15): print(message.dest)
-
stream
(**stream_options: Union[str, int, Dict[str, str]]) → AsyncIterator[Union[asyncpraw.models.Message, asyncpraw.models.Comment]]¶ Yield new inbox items as they become available.
Items are yielded oldest first. Up to 100 historical items will initially be returned.
Keyword arguments are passed to
stream_generator()
.For example, to retrieve all new inbox items, try:
async for item in reddit.inbox.stream(): print(item)
-
submission_replies
(**generator_kwargs: Union[str, int, Dict[str, str]]) → AsyncIterator[asyncpraw.models.Comment]¶ Return a
ListingGenerator
for submission replies.Additional keyword arguments are passed in the initialization of
ListingGenerator
.To output the author of one request worth of submission replies try:
async for reply in reddit.inbox.submission_replies(): print(reply.author)
-
await
uncollapse
(items: List[asyncpraw.models.Message])¶ Mark an inbox message as uncollapsed.
- Parameters
items – A list containing instances of
Message
.
Requests are batched at 25 items (reddit limit).
For example, to uncollapse all unread Messages, try:
from asyncpraw.models import Message unread_messages = [] async for item in reddit.inbox.unread(limit=None): if isinstance(item, Message): unread_messages.append(item) await reddit.inbox.uncollapse(unread_messages)
See also
-
unread
(mark_read: bool = False, **generator_kwargs: Union[str, int, Dict[str, str]]) → AsyncIterator[Union[asyncpraw.models.Message, asyncpraw.models.Comment]]¶ Return a
ListingGenerator
for unread comments and messages.- Parameters
mark_read – Marks the inbox as read (default: False).
Note
This only marks the inbox as read not the messages. Use
Inbox.mark_read()
to mark the messages.Additional keyword arguments are passed in the initialization of
ListingGenerator
.For example, to output the author of unread comments try:
from asyncpraw.models import Comment async for item in reddit.inbox.unread(limit=None): if isinstance(item, Comment): print(item.author)
-