(login_confirm_text, reddit_state)
Looks for if a praw reddit user already exists, and if so logs in with it
    :param login_confirm_text: The UI text saying "logged in as USER"
    :param reddit_state: dictionary holding reddit settings
    :return: none
Looks for if a praw reddit user already exists, and if so logs in with it
    :param login_confirm_text: The UI text saying "logged in as USER"
    :param reddit_state: dictionary holding reddit settings
    :return: none
Looks for if a praw reddit user already exists and if so logs in with it : param login_confirm_text : The UI text saying logged in as USER : param reddit_state : dictionary holding reddit settings : return : none
def initialize_reddit_user(login_confirm_text, reddit_state):
    """
    Looks for if a praw reddit user already exists, and if so logs in with it
    :param login_confirm_text: The UI text saying "logged in as USER"
    :param reddit_state: dictionary holding reddit settings
    :return: none
    """
    try:
        if (reddit_state['refresh_token']):
            reddit = praw.Reddit(
                client_id=reddit_state['reddit_client_id'],
                client_secret=reddit_state['reddit_client_secret'],
                user_agent=USER_AGENT,
                refresh_token=reddit_state['refresh_token']
            )
        else:
            reddit = praw.Reddit(
                client_id=reddit_state['reddit_client_id'],
                client_secret=reddit_state['reddit_client_secret'],
                user_agent=USER_AGENT,
                username=reddit_state['reddit_username'],
                password=reddit_state['reddit_password'],
            )
        reddit.user.me()

        reddit_username = str(reddit.user.me())
        reddit_state['user'] = reddit.redditor(reddit_username)

        login_confirm_text.set(f'Logged in to Reddit as {reddit_username}')

        initialize_state(reddit_state)
    except:
        pass
def initialize_reddit_user ( login_confirm_text , reddit_state ) : try : if ( reddit_state [ 'refresh_token' ] ) : reddit = praw . Reddit ( client_id = reddit_state [ 'reddit_client_id' ] , client_secret = reddit_state [ 'reddit_client_secret' ] , user_agent = USER_AGENT , refresh_token = reddit_state [ 'refresh_token' ] ) else : reddit = praw . Reddit ( client_id = reddit_state [ 'reddit_client_id' ] , client_secret = reddit_state [ 'reddit_client_secret' ] , user_agent = USER_AGENT , username = reddit_state [ 'reddit_username' ] , password = reddit_state [ 'reddit_password' ] , ) reddit . user . me ( ) reddit_username = str ( reddit . user . me ( ) ) reddit_state [ 'user' ] = reddit . redditor ( reddit_username ) login_confirm_text . set ( f'Logged in to Reddit as {reddit_username}' ) initialize_state ( reddit_state ) except : pass