Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 8b5d9f0

Browse files
author
PokestarFan
committed
New updates
2 parents 8e0fc63 + bef9f53 commit 8b5d9f0

File tree

7 files changed

+65
-42
lines changed

7 files changed

+65
-42
lines changed

Diff for: README.md

+21-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Bot for duplicates
55
# How to use
66

77
* Unzip
8-
* Create login.py with the following code:
8+
* Go into the modules folder and create login.py with the following code:
99

1010
```python
1111
import praw
@@ -17,3 +17,23 @@ reddit = praw.Reddit(username = 'yourusername', password = 'yourpassword', clien
1717

1818

1919
* Use
20+
21+
# Extra scripts
22+
23+
There are extra scripts that come with the bot.
24+
25+
## Delete.py
26+
27+
This script will delete any comment if a person comments delete. It is a mandatory run.
28+
29+
## gb-bb.py
30+
31+
This script controls the good bot/bad bot reply part. It is optional.
32+
33+
## lowpostremover.py
34+
35+
This script removes any comment below 1 karma. It is optional but recommended.
36+
37+
## deleteallcomments.py
38+
39+
If the bot has screwed up and made major mistakes, this script will delete all of the bot's comments.

Diff for: _config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
theme: jekyll-theme-architect
2-
show_downloads: true
2+
show_downloads: true

Diff for: delete.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def main():
1616
if 'delete' in item.body.lower():
1717
item.parent().delete()
1818
logging.info('Comment {} removed'.format(str(item.parent())))
19-
item.reply('The top level post has been removed.'+footer)
19+
item.author.message('Removal of comment {}'.format(str(item.parent())),'The top level post has been removed.')
2020
except:
2121
logging.debug('Item {} skipped'.format(str(item)))
2222
except(KeyboardInterrupt):

Diff for: deleteallcomments.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import praw
22
from modules.logger import setup_logger
3-
from modules.login import reddit
3+
from modules.login import reddit as r
44
import logging
55

6-
logger = setup_logger('remallcomments')
6+
logger = setup_logger('remove_all_comments')
77

88

99
def main(count=0):
1010
for comment in r.redditor(str(r.user.me())).comments.new(limit=None):
1111
comment.delete()
1212
logging.info('Finished comment #'+str(count)+', id {}'.format(str(comment)))
13+
count += 1
1314

1415
if __name__ == '__main__':
1516
while True:

Diff for: gb-bb.py

+36-35
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import praw
2+
import prawcore
23
from modules.logger import setup_logger
34
from modules.login import reddit
45
import logging
@@ -9,43 +10,43 @@
910
def main():
1011
try:
1112
for item in reddit.inbox.stream():
12-
written_to = 0
13-
text = ''
14-
with open('comments_written_to.txt', 'r') as file:
15-
for line in file.readlines():
16-
if line == str(item) and written_to == 0:
17-
written_to = 1
18-
logging.info('Comment {} has been already replied to.'.format(str(item)))
19-
if written_to == 0:
20-
if 'good bot' in str(item.body.lower()):
21-
text = 'Good human'
22-
item.reply(text+footer)
23-
logging.info('Message with the text {} replied to comment {}'.format(text, str(item)))
24-
with open('comments_written_to.txt', 'a') as file:
25-
file.write(str(item)+'\n')
26-
elif 'bad bot' in str(item.body.lower()):
27-
text = 'Bad human'
28-
item.reply(text+footer)
29-
logging.info('Message with the text {} replied to comment {}'.format(text, str(item)))
30-
with open('comments_written_to.txt', 'a') as file:
31-
file.write(str(item)+'\n')
32-
elif 'average bot' in str(item.body.lower()):
33-
text = 'Average human'
34-
item.reply(text+footer)
35-
logging.info('Message with the text {} replied to comment {}'.format(text, str(item)))
36-
with open('comments_written_to.txt', 'a') as file:
37-
file.write(str(item)+'\n')
38-
elif 'bot' in str(item.body.lower()):
39-
strings = str(item.body.lower()).split('bot')
40-
text = '{} human'.format(strings[0])
41-
item.reply(text+footer)
42-
logging.info('Message with the text {} replied to comment {}'.format(text, str(item)))
43-
with open('comments_written_to.txt', 'a') as file:
44-
file.write(str(item)+'\n')
13+
try:
14+
written_to = 0
15+
text = ''
16+
with open('comments_written_to.txt', 'r') as file:
17+
for line in file.readlines():
18+
if line == str(item) and written_to == 0:
19+
written_to = 1
20+
logging.info('Comment {} has been already replied to.'.format(str(item)))
21+
if written_to == 0:
22+
if 'good bot' in str(item.body.lower()):
23+
text = 'Good human'
24+
item.reply(text+footer)
25+
logging.info('Message with the text {} replied to comment {}'.format(text, str(item)))
26+
with open('comments_written_to.txt', 'a') as file:
27+
file.write(str(item)+'\n')
28+
elif 'bad bot' in str(item.body.lower()):
29+
text = 'Bad human'
30+
item.reply(text+footer)
31+
logging.info('Message with the text {} replied to comment {}'.format(text, str(item)))
32+
with open('comments_written_to.txt', 'a') as file:
33+
file.write(str(item)+'\n')
34+
elif 'average bot' in str(item.body.lower()):
35+
text = 'Average human'
36+
item.reply(text+footer)
37+
logging.info('Message with the text {} replied to comment {}'.format(text, str(item)))
38+
with open('comments_written_to.txt', 'a') as file:
39+
file.write(str(item)+'\n')
40+
except(prawcore.exceptions.Forbidden):
41+
logging.info('Blocked on /r/{}'.format(str(item.subreddit)))
42+
except(KeyboardInterrupt):
43+
raise KeyboardInterrupt
44+
except Exception as e:
45+
logging.error('Error on item {}. {}'.format(str(item),str(e)), exc_info=True)
4546
except(KeyboardInterrupt):
4647
raise KeyboardInterrupt
47-
except:
48-
logging.error('Error', exc_info = True)
48+
except Exception as e:
49+
logging.critical('Error on main loop! {}'.format(str(e)), exc_info=True)
4950

5051
if __name__ == '__main__':
5152
while True:

Diff for: modules/footer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
footer = '\n\n ---- \n\n ^^I ^^am ^^a ^^bot ^^[FAQ](https://www.reddit.com/r/DuplicatesBot/wiki/index)-[Code](https://github.com/PokestarFan/DuplicateBot)-[Bugs](https://www.reddit.com/r/DuplicatesBot/comments/6ypgmx/bugs_and_problems/)-[Suggestions](https://www.reddit.com/r/DuplicatesBot/comments/6ypg85/suggestion_for_duplicatesbot/)-[Block](https://www.reddit.com/r/DuplicatesBot/wiki/index#wiki_block_bot_from_tagging_on_your_posts)\n\n^^Now ^^you ^^can ^^remove ^^the ^^comment ^^by ^^replying ^^delete!'
1+
footer = '\n\n----\n\n ^^I ^^am ^^a ^^bot ^^[FAQ](https://www.reddit.com/r/DuplicatesBot/wiki/index)-[Code](https://github.com/PokestarFan/DuplicateBot)-[Bugs](https://www.reddit.com/r/DuplicatesBot/comments/6ypgmx/bugs_and_problems/)-[Suggestions](https://www.reddit.com/r/DuplicatesBot/comments/6ypg85/suggestion_for_duplicatesbot/)-[Block](https://www.reddit.com/r/DuplicatesBot/wiki/index#wiki_block_bot_from_tagging_on_your_posts)\n\n^^Now ^^you ^^can ^^remove ^^the ^^comment ^^by ^^replying ^^delete!'

Diff for: run.bat

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@echo off
22
start py duplicate.py
33
start py delete.py
4-
start py lowpostremover.py
4+
start py lowpostremover.py
5+
start py gb-bb.py

0 commit comments

Comments
 (0)