Пример #1
0
def is_char_banned(char: Character) -> Tuple[bool, str]:
    try:
        corp_id, alli_id = outgate.character.get_affiliations(
            char.get_eve_id())
        # if he is on whitelist let him pass

        char_banned = char.banned
        corp_banned = is_charid_banned(corp_id)
        alli_banned = is_charid_banned(alli_id)

        if is_charid_whitelisted(char.get_eve_id()):
            return False, ""

        if char_banned:
            return True, "Character"

        if is_charid_whitelisted(corp_id):
            return False, ""

        if corp_banned:
            return True, "Corporation"

        if is_charid_whitelisted(alli_id):
            return False, ""

        if alli_banned:
            return True, "Alliance"

        return False, ""
    except Exception:
        logger.error("Failed to check if %d was banned",
                     char.get_eve_id(),
                     exc_info=1)
        return False, ""
Пример #2
0
def make_json_character(dbcharacter: Character, scramble_names: bool = False,
                        include_names_from: Optionalcharids = None):
    return {
        'id': dbcharacter.get_eve_id() if not scramble_names or (
            include_names_from is not None and dbcharacter.get_eve_id() in include_names_from) else None,
        'name': dbcharacter.get_eve_name() if not scramble_names or (
            include_names_from is not None and dbcharacter.get_eve_id() in include_names_from) else 'Name Hidden',
        'newbro': dbcharacter.is_new
    }
Пример #3
0
def is_char_banned(char: Character) -> Tuple[bool, str]:
    try:
        if is_charid_whitelisted(char.get_eve_id()):
            return False, ""

        if char.banned:
            return True, "Character"

        corp_id, alli_id = outgate.character.get_affiliations(
            char.get_eve_id())

        if banned_by_default:
            if is_charid_whitelisted(corp_id):
                return False, ""
            if is_charid_banned(corp_id):
                return True, "Corporation"
            if is_charid_whitelisted(alli_id):
                return False, ""
            return True, "Everyone Banned by default"
        else:
            corp_banned = is_charid_banned(corp_id)
            alli_banned = is_charid_banned(alli_id)

            if is_charid_whitelisted(corp_id):
                return False, ""

            if corp_banned:
                return True, "Corporation"

            if is_charid_whitelisted(alli_id):
                return False, ""

            if alli_banned:
                return True, "Alliance"

            return False, ""
    except ApiException as e:
        logger.info(
            "Failed to check if %d was banned, because of Api error, code=%d msg=%s",
            char.get_eve_id(), e.code, e.msg)
        return False, ""
    except Exception:
        logger.error("Failed to check if %d was banned",
                     char.get_eve_id(),
                     exc_info=1)
        return False, ""