Implement automatic sticker saving (#985)

* Implement automatic sticker saving

* Prevent multiple requests for same sticker or print
This commit is contained in:
Nekromateion
2024-11-26 05:36:02 +01:00
committed by GitHub
parent 654872fc30
commit c4a19966a4
7 changed files with 99 additions and 1 deletions

View File

@@ -592,5 +592,16 @@ namespace VRCX
return await ImageCache.SaveImageToFile(url, filePath);
}
public async Task<bool> SaveStickerToFile(string url, string path, string fileName)
{
var folder = Path.Combine(GetVRChatPhotosLocation(), "Stickers", MakeValidFileName(path));
Directory.CreateDirectory(folder);
var filePath = Path.Combine(folder, MakeValidFileName(fileName));
if (File.Exists(filePath))
return false;
return await ImageCache.SaveImageToFile(url, filePath);
}
}
}

View File

@@ -259,7 +259,8 @@ namespace VRCX
ParseFailedToJoin(fileInfo, logContext, line, offset) ||
ParseInstanceResetWarning(fileInfo, logContext, line, offset) ||
ParseVoteKickInitiation(fileInfo, logContext, line, offset) ||
ParseVoteKickSuccess(fileInfo, logContext, line, offset))
ParseVoteKickSuccess(fileInfo, logContext, line, offset) ||
ParseStickerSpawn(fileInfo, logContext, line, offset))
{
}
}
@@ -1270,6 +1271,32 @@ namespace VRCX
return true;
}
private bool ParseStickerSpawn(FileInfo fileInfo, LogContext logContext, string line, int offset)
{
var index = line.IndexOf("[StickersManager] User ");
if (index == -1 || !line.Contains("file_") || !line.Contains("spawned sticker"))
return false;
string info = line.Substring(index + 23);
var (userId, displayName) = ParseUserInfo(info);
var fileIdIndex = info.IndexOf("file_");
string fileId = info.Substring(fileIdIndex);
AppendLog(new[]
{
fileInfo.Name,
ConvertLogTimeToISO8601(line),
"sticker-spawn",
userId,
displayName,
fileId,
});
return true;
}
public string[][] Get()
{
Update();