Exemplo n.º 1
0
def setup_bot():
    """
    Sets up the bot by setting the refresh_token and the refresh_token through oauth
    """
    config = get_config()

    app_key = config.get("oauth", "reddit_app_key")
    app_secret = config.get("oauth", "reddit_app_secret")

    print "Getting OAUTH tokens."
    oauth_server = PrawOAuth2Server(REDDIT_CLIENT, app_key, app_secret, state=USER_AGENT, scopes=SCOPES)
    oauth_server.start()

    tokens = oauth_server.get_access_codes()
    config.set("oauth", "reddit_refresh_token", tokens['refresh_token'])
    config.set("oauth", "reddit_access_token", tokens['access_token'])

    cfgfile = open("config.ini", 'w')
    config.write(cfgfile)
    cfgfile.close()
Exemplo n.º 2
0
#!/usr/bin/env python
"""
Bot User Management
"""

import DBManager
from OfferBot import get_config

Config = get_config()


def plus_job(user):
    """
    Adds a job to a user
    :param user:
    """
    userdb = DBManager.get_user(user)
    new_jobs = userdb['jobs'] + 1
    DBManager.update_user(user, new_jobs, userdb['reputation'])


def minus_job(user):
    """
    Removes a job to a user
    :param user:
    """
    userdb = DBManager.get_user(user)
    new_jobs = userdb['jobs'] - 1
    DBManager.update_user(user, new_jobs, userdb['reputation'])