WikiPageModeration
- class praw.models.reddit.wikipage.WikiPageModeration(wikipage: praw.models.reddit.wikipage.WikiPage)
Provides a set of moderation functions for a WikiPage.
For example, to add
spez
as an editor on the wikipagepraw_test
try:reddit.subreddit("test").wiki["praw_test"].mod.add("spez")
- __init__(wikipage: praw.models.reddit.wikipage.WikiPage)
Create a WikiPageModeration instance.
- Parameters
wikipage – The wikipage to moderate.
- add(redditor: praw.models.Redditor)
Add an editor to this WikiPage.
- Parameters
redditor – A redditor name (e.g.,
"spez"
) orRedditor
instance.
To add
"spez"
as an editor on the wikipage"praw_test"
try:reddit.subreddit("test").wiki["praw_test"].mod.add("spez")
- remove(redditor: praw.models.Redditor)
Remove an editor from this WikiPage.
- Parameters
redditor – A redditor name (e.g.,
"spez"
) orRedditor
instance.
To remove
"spez"
as an editor on the wikipage"praw_test"
try:reddit.subreddit("test").wiki["praw_test"].mod.remove("spez")
- revert()
Revert a wikipage back to a specific revision.
To revert the page
"praw_test"
inr/test
to revision[ID]
, tryreddit.subreddit("test").wiki["praw_test"].revision("[ID]").mod.revert()
Note
When you attempt to revert the page
config/stylesheet
, Reddit checks to see if the revision being reverted to passes the CSS filter. If the check fails, then the revision attempt will also fail, and aprawcore.Forbidden
exception will be raised. For example, you can’t revert to a revision that contains a link tourl(%%PRAW%%)
if there is no image namedPRAW
on the current stylesheet.Here is an example of how to look for this type of error:
from prawcore.exceptions import Forbidden try: reddit.subreddit("test").wiki["config/stylesheet"].revision("[ID]").mod.revert() except Forbidden as exception: try: exception.response.json() except ValueError: exception.response.text
If the error occurs, the output will look something like
{"reason": "INVALID_CSS", "message": "Forbidden", "explanation": "%(css_error)s"}
- update(listed: bool, permlevel: int, **other_settings: Any) Dict[str, Any]
Update the settings for this WikiPage.
- Parameters
listed – (boolean) Show this page on page list.
permlevel – (int) Who can edit this page? (0) use subreddit wiki permissions, (1) only approved wiki contributors for this page may edit (see
WikiPageModeration.add()
), (2) only mods may edit and viewother_settings – Additional keyword arguments to pass.
- Returns
The updated WikiPage settings.
To set the wikipage
praw_test
inr/test
to mod only and disable it from showing in the page list, try:reddit.subreddit("test").wiki["praw_test"].mod.update(listed=False, permlevel=2)