Add UserId parsing on player joined or left (#943)

This commit is contained in:
Usman Shafiq
2024-10-21 15:06:50 -04:00
committed by GitHub
parent 458c00fdec
commit ddc1604795
3 changed files with 31 additions and 5 deletions
+28 -4
View File
@@ -455,6 +455,8 @@ namespace VRCX
// 2021.12.12 11:47:22 Log - [Behaviour] OnPlayerJoined:Unnamed // 2021.12.12 11:47:22 Log - [Behaviour] OnPlayerJoined:Unnamed
// 2021.12.12 11:53:14 Log - [Behaviour] OnPlayerLeftRoom // 2021.12.12 11:53:14 Log - [Behaviour] OnPlayerLeftRoom
// Future logs will be formatted like this: [Behaviour] OnPlayerJoined Natsumi-sama (usr_032383a7-748c-4fb2-94e4-bcb928e5de6b)
if (line.Contains("[Behaviour] OnPlayerJoined") && !line.Contains("] OnPlayerJoined:")) if (line.Contains("[Behaviour] OnPlayerJoined") && !line.Contains("] OnPlayerJoined:"))
{ {
var lineOffset = line.LastIndexOf("] OnPlayerJoined"); var lineOffset = line.LastIndexOf("] OnPlayerJoined");
@@ -464,14 +466,15 @@ namespace VRCX
if (lineOffset > line.Length) if (lineOffset > line.Length)
return true; return true;
var userDisplayName = line.Substring(lineOffset); var userInfo = ParseUserInfo(line.Substring(lineOffset));
AppendLog(new[] AppendLog(new[]
{ {
fileInfo.Name, fileInfo.Name,
ConvertLogTimeToISO8601(line), ConvertLogTimeToISO8601(line),
"player-joined", "player-joined",
userDisplayName userInfo.DisplayName,
userInfo.UserId
}); });
return true; return true;
@@ -486,14 +489,15 @@ namespace VRCX
if (lineOffset > line.Length) if (lineOffset > line.Length)
return true; return true;
var userDisplayName = line.Substring(lineOffset); var userInfo = ParseUserInfo(line.Substring(lineOffset));
AppendLog(new[] AppendLog(new[]
{ {
fileInfo.Name, fileInfo.Name,
ConvertLogTimeToISO8601(line), ConvertLogTimeToISO8601(line),
"player-left", "player-left",
userDisplayName userInfo.DisplayName,
userInfo.UserId
}); });
return true; return true;
@@ -1285,6 +1289,26 @@ namespace VRCX
return new string[][] { }; return new string[][] { };
} }
private static (string DisplayName, string UserId) ParseUserInfo(string userInfo)
{
string userDisplayName;
string userId;
int pos = userInfo.LastIndexOf(" (");
if (pos >= 0)
{
userDisplayName = userInfo.Substring(0, pos);
userId = userInfo.Substring(pos + 2, userInfo.LastIndexOf(')') - (pos + 3));
}
else
{
userDisplayName = userInfo;
userId = null;
}
return (userDisplayName, userId);
}
private class LogContext private class LogContext
{ {
public bool AudioDeviceChanged; public bool AudioDeviceChanged;
+1 -1
View File
@@ -11245,7 +11245,7 @@ speechSynthesis.getVoices();
var joinTime = Date.parse(gameLog.dt); var joinTime = Date.parse(gameLog.dt);
var userMap = { var userMap = {
displayName: gameLog.displayName, displayName: gameLog.displayName,
userId, userId : gameLog.userId,
joinTime, joinTime,
lastAvatar: '' lastAvatar: ''
}; };
+2
View File
@@ -19,10 +19,12 @@ class GameLogService {
case 'player-joined': case 'player-joined':
gameLog.displayName = args[0]; gameLog.displayName = args[0];
gameLog.userId = args[1];
break; break;
case 'player-left': case 'player-left':
gameLog.displayName = args[0]; gameLog.displayName = args[0];
gameLog.userId = args[1];
break; break;
case 'notification': case 'notification':