def stats(self, mess, args): """The ranked win rate and KDA""" summ_id = self.get_player_id(mess) teams = RiotAPI.get_teams(summ_id) if teams is None: return "You must be in a game to check stats" friendly, enemies = teams self.send_simple_reply(mess, "Looking up stats...") lines = ["Your team:"] for summonerID, champID in friendly.iteritems(): champ_stats = RiotAPI.get_stats(summonerID, champID) to_send = ">>" + RiotAPI.get_champion_name(champID) + ": " to_send += self.format_stats(champ_stats) lines += [to_send] lines += ["Enemy team:"] for summonerID, champID in enemies.iteritems(): champ_stats = RiotAPI.get_stats(summonerID, champID) to_send = ">>" + RiotAPI.get_champion_name(champID) + ": " to_send += self.format_stats(champ_stats) lines += [to_send] pprint(lines) # Send response to user for line in lines[:-1]: self.send_simple_reply(mess, line) time.sleep(0.25) self.send_simple_reply(mess, lines[-1])
def tilt(self, mess, args): """The win/loss history each player's recent games""" summ_id = self.get_player_id(mess) num_hours = 12 if len(args.split()) > 0: try: num_hours = int(args.split()[0]) except ValueError: pass teams = RiotAPI.get_teams(summ_id) if teams is None: return "You must be in a game to check match history" friendly, enemies = teams self.send_simple_reply(mess, "Looking up match history...") lines = ["Match history for the last %d hours:" % num_hours] lines += ["Your team:"] for summonerID, champID in friendly.iteritems(): to_send = ">>" + RiotAPI.get_champion_name(champID) + ": " to_send += RiotAPI.get_recent_winrate(summonerID, num_hours * TIME_HOUR) lines += [to_send] lines += ["Enemy team:"] for summonerID, champID in enemies.iteritems(): to_send = ">>" + RiotAPI.get_champion_name(champID) + ": " to_send += RiotAPI.get_recent_winrate(summonerID, num_hours * TIME_HOUR) lines += [to_send] pprint(lines) # Send response to user for line in lines[:-1]: self.send_simple_reply(mess, line) time.sleep(0.25) self.send_simple_reply(mess, lines[-1])