-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathoutstanding_gardeners.py
53 lines (37 loc) · 1.02 KB
/
outstanding_gardeners.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import os
import praw
import sys
import config as c
from collections import Counter
REDDIT_USERNAME = 'takecareofmyplant'
REDDIT_PASSWORD = 'hunter2'
path = c.pathPrefix()
r = c.getReddit()
with open(path+'history.txt', 'r+') as f:
x = f.readlines()
last_seven = x[-7:]
last_seven = [x.split(',')[2].strip() for x in last_seven]
print(last_seven)
def getResponders(thread):
s = r.get_submission(submission_id = thread)
s.replace_more_comments(limit = None, threshold = 0)
comments = s.comments
name_list = []
for x in comments:
try:
name_list.append( x.author.name)
except:
continue
return set(name_list)
name_list = []
for x in last_seven:
s = r.get_submission(submission_id = x)
name_list += getResponders(x)
foo = Counter(name_list)
outstanding = []
for x in set(name_list):
if foo[x] >= 6:
outstanding.append(x)
print outstanding
for x in outstanding:
r.get_subreddit('takecareofmyplant').set_flair(x, 'Outstanding Gardener', '')