diff --git a/CHANGES.rst b/CHANGES.rst index 6739a004c1..e8af02de89 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -24,6 +24,10 @@ Unreleased * Parameters ``mod_note`` and ``reason_id`` to :meth:`.ThingModerationMixin.remove` to optionally apply a removal reason on removal +* Parameters ``allowable_content`` and ``max_emojis`` to + :meth:`~.SubredditRedditorFlairTemplates.add`, + :meth:`~.SubredditLinkFlairTemplates.add`, and + :meth:`~.SubredditFlairTemplates.update`, as well as its child classes. **Deprecated** diff --git a/praw/models/reddit/subreddit.py b/praw/models/reddit/subreddit.py index 47c819f7e7..c9fd050697 100644 --- a/praw/models/reddit/subreddit.py +++ b/praw/models/reddit/subreddit.py @@ -1264,16 +1264,20 @@ def _add( background_color=None, text_color=None, mod_only=None, + allowable_content=None, + max_emojis=None, ): url = API_PATH["flairtemplate_v2"].format(subreddit=self.subreddit) data = { - "css_class": css_class, + "allowable_content": allowable_content, "background_color": background_color, - "text_color": text_color, + "css_class": css_class, "flair_type": self.flair_type(is_link), + "max_emojis": max_emojis, + "mod_only": bool(mod_only), "text": text, + "text_color": text_color, "text_editable": bool(text_editable), - "mod_only": bool(mod_only), } self.subreddit._reddit.post(url, data=data) @@ -1308,6 +1312,8 @@ def update( background_color=None, text_color=None, mod_only=None, + allowable_content=None, + max_emojis=None, ): """Update the flair template provided by ``template_id``. @@ -1323,6 +1329,12 @@ def update( ``'light'`` or ``'dark'``. :param mod_only: (boolean) Indicate if the flair can only be used by moderators. + :param allowable_content: If specified, most be one of ``'all'``, + ``'emoji'``, or ``'text'`` to restrict content to that type. + If set to ``'emoji'`` then the ``'text'`` param must be a + valid emoji string, for example ``':snoo:'``. + :param max_emojis: (int) Maximum emojis in the flair + (Reddit defaults this value to 10). For example to make a user flair template text_editable, try: @@ -1342,13 +1354,15 @@ def update( """ url = API_PATH["flairtemplate_v2"].format(subreddit=self.subreddit) data = { + "allowable_content": allowable_content, + "background_color": background_color, + "css_class": css_class, "flair_template_id": template_id, + "max_emojis": max_emojis, + "mod_only": mod_only, "text": text, - "css_class": css_class, - "background_color": background_color, "text_color": text_color, "text_editable": text_editable, - "mod_only": mod_only, } self.subreddit._reddit.post(url, data=data) @@ -1381,6 +1395,8 @@ def add( background_color=None, text_color=None, mod_only=None, + allowable_content=None, + max_emojis=None, ): """Add a Redditor flair template to the associated subreddit. @@ -1394,6 +1410,12 @@ def add( ``'light'`` or ``'dark'``. :param mod_only: (boolean) Indicate if the flair can only be used by moderators. + :param allowable_content: If specified, most be one of ``'all'``, + ``'emoji'``, or ``'text'`` to restrict content to that type. + If set to ``'emoji'`` then the ``'text'`` param must be a + valid emoji string, for example ``':snoo:'``. + :param max_emojis: (int) Maximum emojis in the flair + (Reddit defaults this value to 10). For example, to add an editable Redditor flair try: @@ -1411,6 +1433,8 @@ def add( background_color=background_color, text_color=text_color, mod_only=mod_only, + allowable_content=allowable_content, + max_emojis=max_emojis, ) def clear(self): @@ -1453,6 +1477,8 @@ def add( background_color=None, text_color=None, mod_only=None, + allowable_content=None, + max_emojis=None, ): """Add a link flair template to the associated subreddit. @@ -1466,6 +1492,12 @@ def add( ``'light'`` or ``'dark'``. :param mod_only: (boolean) Indicate if the flair can only be used by moderators. + :param allowable_content: If specified, most be one of ``'all'``, + ``'emoji'``, or ``'text'`` to restrict content to that type. + If set to ``'emoji'`` then the ``'text'`` param must be a + valid emoji string, for example ``':snoo:'``. + :param max_emojis: (int) Maximum emojis in the flair + (Reddit defaults this value to 10). For example, to add an editable link flair try: @@ -1483,6 +1515,8 @@ def add( background_color=background_color, text_color=text_color, mod_only=mod_only, + allowable_content=allowable_content, + max_emojis=max_emojis, ) def clear(self):