Last active
May 11, 2021 18:32
-
-
Save iandenegri/129ef497f67d3f1e67365f3a6944c2de to your computer and use it in GitHub Desktop.
LEAGUE GRIEF CHECKER FOR RP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
API_KEY = "" | |
def create_champion_mapping(): | |
champ_map = dict() | |
champion_json = requests.get("http://ddragon.leagueoflegends.com/cdn/9.22.1/data/en_US/champion.json") | |
for champion in champion_json.json()['data']: | |
key = champion_json.json()['data'][champion]['key'] | |
champ_map[key] = champion_json.json()['data'][champion]['id'] | |
return champ_map | |
def grief_check(all_champ_map): | |
summoner_name = input("Enter your summoner name: ").replace(" ", "") | |
# summoner_name = "imbabydog" | |
summoner_request = requests.get(("https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/%s?api_key=%s" % summoner_name, API_KEY)) | |
summoner_request.encoding = 'utf-8' # Optional: requests infers this internally | |
summoner_account_id = (summoner_request.json()['accountId']) | |
match_request = requests.get(("https://na1.api.riotgames.com/lol/match/v4/matchlists/by-account/%s?api_key=%s" % summoner_account_id, API_KEY)) | |
last_match_id = match_request.json()['matches'][0]['gameId'] | |
last_match = requests.get(("https://na1.api.riotgames.com/lol/match/v4/matches/%s?api_key=%s" % last_match_id, API_KEY)) | |
for player in last_match.json()['participantIdentities']: | |
if summoner_account_id == player['player']['accountId']: | |
last_played_id = player['participantId'] | |
for player in last_match.json()['participants']: | |
if last_played_id == player['participantId']: | |
print("Welcome %s" % summoner_name) | |
if player['stats']['win'] == True: | |
print("Wowee you won your last game.") | |
print("You played champion " + all_champ_map[str(player['championId'])] + ", your KD was " + str((player['stats']['kills'] + player['stats']['assists'])/player['stats']['deaths'])) | |
else: | |
print("You lost your last game because you're a griefer :-/") | |
print("You played " + all_champ_map[str(player['championId'])] + ", your KD was " + str((player['stats']['kills'] + player['stats']['assists'])/player['stats']['deaths'])) | |
all_champ_map = create_champion_mapping() | |
grief_check(all_champ_map) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment