Example #1
0
""" New post checker """

import sys
import re
import sqlite3
import unicodedata
import json
import os
from datetime import datetime
from time import sleep

from log_conf import LoggerManager
from common import SubRedditMod

# configure logging
LOGGER = LoggerManager().getLogger("post_check")


class PostChecker(object):
    """ Post check helper """
    def __init__(self, subreddit, db_con, post_categories, locations):
        self._subreddit = subreddit
        self._config = subreddit.config["post_check"]
        self._user_db_con = db_con
        self._user_db_cursor = self._user_db_con.cursor()
        self._post_categories = post_categories
        self._locations = locations

    def _get_user_db_entry(self, post):
        self._user_db_cursor.execute('SELECT * FROM user WHERE username=?',
                                     (post.author.name, ))
Example #2
0
path_to_cfg = os.path.join(containing_dir, 'config.cfg')
cfg_file.read(path_to_cfg)
username = cfg_file.get('reddit', 'username')
password = cfg_file.get('reddit', 'password')
subreddit = cfg_file.get('reddit', 'subreddit')
multiprocess = cfg_file.get('reddit', 'multiprocess')
link_id = cfg_file.get('trade', conf_link_id)
equal_warning = cfg_file.get('trade', 'equal')
age_warning = cfg_file.get('trade', 'age')
karma_warning = cfg_file.get('trade', 'karma')
added_msg = cfg_file.get('trade', 'added')
age_check = int(cfg_file.get('trade', 'age_check'))
karma_check = int(cfg_file.get('trade', 'karma_check'))

# Configure logging
logger = LoggerManager().getLogger(__name__)


def main():
    def conditions():
        if comment.id in completed:
            return False
        if not hasattr(comment.author, 'name'):
            return False
        if 'confirm' not in comment.body.lower():
            return False
        if comment.author.name == username:
            return False
        if comment.is_root == True:
            return False
        if comment.banned_by:
Example #3
0
#!/usr/bin/env python2

import sys
import re
import argparse
from datetime import datetime

from log_conf import LoggerManager
from common import SubRedditMod

# Configure logging
LOGGER = LoggerManager().getLogger("trade_flair")


class TradeFlairer(object):
    """ Trade flair helper """
    def __init__(self, subreddit, logger):
        self._subreddit = subreddit
        self._config = subreddit.config["trade"]
        self.completed = []
        self.pending = []
        self._trade_count_cache = {}
        self._current_submission = None
        self._logger = logger

    def open_submission(self, submission):
        if submission == "curr":
            submission = self._config["link_id"]
        elif submission == "prev":
            submission = self._config["prevlink_id"]
        self._current_submission = submission
Example #4
0
subreddit = cfg_file.get('reddit', 'subreddit')
link_id = cfg_file.get('trade', conf_link_id)
equal_warning = cfg_file.get('trade', 'equal')
age_warning = cfg_file.get('trade', 'age')
karma_warning = cfg_file.get('trade', 'karma')
dev_warning = cfg_file.get('trade', 'dev')
reply = cfg_file.get('trade', 'reply')
age_check = cfg_file.getint('trade', 'age_check')
karma_check = cfg_file.getint('trade', 'karma_check')
flair_db = cfg_file.get('trade', 'flair_db')
flair_dev = cfg_file.getint('trade', 'flair_dev')
notrade_flairclass = ast.literal_eval(
    cfg_file.get('trade', 'notrade_flairclass'))

# Configure logging
logger = LoggerManager().getLogger(__name__)


def main():
    def conditions():
        if not hasattr(comment.author, 'name'):
            return False
        if 'confirm' not in comment.body.lower():
            return False
        if comment.author.name == username:
            return False
        if comment.is_root is True:
            return False
        if comment.banned_by:
            return False
        return True