-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
54 lines (40 loc) · 1.16 KB
/
main.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
54
from prawcore.exceptions import RequestException, ServerError
from Reddit import reddit
import time
from utils import (
SignalHandler,
commentCheck,
downloadNewSubtitles,
getActiveSubs,
inboxCheck,
processComment,
)
signalHandler = SignalHandler()
def main():
downloadNewSubtitles()
commentCheckTime = 0
inboxCheckTime = 0
me = reddit.user.me()
for comment in reddit.subreddit(getActiveSubs()).stream.comments():
signalHandler.loopStart()
if time.time() > inboxCheckTime:
inboxCheck()
inboxCheckTime = time.time() + 3600 * 12
if time.time() > commentCheckTime:
commentCheck()
commentCheckTime = time.time() + 1800
if not (comment.saved or comment.author == me):
processComment(comment)
signalHandler.loopEnd()
if __name__ == "__main__":
print("Starting the bot")
while True:
try:
main()
# Network Issues
except (RequestException, ServerError) as e:
print(e)
time.sleep(60)
else:
print("Program ended. It aint supposed to")
break