-
Notifications
You must be signed in to change notification settings - Fork 40
/
daily_water_thread.py
49 lines (36 loc) · 942 Bytes
/
daily_water_thread.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
# Make a thread in the subreddit to get input on water/don't water
import os
import praw
import sys
import config as c
import post_templates as posts
#import gpio_out as g
REDDIT_USERNAME = 'takecareofmyplant'
REDDIT_PASSWORD = 'hunter2'
# Set-up
r = c.getReddit()
sr = c.getSubReddit(r)
post_body = posts.body
post_title = posts.title
if c.checkKillSwitch() == 1:
sys.exit()
# Post Thread
s = sr.submit(post_title, text=post_body)
s.sticky()
# Logging
path_prefix = c.pathPrefix()
with open(path_prefix+'daily_thread.txt', 'w') as f:
f.write(s.id)
f.close()
with open(path_prefix+'topup.txt', 'r+') as f:
x = f.read()
if x == '1':
g.on_off(10)
True
# Reset continuous comment files
with open(path_prefix+'/continuous_tally/cont_comment_log.txt', 'w') as f:
f.write('')
f.close()
with open(path_prefix+'/continuous_tally/cont_comment_id.txt', 'w') as f:
f.write('')
f.close()