Advertisement
Abstract-Chief

test/main.py

Mar 7th, 2022
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.17 KB | None | 0 0
  1. import requests  # see https://2.python-requests.org/en/master/
  2. import sys
  3. key = '-eLIPaTzebsJVnmuSf5oOvY9JaJpmMZD'
  4. formate_data = {
  5.     "py":"python",
  6.     "c":"c",
  7.     "vim":"vim"
  8. }
  9. login_data = {
  10.     'api_dev_key': key,
  11.     'api_user_name': 'Abstract-Chief',
  12.     'api_user_password': 'dkcXk?8kz4VPViW'
  13. }
  14. def get_api_user_key(data):
  15.     login = requests.post ( "https://pastebin.com/api/api_login.php", data=login_data )
  16.     print ( "Login status: ", login.status_code if login.status_code != 200 else "OK/200" )
  17.     print ( "User token: ", login.text )
  18.     data['api_user_key'] = login.text
  19.     return data
  20. def get_info():
  21.  
  22.     data = {
  23.         'api_option': 'userdetails',
  24.         'api_dev_key': key,
  25.     }
  26.     data=get_api_user_key(data)
  27.     post(data)
  28.  
  29. def read_file(file_name):
  30.     with open(file_name,"r") as file:
  31.         text=file.read()
  32.     return text
  33. def create_file(args):
  34.     text = read_file(args[1]+"/"+args[2])
  35.     folder = args[1].split('/')[-1]
  36.     t_title = folder+"/"+args[2]
  37.     data = {
  38.         'api_option': 'paste',
  39.         'api_dev_key': key,
  40.         'api_paste_code': text,
  41.         'api_paste_name': t_title,
  42.         'api_paste_expire_date': "N",
  43.         'api_user_key': None,
  44.         'api_paste_format': formate_data[args[2].split(".")[-1]],
  45.         'api_paste_private': 0,
  46.     }
  47.     data = get_api_user_key ( data )
  48.     post ( data )
  49. def post(data):
  50.     r = requests.post ( "https://pastebin.com/api/api_post.php", data=data )
  51.     print ( "Paste send: ", r.status_code if r.status_code != 200 else "OK/200" )
  52.     print ( "Paste URL: ", r.text )
  53.     add_in_bd(data["api_paste_name"],r.text,data["api_paste_private"])
  54. def config():
  55.     if len(sys.argv)<3:
  56.         sys.exit()
  57.     return sys.argv
  58. def add_in_bd(name,link,priv_level):
  59.     data=""
  60.     if link[0]!="h":
  61.         return 0;
  62.     try:
  63.         with open("DATABASE","r") as file:
  64.             data=file.readline()
  65.             data.remove("\n")
  66.         if len(data)>=1:
  67.             data+=","
  68.     except:
  69.         with open("DATABASE","w") as file:
  70.             pass
  71.     data+=name+"|"+link+"|"+str(priv_level)
  72.     print(data)
  73.     with open("DATABASE","w") as file:
  74.         file.write(data)
  75. a=config()
  76. print(a)
  77. if a[3]=="post":
  78.    create_file(a)
  79.  
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement