<commit_before>#! /usr/bin/env python2.7

from modules.commands.helpers import get_category_string
from modules.commands.helpers import get_category_title
from modules.commands.helpers import time_formatter

def call(salty_inst, c_msg, **kwargs):
    msg_split = c_msg["message"].split(" ", 3)

    game_type = "name"
    infer_category = False
    try:
        username = msg_split[1]
    except IndexError:
        username = salty_inst.channel
    try:
        game = msg_split[2]
        game_type = "shortname"
    except IndexError:
        game = salty_inst.game
        infer_category = True
    try:
        category = msg_split[3]
    except IndexError:
        category = salty_inst.title
        infer_category = True

    success, response = salty_inst.splits_io_api.get_user_pbs(username, **kwargs)
    if not success:
        return False, \
            "Error retrieving info from splits.io ({0}).".format(response.status_code)
    game_pbs = [x for x in response["pbs"] if x["game"] and (x["game"][game_type] or "").lower() == game.lower()]
    game_categories = {x["category"]["name"] : x["category"]["name"] for x in game_pbs if x["category"]}

    if infer_category:
        category_finder = get_category_title.find_active_cat
    else:
        category_finder = get_category_string.find_active_cat

    cat_success, cat_response = category_finder(game_categories, category)
    if not cat_success:
        return False, cat_response

    pb_splits = [x for x in game_pbs if x["category"]["name"].lower() == cat_response.lower()][0]
    output_game = pb_splits["game"]["name"]
    msg = "{0}'s best splits for {1} {2} is {3} https://splits.io{4}".format(
        username.capitalize(),
        output_game,
        cat_response,
        time_formatter.format_time(pb_splits["time"]),
        pb_splits["path"]
    )
    return True, msg<commit_msg>change how games are found<commit_after>#! /usr/bin/env python2.7

from modules.commands.helpers import get_category_string
from modules.commands.helpers import get_category_title
from modules.commands.helpers import time_formatter

def call(salty_inst, c_msg, **kwargs):
    msg_split = c_msg["message"].split(" ", 3)


    infer_category = False
    try:
        username = msg_split[1]
    except IndexError:
        username = salty_inst.channel
    try:
        game = msg_split[2]
    except IndexError:
        game = salty_inst.game
    try:
        category = msg_split[3]
    except IndexError:
        category = salty_inst.title
        infer_category = True

    success, response = salty_inst.splits_io_api.get_user_pbs(username, **kwargs)
    if not success:
        return False, \
            "Error retrieving info from splits.io ({0}).".format(response.status_code)
    game_pbs = [x for x in response["pbs"] if x["game"] and (x["game"]["name"].lower() == game.lower() or x["game"]["shortname"].lower() == game.lower())]
    game_categories = {x["category"]["name"] : x["category"]["name"] for x in game_pbs if x["category"]}

    if infer_category:
        category_finder = get_category_title.find_active_cat
    else:
        category_finder = get_category_string.find_active_cat

    cat_success, cat_response = category_finder(game_categories, category)
    if not cat_success:
        return False, cat_response

    pb_splits = [x for x in game_pbs if x["category"]["name"].lower() == cat_response.lower()][0]
    output_game = pb_splits["game"]["name"]
    msg = "{0}'s best splits for {1} {2} is {3} https://splits.io{4}".format(
        username.capitalize(),
        output_game,
        cat_response,
        time_formatter.format_time(pb_splits["time"]),
        pb_splits["path"]
    )
    return True, msg
{'fraction_non_alphanumeric': 0.12270765911542611, 'fraction_numerical': 0.007011866235167206, 'mean_word_length': 3.2485681557846506, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1652363', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1181, 'n_words': 270}