Hid Discord API Key in Discord.key
This commit is contained in:
parent
e387f1802b
commit
ec4554e248
2 changed files with 2 additions and 52 deletions
|
|
@ -1,51 +0,0 @@
|
|||
#This tutorial was built by me, Farzain! You can ask me questions or troll me on Twitter (@farzatv)
|
||||
|
||||
#First we need to import requests. Installing this is a bit tricky. I included a step by step process on how to get requests in readme.txt which is included in the file along with this program.
|
||||
import requests
|
||||
|
||||
def requestSummonerData(region, summonerName, APIKey):
|
||||
|
||||
#Here is how I make my URL. There are many ways to create these.
|
||||
|
||||
URL = "https://" + region + ".api.pvp.net/api/lol/" + region + "/v1.4/summoner/by-name/" + summonerName + "?api_key=" + APIKey
|
||||
print URL
|
||||
#requests.get is a function given to us my our import "requests". It basically goes to the URL we made and gives us back a JSON.
|
||||
response = requests.get(URL)
|
||||
#Here I return the JSON we just got.
|
||||
return response.json()
|
||||
|
||||
def requestRankedData(region, ID, APIKey):
|
||||
URL = "https://" + region + ".api.pvp.net/api/lol/" + region + "/v2.5/league/by-summoner/" + ID + "/entry?api_key=" + APIKey
|
||||
print URL
|
||||
response = requests.get(URL)
|
||||
return response.json()
|
||||
|
||||
|
||||
def main():
|
||||
print "\nWhat up homie. Enter your region to get started"
|
||||
print "Type in one of the following regions or else the program wont work correctly:\n"
|
||||
print "NA or EUW (Note: You can add more regions by just changing up the URL!\n"
|
||||
|
||||
#I first ask the user for three things, their region, summoner name, and API Key.
|
||||
#These are the only three things I need from them in order to get create my URL and grab their ID.
|
||||
|
||||
region = (str)(raw_input('Type in one of the regions above: '))
|
||||
summonerName = (str)(raw_input('Type your Summoner Name here and DO NOT INCLUDE ANY SPACES: '))
|
||||
APIKey = (str)(raw_input('Copy and paste your API Key here: '))
|
||||
|
||||
#I send these three pieces off to my requestData function which will create the URL and give me back a JSON that has the ID for that specific summoner.
|
||||
#Once again, what requestData returns is a JSON.
|
||||
responseJSON = requestSummonerData(region, summonerName, APIKey)
|
||||
|
||||
ID = responseJSON[summonerName]['id']
|
||||
ID = str(ID)
|
||||
print ID
|
||||
responseJSON2 = requestRankedData(region, ID, APIKey)
|
||||
print responseJSON2[ID][0]['tier']
|
||||
print responseJSON2[ID][0]['entries'][0]['division']
|
||||
print responseJSON2[ID][0]['entries'][0]['leaguePoints']
|
||||
|
||||
#This starts my program!
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
|
@ -227,4 +227,5 @@ if __name__ == '__main__':
|
|||
client.load()
|
||||
with open("API.key", "r") as f:
|
||||
client.initAPI(f.read())
|
||||
client.run("ODQzNDQ4NDg3MzgyNzQ1MDk4.YKEAnQ.qyeogazdj2w4Tt7hEnBZmfcN0Xw")
|
||||
with open("Discord.key", "r") as f:
|
||||
client.run(f.read())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue