Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try:
- import os
- except:
- print("failed to import os")
- exit()
- try:
- import os.path
- except:
- print("failed to import os.path")
- exit()
- try:
- import sys
- except:
- print("failed to import sys")
- exit()
- try:
- import time
- except:
- print("failed to import time")
- exit()
- try:
- import getpass
- except:
- print("failed to import getpass")
- exit()
- if sys.version_info[0] < 3:
- print("You must be using Python 3")
- exit()
- try:
- import praw
- except:
- print("Praw is not installed. You can install it with pip3:\n>>> pip3 install praw")
- exit()
- if os.path.exists("first_run") != True:
- print("First time. Redditerminal setup...\n")
- time.sleep(1)
- print("=== INSTRUCTIONS ===")
- print("First, go here: https://www.reddit.com/prefs/apps/")
- print("Then, scroll down and select 'create an app...'")
- print("1. Set Name to 'redditerminal'")
- print("2. Set Description to whatever you want")
- print("3. Select the 'script' radio button")
- print("4. Redirect URI can be a url of your choice.")
- print(" for example, set it to:\n http://localhost/")
- print("4.1. Leave the About URL blank")
- print("5. Press 'create app'\n")
- print("What is your client id? (it is below the text, 'personal use script',\n which is below your programs Name)")
- clientid = input(">>> ")
- print("\nWhat is your client secret?")
- clientsecret = input(">>> ")
- print("\nStoring information...")
- os.system("mkdir first_run")
- file = open("clientid.cfg","w")
- file.write(clientid)
- file.close()
- file = open("clientsecret.cfg","w")
- file.write(clientsecret)
- file.close()
- print("\nDone! Please re-start the program.")
- exit()
- try:
- file = open("clientid.cfg", "r")
- clientid2 = file.read()
- file = open("clientsecret.cfg", "r")
- clientsecret2 = file.read()
- except:
- print("Could not find file(s) and display the text. Something is broken...")
- exit()
- username = input("Username: ")
- passwd = getpass.getpass()
- try:
- reddit = praw.Reddit(client_id=clientid2, client_secret=clientsecret2, username=username, password=passwd, user_agent='redditerminal by /u/'+username)
- except:
- print("Your clientid or clientsecret might've mistakenly been wrong.\n")
- choice = input("Delete files (y/n)? ")
- if choice == "y" or choice == "yes" or choice == "sure" or choice == "ye" or choice == "yess" or choice == "yyes" or choice == "yees" or choice == "yeess" or choice == "yyees" or choice == "yyeess" or choice == "yee" or choice == "yep" or choice == "yesh": #yesh is something only sudolinux would say... lol
- choice = input("Windows or Linux[or mac] (w,l)? ")
- if choice == "windows" or choice == "w" or choice == "win" or choice == "wind" or choice == "window" or choice == "windows 10" or choice == "windows 8" or choice == "windows 7" or choice == "windows xp" or choice == "windows vista" or choice == "windows 2000": #oh the memories.. jk, linux rules
- print("Deleting...")
- os.system("del clientid.cfg")
- os.system("del clientsecret.cfg")
- os.system("rmdir first_run")
- print("Please re-run the program to enter setup again.")
- exit()
- else:
- print("Deleting...")
- os.system("rm -rf clientid.cfg")
- os.system("rm -rf clientsecret.cfg")
- os.system("rm -rf first_run")
- print("Please re-run the program to enter setup again.")
- exit()
- else:
- print("Ok. Exiting...")
- exit()
- try:
- user = reddit.user.me()
- print("You are logged in as",user)
- except:
- print("Failed to Login. 1/3 Attempts")
- username = input("\nUsername: ")
- passwd = getpass.getpass()
- try:
- reddit = praw.Reddit(client_id=clientid2, client_secret=clientsecret2, username=username, password=passwd, user_agent='redditerminal by /u/'+username)
- except:
- print("Your clientid or clientsecret might've mistakenly been wrong.\n")
- choice = input("Delete files (y/n)? ")
- if choice == "y" or choice == "yes" or choice == "sure" or choice == "ye" or choice == "yess" or choice == "yyes" or choice == "yees" or choice == "yeess" or choice == "yyees" or choice == "yyeess" or choice == "yee" or choice == "yep" or choice == "yesh": #yesh is something only sudolinux would say... lol
- choice = input("Windows or Linux[or mac] (w,l)? ")
- if choice == "windows" or choice == "w" or choice == "win" or choice == "wind" or choice == "window" or choice == "windows 10" or choice == "windows 8" or choice == "windows 7" or choice == "windows xp" or choice == "windows vista" or choice == "windows 2000": #oh the memories.. jk, linux rules
- print("Deleting files...")
- os.system("del clientid.cfg")
- os.system("del clientsecret.cfg")
- os.system("rmdir first_run")
- print("Please re-run the program to enter setup again.")
- exit()
- else:
- print("Deleting files...")
- os.system("rm -rf clientid.cfg")
- os.system("rm -rf clientsecret.cfg")
- os.system("rm -rf first_run")
- print("Please re-run the program to enter setup again.")
- exit()
- else:
- print("Ok. Exiting...")
- exit()
- try:
- user = reddit.user.me()
- print("You are logged in as",user)
- except:
- print("Failed to Login. 2/3 Attempts")
- username = input("\nUsername: ")
- passwd = getpass.getpass()
- try:
- reddit = praw.Reddit(client_id=clientid2, client_secret=clientsecret2, username=username, password=passwd, user_agent='redditerminal by /u/'+username)
- except:
- print("Your clientid or clientsecret might've mistakenly been wrong.\n")
- choice = input("Delete files (y/n)? ")
- if choice == "y" or choice == "yes" or choice == "sure" or choice == "ye" or choice == "yess" or choice == "yyes" or choice == "yees" or choice == "yeess" or choice == "yyees" or choice == "yyeess" or choice == "yee" or choice == "yep" or choice == "yesh": #yesh is something only sudolinux would say... lol
- choice = input("Windows or Linux[or mac] (w,l)? ")
- if choice == "windows" or choice == "w" or choice == "win" or choice == "wind" or choice == "window" or choice == "windows 10" or choice == "windows 8" or choice == "windows 7" or choice == "windows xp" or choice == "windows vista" or choice == "windows 2000": #oh the memories.. jk, linux rules
- print("Deleting...")
- os.system("del clientid.cfg")
- os.system("del clientsecret.cfg")
- os.system("rmdir first_run")
- print("Please re-run the program to enter setup again.")
- exit()
- else:
- print("Deleting...")
- os.system("rm -rf clientid.cfg")
- os.system("rm -rf clientsecret.cfg")
- os.system("rm -rf first_run")
- print("Please re-run the program to enter setup again.")
- exit()
- else:
- print("Ok. Exiting...")
- exit()
- try:
- user = reddit.user.me()
- print("You are logged in as", user)
- except:
- print("Failed to Login. 3/3 Attempts. Giving up.")
- exit()
- print("Login success!\n")
- print("Welcome to Redditerminal v0.1! Type 'h' for help!")
- while(1):
- print("This build is just an example to get login working.") # remove this message
- opt = input(">>> ")
- if opt == "help" or opt == "h" or opt == "stuck" or opt == "?" or opt == "h?" or opt == "help?":
- print("\aBasic Commands:")
- print("nothing")
Add Comment
Please, Sign In to add comment