<commit_before>'''
Created on 20/07/2013

@author: luke
'''
import time
import praw
import string
from getpass import getpass
USERNAME    = ""

class RedditBot(object):
    """
    RedditBot: 
        Configurations
            tracks subreddits to check rules in
            has a list of rules for making comments
        Should not reply to the same thread twice
        tracks all replies made
        abilities:
            make a comment
            cehck subreddits to attempt to find a place to comment
            check if URL is a comment on reddit
            login as user x
    """


    def __init__(self,rules):
        <commit_msg>properties and submission from subreddit getter<commit_after>'''
Created on 20/07/2013

@author: luke
'''
import time
import praw
import string
from getpass import getpass
USERNAME    = ""

class RedditBot(object):
    """
    https://praw.readthedocs.org/en/latest/pages/writing_a_bot.html
    RedditBot: 
        Configurations
            tracks subreddits to check rules in
            has a list of rules for making comments
        Should not reply to the same thread twice
        tracks all replies made
        abilities:
            make a comment
            cehck subreddits to attempt to find a place to comment
            check if URL is a comment on reddit
            login as user x
    """
    # set unique and descriptive user_agent
    __user_agent    = "reddit_bot_test v0.0 by /u/drhealsgood and /u/"
    # create Reddit object
    __reddit        = praw.Reddit(__user_agent)

    def __init__(self,rules,subreddits):
        # log in
        self.__reddit.login(USERNAME,getpass())
        self.__rules        = rules
        self.__subreds      = subreddits
        # submission: comments
        self.__submissions  = {}
        
    @property
    def submissions(self):
        return self.__submissions
    
    @property
    def rules(self):
        return self.__rules
    
    def add_rule(self, rule):
        self.__rules.append(rule)
    
    @property
    def subreddits(self):
        return self.__subreds
    
    @subreddits.setter
    def subreddits(self,new_subreddits):
        self.__subreddits   = new_subreddits
    
    def add_subreddit(self,subreddit):
        self.__subreds.append(subreddit)
        
    def _get_submissions(self,subreddit,n):
        """
            returns top n submissions from
            subreddit
        """
        return self.__reddit.get_subreddit(subreddit).get_top(limit=n)
{'fraction_non_alphanumeric': 0.06517393042782887, 'fraction_numerical': 0.007197121151539384, 'mean_word_length': 2.058679706601467, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1392241', 'n_tokens_mistral': 725, 'n_tokens_neox': 713, 'n_words': 220}