コード例 #1
0
def run(r):
    print('Checking submissions...')
    config = get_config('core')
    if should_check_submissions(config):
        notify_violating_submissions(r, config, get_last_timestamp(config))
    else:
        # if state file exists, delete it to trigger fresh copy on a non monday
        if os.path.exists(config['state_filename']):
            os.remove(config['state_filename'])
    print('Submission purge complete!')
コード例 #2
0
def run(r):
    print('Checking submissions...')
    config = get_config('core')
    if should_check_submissions(config):
        notify_violating_submissions(
            r,
            config,
            get_last_timestamp(config)
        )
    else:
        # if state file exists, delete it to trigger fresh copy on a non monday
        if os.path.exists(config['state_filename']):
            os.remove(config['state_filename'])
    print('Submission purge complete!')
コード例 #3
0
def run(r):
    print('Starting update of sidebar...')
    config = get_config('core')
    mod = r.subreddit(config['subreddit']).mod
    mod_settings = mod.settings()

    time_left = compute_how_much_time_left(datetime.datetime.utcnow(),
                                           int(config['monday']))

    announcement_index = get_mlm_announcement_index_in_description(
        mod_settings)

    update_announcement_text(config, mod, mod_settings, announcement_index,
                             time_left)
    print('Update of sidebar successful!')
コード例 #4
0
def get_es_instance():
    conf = get_config()
    ssl_context = create_ssl_context()
    ssl_context.check_hostname = False
    ssl_context.verify_mode = ssl.CERT_NONE

    user = conf['es']['user']
    password = conf['es']['password']
    if user and password:
        auth = (user, password)
    else:
        auth = None

    return Elastic(hosts=[conf['es']['host']],
                   http_auth=auth,
                   scheme=conf['es']['scheme'],
                   port=conf['es']['port'],
                   ssl_context=ssl_context)
コード例 #5
0
ファイル: best_of.py プロジェクト: teh-username/itap_bot
def run(r):
    print('Starting best of processing...')
    config = get_config('best_of')
    generate_best_of_lists(r, config)
    time.sleep(1)
    post_nominations_to_voting_thread(r, config)
コード例 #6
0
ファイル: itap_bot.py プロジェクト: teh-username/itap_bot
import schedule
from utils.config_reader import get_config
from modules.mlm_sidebar_update import run as mlm_sidebar_update
from modules.mlm_submission_check import (
    run as mlm_submission_check
)
from modules.best_of import run as best_of_itap
from modules.slack_bot import send_error_log


# system wide flags
timekeeping = -1
debug = True if '--debug' in sys.argv[1:] else False

# Retrieve config
config = get_config('core')
config['monday'] = int(config['monday'])
slack_config = get_config('slack_bot')

# generate instance of praw
print('Logging in...')

user_agent = "r/itookapicture MLM announcer v4.2.0 by /u/tehusername"

while True:
    try:
        r = praw.Reddit(
            client_id=os.environ['ITAP_ID'],
            client_secret=os.environ['ITAP_SECRET'],
            username=os.environ['ITAP_USERNAME'],
            password=os.environ['ITAP_PASSWORD'],
コード例 #7
0
import traceback
import sys
import praw
import schedule
from utils.config_reader import get_config
from modules.mlm_sidebar_update import run as mlm_sidebar_update
from modules.mlm_submission_check import (run as mlm_submission_check)
from modules.best_of import run as best_of_itap
from modules.slack_bot import send_error_log

# system wide flags
timekeeping = -1
debug = True if '--debug' in sys.argv[1:] else False

# Retrieve config
config = get_config('core')
config['monday'] = int(config['monday'])
slack_config = get_config('slack_bot')

# generate instance of praw
print('Logging in...')

user_agent = "r/itookapicture MLM announcer v4.2.0 by /u/tehusername"

while True:
    try:
        r = praw.Reddit(client_id=os.environ['ITAP_ID'],
                        client_secret=os.environ['ITAP_SECRET'],
                        username=os.environ['ITAP_USERNAME'],
                        password=os.environ['ITAP_PASSWORD'],
                        user_agent=user_agent)
コード例 #8
0
ファイル: best_of.py プロジェクト: teh-username/itap_bot
def run(r):
    print('Starting best of processing...')
    config = get_config('best_of')
    generate_best_of_lists(r, config)
    time.sleep(1)
    post_nominations_to_voting_thread(r, config)
コード例 #9
0
def get_path_raw_file(relative_path):
    return os.path.join(get_config(['data', 'raw']), relative_path)
コード例 #10
0
def get_path_processed_file(relative_path):
    return os.path.join(get_config(['data', 'processed']), relative_path)
コード例 #11
0
def get_path_intermediate_file(relative_path):
    return os.path.join(get_config(['data', 'intermediate']), relative_path)