mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 06:43:51 +02:00
Implement automatic sticker saving (#985)
* Implement automatic sticker saving * Prevent multiple requests for same sticker or print
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user