Ejemplo n.º 1
0
def call(salty_inst, c_msg, **kwargs):
    msg_split = c_msg["message"].split(" ", 1)
    try:
        game = msg_split[1]
        twitch_game = False
    except IndexError:
        game = salty_inst.game
        twitch_game = True
    success, response = salty_inst.sr_com_api.get_games({"name" : game}, **kwargs)

    if not success:
        return False, \
            "Error retrieving info from speedrun.com ({0})".format(response.status_code)

    for i in response["data"]:
        if twitch_game:
            if i["names"]["international"].lower() == game.lower():
                game_record = i
                break
        else:
            if get_diff_ratio.diff_ratio(game.lower(), i["names"]["international"].lower()) > .8:
                game_record = i
                break
            elif i["abbreviation"].lower() == game.lower():
                game_record = i
                break
    else:
        return False, "Could not find a suitable game match for {0}.".format(game)

    return True, game_record["weblink"]
Ejemplo n.º 2
0
def call(salty_inst, c_msg, **kwargs):
    msg_split = c_msg["message"].split(" ", 1)
    try:
        game = msg_split[1]
        twitch_game = False
    except IndexError:
        game = salty_inst.game
        twitch_game = True
    if not game:
        return
    success, response = salty_inst.sr_com_api.get_games({"name" : game}, **kwargs)

    if not success:
        return False, \
            "Error retrieving info from speedrun.com ({0})".format(response.status_code)

    for i in response["data"]:
        if twitch_game:
            if i["names"]["international"].lower() == game.lower():
                game_record = i
                break
        else:
            if get_diff_ratio.diff_ratio(game.lower(), i["names"]["international"].lower()) > .8:
                game_record = i
                break
            elif i["abbreviation"].lower() == game.lower():
                game_record = i
                break
    else:
        return False, "Could not find a suitable game match for {0}.".format(game)

    return True, game_record["weblink"]
def find_active_cat(game_categories, user_string):
    for k in game_categories.keys():
        if k.lower() == user_string.lower():
            return True, k

    best_ratio = {}
    for i in game_categories:
        best_ratio[i] = get_diff_ratio.diff_ratio(user_string.lower(), i.lower())

    try:
        return True, max(best_ratio, key=best_ratio.get)
    except ValueError:
        return False, "Could not find pb with close enough match to {0}".format(user_string)
Ejemplo n.º 4
0
def test_get_diff_ratio():
    assert get_diff_ratio.diff_ratio("120 Shines", "79 Shines") > .6
    assert get_diff_ratio.diff_ratio("79 Ruppees", "79 Shines") < .6
Ejemplo n.º 5
0
def test_get_diff_ratio():
    assert get_diff_ratio.diff_ratio("120 Shines", "79 Shines") > .6
    assert get_diff_ratio.diff_ratio("79 Ruppees", "79 Shines") < .6