Documentation

This commit is contained in:
Luke Robles 2018-07-01 11:54:41 -07:00
parent e50fad0342
commit 7af4a9c037
2 changed files with 45 additions and 11 deletions

View File

@ -104,7 +104,12 @@ def get_help_message(method):
'\nUsage: !weather Berkeley'
],
'pout': [
'Returns the URL for an anime girl pouting you filthy weeb'
'Returns the URL for an anime girl pouting you filthy weeb\n',
'Usage: !pout'
],
'quake': [
'Returns player stats for a quake champions account\n'
'Usage: !quake <player name>'
],
'smug': [
'Returns the URL for smug anime girl'
@ -127,7 +132,7 @@ def get_help_message(method):
def get_help_embed(client):
categories = {
'fun': ['clap', 'birb', 'dog', 'excuse', 'greentext', 'lewd', 'message', 'homepage', 'pout', 'smug'],
'fun': ['clap', 'birb', 'dog', 'excuse', 'greentext', 'lewd', 'message', 'homepage', 'pout', 'smug', 'quake'],
'util': ['8ball', 'decide', 'wallpaper', 'weather', 'stock', 'tts', 'issue'],
'users': ['help', 'invite', 'purge', 'roles', 'source', 'minecraft'],
'admin': ['emoji', 'cleanup']

View File

@ -4,6 +4,11 @@ import discord
import help_methods
def parse_message(message):
"""
parse_message(message)
Handles the message and looks for a plaer name.
"""
if len(message.content.split()) == 1:
return help_methods.get_help_message('quake')
@ -16,6 +21,12 @@ def parse_message(message):
def get_stats(player):
"""
get_stats(player)
Makes the request to stats.quake.com and returns an embed object with a
bunch of data about the player
"""
base_url = 'https://stats.quake.com/api/v2/'
player_endpoint = "Player/Stats?name={}".format(player)
@ -38,7 +49,6 @@ def create_embed(stats):
object
"""
# Parse the json and pull out the numbers we want
champ_name, play_time = get_favorite_champion(stats)
fav_weapon, fav_weapon_kills = get_favorite_weapon(stats)
@ -74,6 +84,13 @@ def create_embed(stats):
def get_favorite_champion(blob):
"""
get_favorite_champion(blob)
Takes one argument, a large json data set from the stats API and parses it
to figure out who the players favorite champion is. Stores all the data
in a temp dictionary, play_times, then grabs the max value from it
"""
play_times = {}
all_champions = blob['playerProfileStats']['champions']
@ -93,6 +110,13 @@ def get_favorite_champion(blob):
def get_favorite_weapon(blob):
"""
get_favorite_weapon(blob)
Takes one argument, a large json data set from the stats API and parses it
to figure out what the players favorite weapon is. Stores all the data
in a temp dictionary, weapon_stats, then grabs the max value from it
"""
weapon_stats = {}
all_champions = blob['playerProfileStats']['champions']
@ -109,8 +133,13 @@ def get_favorite_weapon(blob):
return(weapon_name, total_kills)
def get_kd(blob):
"""
get_kd(blob)
Takes one argument, a large json data set from the stats API and parses it
to figure the players total K/D ratio
"""
total_kills = 0
total_deaths = 0
all_champions = blob['playerProfileStats']['champions']