How to use the steam.enums.EUniverse function in steam

To help you get started, we’ve selected a few steam examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ValvePython / steam / tests / test_steamid.py View on Github external
(3, EType.Individual, EUniverse.Public, 1)
                         )
        self.assertEqual(steamid.steam2_to_tuple("STEAM_1:1:1"),
                         (3, EType.Individual, EUniverse.Public, 1)
                         )
        self.assertEqual(steamid.steam2_to_tuple("STEAM_0:0:4"),
                         (8, EType.Individual, EUniverse.Public, 1)
                         )
        self.assertEqual(steamid.steam2_to_tuple("STEAM_1:0:4"),
                         (8, EType.Individual, EUniverse.Public, 1)
                         )
        self.assertEqual(steamid.steam2_to_tuple("STEAM_4:1:1"),
                         (3, EType.Individual, EUniverse.Dev, 1)
                         )
        self.assertEqual(steamid.steam2_to_tuple("STEAM_4:0:4"),
                         (8, EType.Individual, EUniverse.Dev, 1)
                         )
github ValvePython / steam / tests / test_steamid.py View on Github external
self.assertFalse(SteamID(id=0).is_valid())
        self.assertFalse(SteamID(-50).is_valid())
        self.assertFalse(SteamID(id=-50).is_valid())
        # id > 0
        self.assertTrue(SteamID(5).is_valid())
        # type out of bound
        self.assertFalse(SteamID(1, EType.Max).is_valid())
        # universe out of bound
        self.assertFalse(SteamID(1, universe=EUniverse.Max).is_valid())
        # individual
        self.assertTrue(SteamID(123, EType.Individual, EUniverse.Public, instance=0).is_valid())
        self.assertTrue(SteamID(123, EType.Individual, EUniverse.Public, instance=1).is_valid())
        self.assertTrue(SteamID(123, EType.Individual, EUniverse.Public, instance=2).is_valid())
        self.assertTrue(SteamID(123, EType.Individual, EUniverse.Public, instance=3).is_valid())
        self.assertTrue(SteamID(123, EType.Individual, EUniverse.Public, instance=4).is_valid())
        self.assertFalse(SteamID(123, EType.Individual, EUniverse.Public, instance=5).is_valid())
        self.assertFalse(SteamID(123, EType.Individual, EUniverse.Public, instance=333).is_valid())
        # clan
        self.assertTrue(SteamID(1, EType.Clan, EUniverse.Public, instance=0).is_valid())
        self.assertFalse(SteamID(1, EType.Clan, EUniverse.Public, instance=1).is_valid())
        self.assertFalse(SteamID(1, EType.Clan, EUniverse.Public, instance=1234).is_valid())

        s = SteamID(123, type=EType.Clan, universe=EUniverse.Public, instance=333)
        self.assertFalse(s.is_valid())
github ValvePython / steam / steam / steamid.py View on Github external
etype = EType.Invalid
    universe = EUniverse.Invalid
    instance = None

    if len(args) == 0 and len(kwargs) == 0:
        value = str(accountid)

        # numeric input
        if value.isdigit():
            value = int(value)

            # 32 bit account id
            if 0 < value < 2**32:
                accountid = value
                etype = EType.Individual
                universe = EUniverse.Public
            # 64 bit
            elif value < 2**64:
                accountid = value & 0xFFFFFFFF
                instance = (value >> 32) & 0xFFFFF
                etype = (value >> 52) & 0xF
                universe = (value >> 56) & 0xFF
            # invalid account id
            else:
                accountid = 0

        # textual input e.g. [g:1:4]
        else:
            result = steam2_to_tuple(value) or steam3_to_tuple(value)

            if result:
                (accountid,
github ValvePython / steam / steam / steamid.py View on Github external
match = re.match(r"^STEAM_(?P\d+)"
                     r":(?P[0-1])"
                     r":(?P\d+)$", value
                     )

    if not match:
        return None

    steam32 = (int(match.group('id')) << 1) | int(match.group('reminder'))
    universe = int(match.group('universe'))

    # Games before orange box used to incorrectly display universe as 0, we support that
    if universe == 0:
        universe = 1

    return (steam32, EType(1), EUniverse(universe), 1)
github ValvePython / steam / steam / steamid.py View on Github external
def is_valid(self):
        """
        Check whether this SteamID is valid

        :rtype: :py:class:`bool`
        """
        if self.type == EType.Invalid or self.type >= EType.Max:
            return False

        if self.universe == EUniverse.Invalid or self.universe >= EUniverse.Max:
            return False

        if self.type == EType.Individual:
            if self.id == 0 or self.instance > 4:
                return False

        if self.type == EType.Clan:
            if self.id == 0 or self.instance != 0:
                return False

        if self.type == EType.GameServer:
            if self.id == 0:
                return False

        if self.type == EType.AnonGameServer:
            if self.id == 0 and self.instance == 0:
github ValvePython / steam / steam / steamid.py View on Github external
def universe(self):
        """
        :rtype: :py:class:`steam.enum.EUniverse`
        """
        return EUniverse((int(self) >> 56) & 0xFF)
github ValvePython / steam / steam / steamid.py View on Github external
:return: (accountid, type, universe, instance)
    :rtype: :class:`tuple` or :class:`None`
    """
    match = re.match(r"^\["
                     r"(?P[i%s]):"        # type char
                     r"(?P[0-4]):"     # universe
                     r"(?P\d{1,10})"            # accountid
                     r"(:(?P\d+))?"  # instance
                     r"\]$" % ETypeChars,
                     value
                     )
    if not match:
        return None

    steam32 = int(match.group('id'))
    universe = EUniverse(int(match.group('universe')))
    typechar = match.group('type').replace('i', 'I')
    etype = EType(ETypeChar[typechar])
    instance = match.group('instance')

    if typechar in 'gT':
        instance = 0
    elif instance is not None:
        instance = int(instance)
    elif typechar == 'L':
        instance = EInstanceFlag.Lobby
    elif typechar == 'c':
        instance = EInstanceFlag.Clan
    elif etype in (EType.Individual, EType.GameServer):
        instance = 1
    else:
        instance = 0
github ValvePython / steam / steam / steamid.py View on Github external
m = re.match(r'(https?://s\.team/p/(?P[\-'+_icode_all_valid+']+))'
                 r'|(?P[\-'+_icode_all_valid+']+$)'
                 , code)
    if not m:
        return None

    code = (m.group('code1') or m.group('code2')).replace('-', '')

    def repl_mapper(x):
        return _icode_map_inv[x.group()]

    accountid = int(re.sub("["+_icode_custom+"]", repl_mapper, code), 16)

    if 0 < accountid < 2**32:
        return (accountid, EType(1), EUniverse(universe), 1)