class Gonewild(object): def __init__(self): # Single file that all output is written to, to track usage self.exit_if_already_started() self.root_log = open(path.join(ImageUtils.get_root(), 'history.log'), 'a') self.logger = self.root_log # Logger used by helper classes self.db = DB() # Database instance self.reddit = Reddit() try: (username, password) = self.db.get_credentials('reddit') try: self.reddit.login(username, password) except Exception, e: self.debug('__init__: failed to login to reddit: %s' % str(e)) except Exception, e: self.debug('__init__: failed to get reddit credentials: %s' % str(e))
class Expunger: deleteMsg = "Deleted" shouldDelete = False verboseMode = False def __init__(self, username, password, clientId, clientSecret): self.reddit = Reddit(username, password, clientId, clientSecret) def run(self): allComments = self.reddit.getComments() if self.reddit.login() is True: for commentId in allComments: deleteMsg = self.deleteMsg + " " + self.randomString(8) editSuccess = self.reddit.editComment(commentId, deleteMsg) print(commentId + " - Edit " + ("Successful" if editSuccess else "Failed")) if self.verboseMode: print("New comment body: \"" + deleteMsg + "\"") print("Operation completed") else: print("Login failed - check your details") def setDeleteMsg(self, msg): self.deleteMsg = msg def setVerboseMode(self, value): self.verboseMode = value def randomString(self, length): return "".join( random.choice(string.ascii_lowercase + string.ascii_uppercase + string.digits) for _ in range(length))
print '[!] inserting "blank" admin' total_scores = db.select_one('sum(score)', 'admins', 'username != ""') db.update('admins', 'score = ?', 'username = ""', [total_removed - total_scores]) print '[!] updated "blank" admin with score: %d' % total_scores db.commit() ####################### # Login to reddit print '[ ] logging in to reddit' username = db.get_config('reddit_user') password = db.get_config('reddit_pw') if username == None or password == None: print '[!] "reddit_user" or "reddit_pw" were not found in "config" table in database' Reddit.login(username, password) print '[ ] executing AmArch.py functionality...' def log(txt): print txt AmArch.execute(db, log) # MODERATED SUBS (real-time) print '[ ] finding modded subs...' current = Reddit.get_modded_subreddits() print '[ ] found %d subs modded by /u/%s' % (len(current), username) # remove subs that should be ignored to_ignore = db.get_config('ignore_subreddits') if to_ignore != None: for ignore in to_ignore.split(','):