def get_tilt(area, summoner_name): try: watcher = RiotWatcher(API_KEY, default_region=area) champions_dict = get_champions_data(watcher) # check if we have API calls remaining if watcher.can_make_request(): current_app.logger.debug('Requests to API available') else: current_app.logger.error('Too many requests. ' 'Please try again later.') sys.exit(2) try: player = watcher.get_summoner(name=summoner_name, region=area) except LoLException: current_app.logger.debug('Summoner {0} not found.'.format( summoner_name)) raise SummonerNotFound( 'Summoner {0} not found in {1} server.'.format( summoner_name, area.upper())) recent_games = watcher.get_recent_games(player['id'])['games'] response = {"status": 200, "wins": get_wins_number(recent_games), "metadata": { "background": get_random_background_url( champions_dict), "display": get_random_display()}, "stats": get_stats(recent_games, champions_dict), "summoner_name": summoner_name, "tilt_level": get_tilt_level(recent_games)} return response except: current_app.logger.error(traceback.format_exc()) raise
leagueApi = RiotWatcher('04328930-7ab0-4e23-8c83-af1bbc4147ea') #Get Summoner ID and Stats summoner = raw_input("Enter your summoner name: ") opponent = raw_input("Enter your opponent's summoner name:") if leagueApi.can_make_request(): summonerId = leagueApi.get_summoner(name=summoner) opponentId = leagueApi.get_summoner(name=opponent) print print "Welcome Summoner!" bet = raw_input("Enter the amount of $ you would like to bet: ") print print "You've bet", bet, "dollars" lastPlayedGame = leagueApi.get_recent_games(summonerId['id'])['games'][0]['createDate'] currentDate = lastPlayedGame print "Waiting for you to play a game!" while lastPlayedGame == currentDate: #Checks every 10 seconds for new game time.sleep(10) currentDate = leagueApi.get_recent_games(summonerId['id'])['games'][0]['createDate'] #Need to also make a check to see if the other player was playing summonerGameId = leagueApi.get_recent_games(summonerId['id'])['games'][0]['gameId'] opponentGameId = leagueApi.get_recent_games(opponentId['id'])['games'][0]['gameId'] if summonerGameId == opponentGameId: if leagueApi.get_recent_games(summonerId['id'])['games'][0]['stats']['win']: print "You have beat your enemy! You win", bet, "dollars!"
with open('pulled_matches.txt','r') as file: for line in file: pulled_matches.append(int(line)) pulled_matches_count +=1 pulled_matches_file = open('pulled_matches.txt', 'a') while True: if len(unpulled_summoners) == 0: #if we run out of summoners, hopefully older summoners already played new matches unpulled_summoners = random.sample(pulled_summoners, 30) pulled_summoners = list() current_summoner_id = unpulled_summoners.pop(0) try: wait_for_request_availability(w) match_history = w.get_recent_games(current_summoner_id) except Exception,e: print("An ERROR occurred when pulling match history data for summonerId {0}! {1}".format(current_summoner_id,e)) unpulled_summoners.insert(0, current_summoner_id) continue pulled_summoners.append(current_summoner_id) for match in match_history['games']: matchId = match['gameId'] if matchId not in pulled_matches and match['subType'] in ('RANKED_SOLO_5x5','RANKED_PREMADE_5x5') and match['createDate'] > int(time.time()*1000) - 3*24*60*60000: pulled_matches.append(matchId) pulled_matches_file.write(str(matchId) + '\n') participants_ids = [player['summonerId'] for player in match['fellowPlayers']] try: wait_for_request_availability(w) participants_league_data = w.get_league(summoner_ids=participants_ids)
from riotwatcher import RiotWatcher import json w = RiotWatcher('RGAPI-bcc0bb05-6e09-4d0c-b7dd-49fd76069f19', default_region='jp') summoner = w.get_summoner(name='Sethena') summoner_id = summoner['id'] results = w.get_recent_games(summoner_id) a = "" i = 0 for result in results['games']: for player in result['fellowPlayers']: #print(player['summonerId']) a += str(player['summonerId']) a += "\n" i += 1 if i % 9 == 0: a += "\n" print(a) print(i) #with open('saveresults.json','w') as file: # file.write(json.dumps(player['summonerId']) #for sumid in player['summonerId']: # print(sumid) #with open(str(result['gameId'])+'.json','w') as file: # file.write(json.dumps(result)) #print(summoner) #print(summoner_id) #print(results)