Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try:
result = userid_from_inthandle(target_userid)
except ValueError:
dbgmsg(1, 'FindUserIDByString: Not a handle or userid.')
else:
dbgmsg(1, 'FindUserIDByString: Yep, it\'s a handle.')
return result
# Search for SteamID
dbgmsg(1, 'FindUserIDByString: is it a steamid?')
# The next line is the original ES behaviour. It doesn't work with SteamID3
#if len(target_string) > 6 and target_string.startswith('STEAM_'):
if not target_string.isdigit():
try:
SteamID.parse(target_string)
except ValueError:
pass
else:
dbgmsg(1, 'FindUserIDByString: really looks like a steamid.')
for player in PlayerIter():
if player.steamid == target_string:
dbgmsg(1, 'FindUserIDByString: was a steamid')
return player.userid
# Search for exact name
dbgmsg(1, 'FindUserIDByString: Look for exact name?')
for player in PlayerIter():
if player.name == target_string:
dbgmsg(1, 'FindUserIDByString: found exact name')
return player.userid
def _get_records_for_steamid(steamid):
records = []
steamid64 = str(SteamID.parse(steamid).to_uint64())
# Firstly, add live records (if player is on the server)
for tracked_player in tracked_players.values():
if tracked_player.steamid == steamid64:
for record in reversed(tracked_player):
records.append(_TrackRecordReport(
steamid64,
record.ip_address,
record.name,
record.seen_at,
live=True
))
break
# Secondly, add records from the database
def _convert_steamid_to_db_format(self, steamid):
return str(SteamID.parse(steamid).to_uint64())
def __missing__(self, steamid):
"""Create, store and return a :class:`PlayerPermissions` object.
:param str/int steamid:
A SteamID2, SteamID3 or SteamID64 value.
:rtype: PlayerPermissions
"""
if not isinstance(steamid, int):
steamid64 = SteamID.parse(steamid).to_uint64()
if steamid64 in self:
return self[steamid64]
# We got a SteamID in a string format, so we can store it by using
# its SteamID64 value, but keep the original name.
instance = self[steamid64] = PlayerPermissions(steamid, steamid64)
else:
instance = self[steamid] = PlayerPermissions(steamid, steamid)
return instance