Help on adding subreddits my bot is banned from to the blacklist
So I have a bot that's being banned from a lot of subreddits simply for being a bot. In order to not clog up my console with errors and spam reddit, I have to manually check the inbox and paste every subreddit I'm banned from into the blacklist. Is there anyway I can make the bot fetch the inbox, check if I'm banned from any subreddits, and add it to a txt file? Something like:
blacklist = getbannedsubreddits
os.chdir('/Users/Test/Desktop/Reddit Bot')
f = open("blacklist.txt","w")
x = write(blacklist)
f.close()
Posted Sep 13, 2015, 3:18 PM UTC
12
Of course. How would you perform it in real life? First open your inbox, then read each message, then see if it looks like a ban message.
Be careful how you store this information though. If you open a file in 'w' mode, all of the file's contents are deleted. You might want to play with 'a+' mode, which leaves the current contents intact. You'll have to play with the file writing for a little bit first and make sure everything is being written safely and formatted properly. There are some other optimizations you can make such as only opening the file if the bans list is not empty, to cut down on unnecessary file operations.