mirror of
https://codeberg.org/icewind/tf-log-parser.git
synced 2026-06-03 10:14:10 +02:00
more steamid fixes
This commit is contained in:
parent
2dde316476
commit
1b9addbb4f
1 changed files with 11 additions and 14 deletions
|
|
@ -228,20 +228,17 @@ impl TryFrom<&RawSubject<'_>> for SubjectId {
|
||||||
Ok(match raw {
|
Ok(match raw {
|
||||||
RawSubject::Player(raw) => {
|
RawSubject::Player(raw) => {
|
||||||
if let Some(raw_account_id) = find_between_end(raw, b':', b']') {
|
if let Some(raw_account_id) = find_between_end(raw, b':', b']') {
|
||||||
SubjectId::Player(
|
if let Ok(account_id) = raw_account_id.parse() {
|
||||||
raw_account_id
|
return Ok(SubjectId::Player(account_id));
|
||||||
.parse()
|
|
||||||
.map_err(|_| SubjectError::InvalidSteamId)?,
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
let (_, user_id, steam_id, _) =
|
|
||||||
split_player_subject(raw).map_err(|_| SubjectError::InvalidSteamId)?;
|
|
||||||
if let Ok(steam_id) = SteamID::from_steam2(steam_id) {
|
|
||||||
SubjectId::Player(steam_id.account_id())
|
|
||||||
} else {
|
|
||||||
SubjectId::Bot(user_id.parse().map_err(|_| SubjectError::InvalidUserId)?)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let (_, user_id, steam_id, _) = split_player_subject(raw)
|
||||||
|
.map_err(|_| SubjectError::InvalidSteamId(raw.to_string()))?;
|
||||||
|
if let Ok(steam_id) = SteamID::from_steam2(steam_id) {
|
||||||
|
SubjectId::Player(steam_id.account_id())
|
||||||
|
} else {
|
||||||
|
SubjectId::Bot(user_id.parse().map_err(|_| SubjectError::InvalidUserId)?)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
RawSubject::Team(team) => SubjectId::Team(*team),
|
RawSubject::Team(team) => SubjectId::Team(*team),
|
||||||
RawSubject::System(_) => SubjectId::System,
|
RawSubject::System(_) => SubjectId::System,
|
||||||
|
|
@ -287,8 +284,8 @@ impl SubjectData {
|
||||||
pub enum SubjectError {
|
pub enum SubjectError {
|
||||||
#[error("Invalid user id")]
|
#[error("Invalid user id")]
|
||||||
InvalidUserId,
|
InvalidUserId,
|
||||||
#[error("Invalid steam id")]
|
#[error("Invalid steam id for \"{0}\"")]
|
||||||
InvalidSteamId,
|
InvalidSteamId(String),
|
||||||
#[error("Invalid team name")]
|
#[error("Invalid team name")]
|
||||||
InvalidTeam,
|
InvalidTeam,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue