Skip to content
This repository
Browse code

Require team membership to access team subreddits.

  • Loading branch information...
commit cdaa65e0447b6fdde830555b1c68853525e5eb83 1 parent fe609b4
Neil Williams authored
1  README.md
Source Rendered
@@ -7,6 +7,7 @@ Add the following to your `.update` file:
7 7
 [DEFAULT]
8 8
 f2pcaches = localhost:11211
9 9
 plugins = f2p
  10
+team_subreddits = orangered:red, periwinkle:blue
10 11
 
11 12
 [live_config]
12 13
 # In seconds (decimals allowed)
5  reddit_f2p/__init__.py
@@ -15,6 +15,10 @@ class FreeToPlay(Plugin):
15 15
         ConfigValue.tuple: [
16 16
             "f2pcaches",
17 17
         ],
  18
+
  19
+        ConfigValue.dict(str, str): [
  20
+            "team_subreddits",
  21
+        ],
18 22
     }
19 23
 
20 24
     js = {
@@ -69,6 +73,7 @@ def load_controllers(self):
69 73
 
70 74
         from reddit_f2p import f2p
71 75
         f2p.hooks.register_all()
  76
+        f2p.monkeypatch()
72 77
 
73 78
         from reddit_f2p.steam import SteamController
74 79
         from reddit_f2p.gamelog import GameLogController
10  reddit_f2p/f2p.py
@@ -186,3 +186,13 @@ def POST_use_item(self, item_name, target):
186 186
         item.on_use(c.user, target)
187 187
 
188 188
         return json.dumps(c.state_changes)
  189
+
  190
+
  191
+def monkeypatch():
  192
+    orig_is_contributor = Subreddit.is_contributor
  193
+    def is_contributor_with_teams(sr, user):
  194
+        sr_team = g.team_subreddits.get(sr.name.lower())
  195
+        if sr_team:
  196
+            return sr_team == scores.get_user_team(c.user)
  197
+        return orig_is_contributor(sr, user)
  198
+    Subreddit.is_contributor = is_contributor_with_teams

0 notes on commit cdaa65e

Please sign in to comment.
Something went wrong with that request. Please try again.