-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.py
51 lines (39 loc) · 1.29 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
import cubify
import findWords
import praw
import obot
import time
reddit = praw.Reddit(client_id=obot.client_id,
client_secret=obot.client_secret,
user_agent=obot.user_agent,
username=obot.username,
password=obot.password)
me = reddit.user.me()
while True:
try:
subreddit = reddit.subreddit('all')
comments = subreddit.stream.comments()
counter = 0
for comment in comments:
author = comment.author
#print("%s %s" %(counter, author))
if author == me:
#print('[main] not replying to self')
continue
text = comment.body
words = findWords.findWords(text)
for word in words:
if counter > 3:
counter = 0
else:
counter += 1
word = word.replace(' ', '')
result = cubify.cubify(word=word, subsqaures=(counter == 0))
if (result):
#print('[main] attempting to reply')
comment.reply(result)
print('[main] replied to a comment')
break
except:
print('Unknown Crash')
time.sleep(10)