Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests # see https://2.python-requests.org/en/master/
- import sys
- key = '-eLIPaTzebsJVnmuSf5oOvY9JaJpmMZD'
- formate_data = {
- "py":"python",
- "c":"c",
- "vim":"vim"
- }
- login_data = {
- 'api_dev_key': key,
- 'api_user_name': 'Abstract-Chief',
- 'api_user_password': 'dkcXk?8kz4VPViW'
- }
- def get_api_user_key(data):
- login = requests.post ( "https://pastebin.com/api/api_login.php", data=login_data )
- print ( "Login status: ", login.status_code if login.status_code != 200 else "OK/200" )
- print ( "User token: ", login.text )
- data['api_user_key'] = login.text
- return data
- def get_info():
- data = {
- 'api_option': 'userdetails',
- 'api_dev_key': key,
- }
- data=get_api_user_key(data)
- post(data)
- def read_file(file_name):
- with open(file_name,"r") as file:
- text=file.read()
- return text
- def create_file(args):
- text = read_file(args[1]+"/"+args[2])
- folder = args[1].split('/')[-1]
- t_title = folder+"/"+args[2]
- data = {
- 'api_option': 'paste',
- 'api_dev_key': key,
- 'api_paste_code': text,
- 'api_paste_name': t_title,
- 'api_paste_expire_date': "N",
- 'api_user_key': None,
- 'api_paste_format': formate_data[args[2].split(".")[-1]],
- 'api_paste_private': 0,
- }
- data = get_api_user_key ( data )
- post ( data )
- def post(data):
- r = requests.post ( "https://pastebin.com/api/api_post.php", data=data )
- print ( "Paste send: ", r.status_code if r.status_code != 200 else "OK/200" )
- print ( "Paste URL: ", r.text )
- add_in_bd(data["api_paste_name"],r.text,data["api_paste_private"])
- def config():
- if len(sys.argv)<3:
- sys.exit()
- return sys.argv
- def add_in_bd(name,link,priv_level):
- data=""
- if link[0]!="h":
- return 0;
- try:
- with open("DATABASE","r") as file:
- data=file.readline()
- data.remove("\n")
- if len(data)>=1:
- data+=","
- except:
- with open("DATABASE","w") as file:
- pass
- data+=name+"|"+link+"|"+str(priv_level)
- print(data)
- with open("DATABASE","w") as file:
- file.write(data)
- a=config()
- print(a)
- if a[3]=="post":
- create_file(a)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement