Skip to content

Commit

Permalink
Parse raw numbers as steamids
Browse files Browse the repository at this point in the history
While most of the time we need to parse strings into steamids, sometimes we
already have a parsed steamid ready to use. To make handling this case
easier, add a try-catch around our regex matching.

Signed-off-by: Sean Anderson <[email protected]>
  • Loading branch information
Forty-Bot committed Aug 27, 2021
1 parent 997e770 commit e588e41
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions steamid.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: MIT
# SPDX-License-Identifier: AGPL-3.0-only
# SPDX-License-Identifier: MIT AND AGPL-3.0-only
# Copyright (C) 2020 Sean Anderson <[email protected]>
# Copyright (c) 2017 Nate the great
# Copyright (c) 2015 Alexander Corn
Expand Down Expand Up @@ -69,8 +68,13 @@ def __init__(self, input):

reg = re.compile("^STEAM_([0-5]):([0-1]):([0-9]+)$")
reg3 = re.compile("^\[([a-zA-Z]):([0-5]):([0-9]+)(:[0-9]+)?\]")
mat = reg.match(input)
mat3 = reg3.match(input)
try:
mat = reg.match(input)
mat3 = reg3.match(input)
except TypeError:
mat = None
mat3 = None

if mat:
self.universe = int(mat[1]) or SteamID.Universe["PUBLIC"]
self.type = SteamID.Type["INDIVIDUAL"]
Expand Down

0 comments on commit e588e41

Please sign in to comment.