"quirk_suffix": character.quirk_suffix,
            "case": character.case,
            "replacements": character.replacements,
            "regexes": character.regexes,
        }
    # Otherwise use search character.
    try:
        search_character = db.query(SearchCharacter).filter(
            SearchCharacter.id == searcher["search_character_id"],
        ).one()
    except NoResultFound:
        return {}
    return {
        "name": search_character.name,
        "acronym": search_character.acronym,
        "color": search_character.color,
        "quirk_prefix": search_character.quirk_prefix,
        "quirk_suffix": search_character.quirk_suffix,
        "case": search_character.case,
        "replacements": search_character.replacements,
        "regexes": search_character.regexes,
    }


if __name__ == "__main__":
    run_matchmaker(
        3, "roulette_searchers", "roulette", get_searcher_info,
        check_compatibility, RouletteChat, get_character_info,
    )

Exemple #2
0
    for search_filter in s2["filters"]:
        print "comparing %s and %s" % (s1_name, search_filter)
        if search_filter in s1_name:
            print "FILTER %s MATCHED" % search_filter
            return False, None
    s2_name = s2["character"]["name"].lower()
    for search_filter in s1["filters"]:
        print "comparing %s and %s" % (s2_name, search_filter)
        if search_filter in s2_name:
            print "FILTER %s MATCHED" % search_filter
            return False, None

    if (
        # Match if either person has wildcard, or if they're otherwise compatible.
        (len(s2["choices"]) == 0 or s1["search_character_id"] in s2["choices"])
        and (len(s1["choices"]) == 0 or s2["search_character_id"] in s1["choices"])
    ):
        redis.set(match_key, 1)
        redis.expire(match_key, 1800)
        return True, options

    return False, None


def get_character_info(db, searcher):
    return searcher["character"]


if __name__ == "__main__":
    run_matchmaker(2, "searchers", "searcher", get_searcher_info, check_compatibility, SearchedChat, get_character_info)