Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""Return a ListingGenerator for unread moderator messages.
Additional keyword arguments are passed in the initialization of
:class:`.ListingGenerator`.
See ``inbox`` for all messages.
To print the mail in the unread modmail queue try:
.. code:: python
for message in reddit.subreddit('mod').mod.unread():
print("From: {}, To: {}".format(message.author, message.dest))
"""
return ListingGenerator(
self.subreddit._reddit,
API_PATH["moderator_unread"].format(subreddit=self.subreddit),
**generator_kwargs
)
This method can be used like:
.. code:: python
reddit.domain('imgur.com').hot()
reddit.multireddit('samuraisam', 'programming').hot()
reddit.redditor('spez').hot()
reddit.redditor('spez').comments.hot()
reddit.redditor('spez').submissions.hot()
reddit.subreddit('all').hot()
"""
generator_kwargs.setdefault("params", {})
url = _prepare(self, generator_kwargs, "hot")
return ListingGenerator(self._reddit, url, **generator_kwargs)
:class:`.ListingGenerator`.
.. note:: This method will return a maximum of 100 moderated
subreddits, ordered by subscriber count. To retrieve more than
100 moderated subreddits, please see :meth:`.Redditor.moderated`.
Usage:
.. code-block:: python
for subreddit in reddit.user.moderator_subreddits():
print(subreddit.display_name)
"""
return ListingGenerator(
self._reddit, API_PATH["my_moderator"], **generator_kwargs
)
def search(self, query, **generator_kwargs):
r"""Return a :class:`.ListingGenerator` of Redditors for ``query``.
:param query: The query string to filter Redditors by.
:returns :class:`.Redditor`\ s.
Additional keyword arguments are passed in the initialization of
:class:`.ListingGenerator`.
"""
self._safely_add_arguments(generator_kwargs, "params", q=query)
return ListingGenerator(
self._reddit, API_PATH["users_search"], **generator_kwargs
)
:param generator_kwargs: keyword arguments passed to
:class:`.ListingGenerator` constructor.
:returns: A :class:`.ListingGenerator` object which yields
:class:`.Submission` object.
Usage:
.. code-block:: python
thread = reddit.live('ukaeu1ik4sw5')
for submission in thread.discussions(limit=None):
print(submission.title)
"""
url = API_PATH["live_discussions"].format(id=self.id)
return ListingGenerator(self._reddit, url, **generator_kwargs)
def default(self, **generator_kwargs):
"""Return a :class:`.ListingGenerator` for default subreddits.
Additional keyword arguments are passed in the initialization of
:class:`.ListingGenerator`.
"""
return ListingGenerator(
self._reddit, API_PATH["subreddits_default"], **generator_kwargs
)
def gilded(self, **generator_kwargs):
"""Return a :class:`.ListingGenerator` for gilded items.
Additional keyword arguments are passed in the initialization of
:class:`.ListingGenerator`.
"""
return ListingGenerator(
self._reddit, urljoin(self._path, "gilded"), **generator_kwargs
)
def popular(self, **generator_kwargs):
"""Return a :class:`.ListingGenerator` for popular subreddits.
Additional keyword arguments are passed in the initialization of
:class:`.ListingGenerator`.
"""
return ListingGenerator(
self._reddit, API_PATH["subreddits_popular"], **generator_kwargs
)
def popular(self, **generator_kwargs):
"""Return a :class:`.ListingGenerator` for popular Redditors.
:returns Redditor profiles, which are a type of :class:`.Subreddit`.
Additional keyword arguments are passed in the initialization of
:class:`.ListingGenerator`.
"""
return ListingGenerator(
self._reddit, API_PATH["users_popular"], **generator_kwargs
)
def random_rising(self, **generator_kwargs):
"""Return a :class:`.ListingGenerator` for random rising submissions.
Additional keyword arguments are passed in the initialization of
:class:`.ListingGenerator`.
"""
return ListingGenerator(
self._reddit,
urljoin(self._path, "randomrising"),
**generator_kwargs
)