async def createEmbed(name, name_sp, icon_url, acc_str, ranked_str, ctx): # Create account specific op.gg url region = getRegion() op_gg = '' if region == "KR": op_gg += "https://www.op.gg/summoner/userName={}".format(name) else: reg = riot_dict.get(region) op_gg += "https://{}.op.gg/summoner/userName={}".format(reg, name) title_str = "Account Information for {}".format(name_sp) # General embed info embed = discord.Embed( title=title_str, colour=discord.Colour(0xff005c), url=op_gg, description="Shows current account information for a given summoner.") embed.set_thumbnail(url=icon_url) embed.set_author(name="EloBot", icon_url="https://i.imgur.com/rqXHyI8.png") embed.set_footer( text="Click username to view OP.GG stats | Created by Sam and Alek", icon_url="https://i.imgur.com/rqXHyI8.png") # Account info field embed.add_field(name="**Account Stats**", value=acc_str) # Ranked info field embed.add_field(name="**Ranked Stats**", value=ranked_str) await ctx.send(embed=embed)
def outputAccount(arg): region = getRegion() account = watcher.summoner.by_name(region, arg) acc_id = account['id'] acc_enc_id = account['accountId'] acc_level = account['summonerLevel'] account_result_list.append(acc_level) acc_mastery = watcher.champion_mastery.scores_by_summoner(region, acc_id) account_result_list.append(acc_mastery) matchlist = watcher.match.matchlist_by_account(region, acc_enc_id, queue=[400, 420, 430, 440], begin_index=0, end_index=100) # (LANE, ROLE) lane_list = [] role_list = [] merge_list = [] # Creating lane and role lists for i in matchlist['matches']: lane_list.append(i['lane']) role_list.append(i['role']) # Merge lists as tuples into one list for i in range(0, len(lane_list)): temp_tuple = (lane_list[i], role_list[i]) merge_list.append(temp_tuple) # Determine most common tuple mc_tuple = Counter(merge_list).most_common(1) # Create most common pos string pos_str = '' for key, value in pos_dict.items(): if (mc_tuple[0][0] == key): pos_str = value break else: pos_str = "UNDETECTED" account_result_list.append(pos_str) # Create final embed string account_final_str = "**Account Level**: {}\n**Total Mastery**: {}\n**Most Played**: {}".format( account_result_list[0], account_result_list[1], account_result_list[2]) account_result_list.append(account_final_str)
def buildStrings(): region = getRegion() master_list.clear() region_list = [ "na1", "euw1", "kr", "oc1", "eun1", "jp1", "la1", "la2", "br1" ] status_dict = {} # Create region info for each region for i in region_list: region_status = watcher.lol_status.shard_data(i) status_list = [] status_tup = {} # Scrape status info for each of 4 services for j in region_status['services']: status_tup[j['name']] = j['status'] status_dict[i] = status_tup # Jump into each region for i in status_dict: region_str = '' j_str = '' # Jump to each service for j in status_dict[i]: j_str = j_str + j if status_dict[i][j] == 'online': emoji = client.get_emoji(709372443852275743) temp_str = f': {emoji}\n' j_str = j_str + temp_str else: emoji = client.get_emoji(709372456913207416) temp_str = f': {emoji}\n' j_str = j_str + temp_str region_str = j_str master_list.append(region_str)
async def specific(ctx, *args): spec_mast_list = [] region = getRegion() args_str = ''.join(args) arg_list = args_str.split('-') acc_name = arg_list[0] champ_name = arg_list[1].lower() account = watcher.summoner.by_name(region, acc_name) acc_name_sp = account['name'] acc_id = account['id'] champ_id = champ_map.get(champ_name)[0] champ_name_sp = champ_map.get(champ_name)[1] spec_mast_dict = watcher.champion_mastery.by_summoner_by_champion( region, acc_id, champ_id) # Create Mastery Point List mast_str = '' champ_lvl = spec_mast_dict["championLevel"] champ_played = spec_mast_dict['lastPlayTime'] champ_pts = spec_mast_dict['championPoints'] temp_str = "**{}**: {:,}\n".format(mast_dict.get(champ_lvl), champ_pts) mast_str += temp_str # Create time since last played list time_str = '' start_time = round(time.time()) last_play = champ_played / 1000 last_play = start_time - last_play days, rem_h = divmod(last_play, 86400) hours, rem_m = divmod(rem_h, 3600) mins, rem_s = divmod(rem_m, 60) temp_str = '**{}** days **{}** hours **{}** mins ago\n'.format( round(days), round(hours), round(mins)) time_str += temp_str spec_mast_list.append(champ_name_sp) spec_mast_list.append(acc_name_sp) spec_mast_list.append(time_str) spec_mast_list.append(mast_str) await createSpecificEmbed(ctx, spec_mast_list, account)
async def createEmbed(ctx): region = getRegion() lg_graphs = '' name = '' name = master_list[1].replace(' ', '+') reg = riot_dict.get(region) lg_graphs += "https://www.leagueofgraphs.com/summoner/{}/{}".format( reg, name) title_str = "Champion Mastery for {}".format(master_list[1]) embed = discord.Embed( title=title_str, url=lg_graphs, colour=discord.Colour(0xff005c), description="Shows champion mastery information for a given summoner.") embed.set_thumbnail(url=master_list[2]) embed.set_author(name="EloBot", icon_url="https://i.imgur.com/rqXHyI8.png") # Champ List embed.add_field(name="**Top Champs |**", value=master_list[3], inline=True) # Mastery List embed.add_field(name="**Mastery Points |**", value=master_list[4], inline=True) # Last Played embed.add_field(name="**Last Played**", value=master_list[5], inline=True) embed.add_field(name="**Account Totals**", value=master_list[6], inline=True) # Footer embed.set_footer( text= "Click username to view League of Graphs | Created by Sam and Alek", icon_url="https://i.imgur.com/rqXHyI8.png") await ctx.send(embed=embed)
async def createEmbed(ctx): region = getRegion() op_gg = '' if region == "KR": op_gg += "https://www.op.gg/summoner/userName={}".format( master_list[0]) else: reg = riot_dict.get(region) op_gg += "https://{}.op.gg/summoner/userName={}".format( reg, master_list[0]) title_str = "Live Game Information for {}".format(master_list[1]) embed = discord.Embed(title=title_str, url=op_gg, colour=discord.Colour(0xff005c), description=master_list[2]) embed.set_thumbnail(url=master_list[3]) embed.set_author(name="EloBot", icon_url="https://i.imgur.com/rqXHyI8.png") # Your Team embed.add_field(name="**Blue Side**", value=master_list[4], inline=True) # Your Team Ranks embed.add_field(name=master_list[8], value=master_list[6], inline=True) embed.add_field(name="\u200b", value="\u200b") # Enemy Team embed.add_field(name="**Red Side**", value=master_list[5], inline=True) # Enemy Team Ranks embed.add_field(name=master_list[9], value=master_list[7], inline=True) embed.add_field(name="\u200b", value="\u200b") # Footer embed.set_footer( text="Click username to view OP.GG stats | Created by Sam and Alek", icon_url="https://i.imgur.com/rqXHyI8.png") await ctx.send(embed=embed)
def buildStrings(args): region = getRegion() master_list.clear() acc_name = "".join(args) master_list.append(acc_name) account = watcher.summoner.by_name(region, acc_name) acc_name_sp = account['name'] master_list.append(acc_name_sp) acc_id = account['id'] live_game_info = watcher.spectator.by_summoner(region, acc_id) game_queue_id = live_game_info['gameQueueConfigId'] # Calculate elapsed game time start_time = round(time.time()) game_start = live_game_info['gameStartTime'] / 1000 game_start = start_time - game_start days, rem_h = divmod(game_start, 86400) hours, rem_m = divmod(rem_h, 3600) mins, rem_s = divmod(rem_m, 60) secs, rem_ms = divmod(rem_s, 60) time_str = ' | {}:{:2}'.format(round(mins), round(rem_s)) # Search que_list for game type curr_game = "" for i in que_list: if i["queueId"] == game_queue_id: temp_str = "**{}**{}".format(i["map"], i["description"]) curr_game = temp_str break curr_game += time_str master_list.append(curr_game) buildTeamStr(account, acc_id, live_game_info)
def outputRank(arg): region = getRegion() # Pull account info and ranked info try: account = watcher.summoner.by_name(region, arg) ranked_result_list.append(account) ranked_stats = watcher.league.by_summoner(region, account['id']) ranked_result_list.append(ranked_stats) # Create Profile Icon ID version = dragonVersion() embed_str = f'http://ddragon.leagueoflegends.com/cdn/{version}/img/profileicon/' embed_icon = "{}{}.png".format(embed_str, account['profileIconId']) ranked_result_list.append(embed_icon) # Create output format ranked_str = "{0} **Solo/Duo**: {1} {2} - {3}LP\n{4} **Flex**: {5} {6} - {7}LP" unranked = 'UNRANKED' s = '' # Check to see if user's ranked list is populated (has a rank) # User has no ranked info if not ranked_stats: emoji_u = "<:unrank_alt:710104565143568404>" unrank_final_str = ranked_str.format(emoji_u, unranked, s, s, emoji_u, unranked, s, s) temp_str = unrank_final_str.replace("LP", '') final_str = temp_str.replace("-", '') ranked_result_list.append(final_str) # User is ranked in only ONE queue elif len(ranked_stats) == 1: if (ranked_stats[0]['queueType'] == 'RANKED_FLEX_SR'): emoji_u = "<:unrank_alt:710104565143568404>" flex_only_str = ranked_str.format( emoji_u, unranked, s, 0, rank_dict.get(ranked_stats[0]['tier']), ranked_stats[0]['tier'], ranked_stats[0]['rank'], ranked_stats[0]['leaguePoints']) ranked_result_list.append(flex_only_str) else: emoji_u = "<:unrank_alt:710104565143568404>" solo_only_str = ranked_str.format( rank_dict.get(ranked_stats[0]['tier']), ranked_stats[0]['tier'], ranked_stats[0]['rank'], ranked_stats[0]['leaguePoints'], emoji_u, unranked, s, s) ranked_result_list.append(solo_only_str) # User is ranked in both queues else: for i in range(0, 2): if ranked_stats[i]['queueType'] == 'RANKED_SOLO_5x5': emoji_s = rank_dict.get(ranked_stats[i]['tier']) tier_sd = ranked_stats[i]['tier'] rank_sd = ranked_stats[i]['rank'] points_sd = ranked_stats[i]['leaguePoints'] if ranked_stats[i]['queueType'] == 'RANKED_FLEX_SR': emoji_f = rank_dict.get(ranked_stats[i]['tier']) tier_flex = ranked_stats[i]['tier'] ranked_stats[i]['tier'] rank_flex = ranked_stats[i]['rank'] points_flex = ranked_stats[i]['leaguePoints'] all_rank_str = ranked_str.format(emoji_s, tier_sd, rank_sd, points_sd, emoji_f, tier_flex, rank_flex, points_flex) ranked_result_list.append(all_rank_str) except: ranked_result_list.append(0)
def buildTeamStr(account, acc_id, live_game_info): region = getRegion() version = dragonVersion() champ_url = f"http://ddragon.leagueoflegends.com/cdn/{version}/data/en_US/champion.json" url_get_champ = urllib.request.urlopen(champ_url).read().decode() champ_data = json.loads(url_get_champ) # Create blue side lists blue_list = [] for i in live_game_info["participants"][:5]: champ_key = i["championId"] for j in champ_data["data"]: if str(champ_key) == champ_data["data"][j]["key"]: blue_list.append( (i["summonerName"], champ_data["data"][j]["name"], i["summonerId"], champ_key)) # Create red side lists red_list = [] for i in live_game_info["participants"][5:]: champ_key = i["championId"] for j in champ_data["data"]: if str(champ_key) == champ_data["data"][j]["key"]: red_list.append( (i["summonerName"], champ_data["data"][j]["name"], i["summonerId"], champ_key)) # Generate Champion Icon URL comb_list = blue_list + red_list champ_key = 0 for i in comb_list: if acc_id == i[2]: champ_key = i[3] img_str = "" for i in champ_data["data"]: if str(champ_key) == champ_data["data"][i]["key"]: temp_str = champ_data["data"][i]["image"]["full"] img_str = temp_str champ_icon_url = f"http://ddragon.leagueoflegends.com/cdn/{version}/img/champion/{img_str}" master_list.append(champ_icon_url) # Building complete team strings b_team_str = "" r_team_str = "" for i in blue_list: temp_str = "**{}** - {}\n".format(i[0], i[1]) b_team_str += temp_str master_list.append(b_team_str) for i in red_list: temp_str = "**{}** - {}\n".format(i[0], i[1]) r_team_str += temp_str master_list.append(r_team_str) # Build rank info for blue team b_rank_str = "" b_rank_pts = [] for i in blue_list: temp_rank = watcher.league.by_summoner(region, i[2]) if not temp_rank: emoji_u = "<:unrank_alt:710104565143568404>" temp_str = f'{emoji_u} **UNRANKED**\n' b_rank_str += temp_str else: if len(temp_rank) == 1: for j in temp_rank: if j["queueType"] == "RANKED_SOLO_5x5": temp_str = "{} **Solo/Duo**: {} {}\n".format( rank_dict.get(j["tier"]), j["tier"], j["rank"]) b_rank_str += temp_str pt_str = j["tier"] + ' ' + j["rank"] b_rank_pts.append(rank_avg_dict.get(pt_str)) break else: temp_str = "{} **Flex**: {} {}\n".format( rank_dict.get(j["tier"]), j["tier"], j["rank"]) b_rank_str += temp_str pt_str = j["tier"] + ' ' + j["rank"] b_rank_pts.append(rank_avg_dict.get(pt_str)) break if len(temp_rank) == 2: for j in temp_rank: if j["queueType"] == "RANKED_SOLO_5x5": temp_str = "{} **Solo/Duo**: {} {}\n".format( rank_dict.get(j["tier"]), j["tier"], j["rank"]) b_rank_str += temp_str pt_str = j["tier"] + ' ' + j["rank"] b_rank_pts.append(rank_avg_dict.get(pt_str)) break master_list.append(b_rank_str) # Build rank info for red team r_rank_str = "" r_rank_pts = [] for i in red_list: temp_rank = watcher.league.by_summoner(region, i[2]) if not temp_rank: emoji_u = "<:unrank_alt:710104565143568404>" temp_str = f'{emoji_u} **UNRANKED**\n' r_rank_str += temp_str else: if len(temp_rank) == 1: for j in temp_rank: if j["queueType"] == "RANKED_SOLO_5x5": temp_str = "{} **Solo/Duo**: {} {}\n".format( rank_dict.get(j["tier"]), j["tier"], j["rank"]) r_rank_str += temp_str pt_str = j["tier"] + ' ' + j["rank"] print(pt_str) r_rank_pts.append(rank_avg_dict.get(pt_str)) break else: temp_str = "{} **Flex**: {} {}\n".format( rank_dict.get(j["tier"]), j["tier"], j["rank"]) r_rank_str += temp_str pt_str = j["tier"] + ' ' + j["rank"] print(pt_str) r_rank_pts.append(rank_avg_dict.get(pt_str)) break if len(temp_rank) == 2: for j in temp_rank: if j["queueType"] == "RANKED_SOLO_5x5": temp_str = "{} **Solo/Duo**: {} {}\n".format( rank_dict.get(j["tier"]), j["tier"], j["rank"]) r_rank_str += temp_str pt_str = j["tier"] + ' ' + j["rank"] print(pt_str) r_rank_pts.append(rank_avg_dict.get(pt_str)) break master_list.append(r_rank_str) if sum(b_rank_pts) == 0: master_list.append("**Tier Average:** UNRANKED") else: blue_avg = round(sum(b_rank_pts) / len(b_rank_pts)) for k, v in rank_avg_dict.items(): if v == blue_avg: blue_str = f"**Tier Average:** {k}" master_list.append(blue_str) if sum(r_rank_pts) == 0: master_list.append("**Tier Average:** UNRANKED") else: red_avg = round(sum(r_rank_pts) / len(r_rank_pts)) for k, v in rank_avg_dict.items(): if v == red_avg: red_str = f"**Tier Average:** {k}" master_list.append(red_str) print(len(master_list))
def buildStrings(args): region = getRegion() master_list.clear() acc_name = "".join(args) master_list.append(acc_name) # SCRAPE GENERAL ACC INFO account = watcher.summoner.by_name(region, acc_name) acc_name_sp = account['name'] master_list.append(acc_name_sp) version = dragonVersion() # CREATE PROFILE ICON URL embed_str = f'http://ddragon.leagueoflegends.com/cdn/{version}/img/profileicon/' embed_icon = "{}{}.png".format(embed_str, account['profileIconId']) master_list.append(embed_icon) # CREATE CHAMP INFO JSON champ_url = f"http://ddragon.leagueoflegends.com/cdn/{version}/data/en_US/champion.json" url_get_champ = urllib.request.urlopen(champ_url).read().decode() champ_data = json.loads(url_get_champ) acc_id = account['id'] mast_info = watcher.champion_mastery.by_summoner(region, acc_id) # Create names list count = 0 champ_str = '' for i in mast_info[:5]: champ_id = i['championId'] count += 1 for j in champ_data["data"]: if str(champ_id) == champ_data["data"][j]["key"]: champ_name = champ_data["data"][j]["name"] temp_str = "**{}**. {}\n".format(count, champ_name) champ_str += temp_str master_list.append(champ_str) # Create Mastery Point List mast_str = '' for i in mast_info[:5]: champ_lvl = i['championLevel'] mast_pts = i['championPoints'] temp_str = "**{}**: {:,}\n".format(mast_dict.get(champ_lvl), mast_pts) mast_str += temp_str master_list.append(mast_str) # Create time since last played list time_str = '' for i in mast_info[:5]: start_time = round(time.time()) last_play = i['lastPlayTime'] / 1000 last_play = start_time - last_play days, rem_h = divmod(last_play, 86400) hours, rem_m = divmod(rem_h, 3600) mins, rem_s = divmod(rem_m, 60) temp_str = '**{}** days **{}** hours **{}** mins ago\n'.format( round(days), round(hours), round(mins)) time_str += temp_str master_list.append(time_str) # Get total champs played and total mastery levels total_played = len(mast_info) tot_acc_mast = watcher.champion_mastery.scores_by_summoner(region, acc_id) # Get total mastery points tot_mast_pts = 0 for i in mast_info: tot_mast_pts += i['championPoints'] footer_str = "**Champions**: {} | **Mastery Levels**: {} | **Total Points**: {:,}".format( total_played, tot_acc_mast, tot_mast_pts) master_list.append(footer_str)