From 8656d9dad4293dae13f8c9e2ded5fd9ca57474c2 Mon Sep 17 00:00:00 2001 From: axell Date: Fri, 5 Jul 2024 23:07:18 +0200 Subject: [PATCH 01/35] add functionality for grabbing userid --- Bloxstrap/Integrations/ActivityWatcher.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Bloxstrap/Integrations/ActivityWatcher.cs b/Bloxstrap/Integrations/ActivityWatcher.cs index 0355a782..35c6f003 100644 --- a/Bloxstrap/Integrations/ActivityWatcher.cs +++ b/Bloxstrap/Integrations/ActivityWatcher.cs @@ -13,7 +13,9 @@ public class ActivityWatcher : IDisposable private const string GameTeleportingEntry = "[FLog::SingleSurfaceApp] initiateTeleport"; private const string GameMessageEntry = "[FLog::Output] [BloxstrapRPC]"; private const string GameLeavingEntry = "[FLog::SingleSurfaceApp] leaveUGCGameInternal"; - + private const string GameJoinLoadTimeEntry = "[FLog::GameJoinLoadTime] Report game_join_loadtime:" + + private const string GameJoinLoadTimeEntryPattern = ", userid:([0-9]+)" private const string GameJoiningEntryPattern = @"! Joining game '([0-9a-f\-]{36})' place ([0-9]+) at ([0-9\.]+)"; private const string GameJoiningUDMUXPattern = @"UDMUX Address = ([0-9\.]+), Port = [0-9]+ \| RCC Server Address = ([0-9\.]+), Port = [0-9]+"; private const string GameJoinedEntryPattern = @"serverId: ([0-9\.]+)\|[0-9]+"; @@ -39,6 +41,7 @@ public class ActivityWatcher : IDisposable public bool ActivityInGame = false; public long ActivityPlaceId = 0; public string ActivityJobId = ""; + public string ActivityUserId = ""; public string ActivityMachineAddress = ""; public bool ActivityMachineUDMUX = false; public bool ActivityIsTeleport = false; @@ -143,6 +146,19 @@ private void ExamineLogEntry(string entry) process.CloseMainWindow(); } + if (ActivityUserId == "" && entry.Contains(GameJoinLoadTimeEntry)) + { + Match match = Regex.Match(entry, GameJoinLoadTimeEntryPattern); + + if (match.Groups.Count != 2) + { + App.Logger.WriteLine(LOG_IDENT, $"Failed to assert format for game join load time entry"); + App.Logger.WriteLine(LOG_IDENT, entry); + return; + } + + ActivityUserId = match.Groups[1].Value + } if (!ActivityInGame && ActivityPlaceId == 0) { if (entry.Contains(GameJoiningPrivateServerEntry)) @@ -229,7 +245,8 @@ private void ExamineLogEntry(string entry) ActivityMachineUDMUX = false; ActivityIsTeleport = false; ActivityServerType = ServerType.Public; - + ActivityUserId = "" + OnGameLeave?.Invoke(this, new EventArgs()); } else if (entry.Contains(GameTeleportingEntry)) From 4acab1737e708bb449c5223308db2393c31b4f65 Mon Sep 17 00:00:00 2001 From: axell Date: Fri, 5 Jul 2024 23:38:12 +0200 Subject: [PATCH 02/35] Create UserInfoResponse.cs --- .../Models/RobloxApi/UserInfoResponse.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Bloxstrap/Models/RobloxApi/UserInfoResponse.cs diff --git a/Bloxstrap/Models/RobloxApi/UserInfoResponse.cs b/Bloxstrap/Models/RobloxApi/UserInfoResponse.cs new file mode 100644 index 00000000..a8502494 --- /dev/null +++ b/Bloxstrap/Models/RobloxApi/UserInfoResponse.cs @@ -0,0 +1,26 @@ +namespace Bloxstrap.Models.RobloxApi +{ + /// + /// Roblox.Web.Responses.Users.UserInfoResponse + /// + public class UserInfoResponse + { + [JsonPropertyName("description")] + public string ProfileDescription { get; set; } + + [JsonPropertyName("created")] + public string JoinDate { get; set; }; + + [JsonPropertyName("isBanned")] + public bool IsBanned { get; set; }; + + [JsonPropertyName("hasVerifiedBadge")] + public bool HasVerifiedBadge { get; set; }; + + [JsonPropertyName("name")] + public string Username { get; set; }; + + [JsonPropertyName("displayName")] + public string DisplayName { get; set; }; + } +} From 62ccc1d229ee154854f2c568eaff9e435ddd59b8 Mon Sep 17 00:00:00 2001 From: axell Date: Fri, 5 Jul 2024 23:44:36 +0200 Subject: [PATCH 03/35] add user pfp small image thingy --- Bloxstrap/Integrations/DiscordRichPresence.cs | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/Bloxstrap/Integrations/DiscordRichPresence.cs b/Bloxstrap/Integrations/DiscordRichPresence.cs index ab920d12..4477c111 100644 --- a/Bloxstrap/Integrations/DiscordRichPresence.cs +++ b/Bloxstrap/Integrations/DiscordRichPresence.cs @@ -190,8 +190,12 @@ public async Task SetCurrentGame() } string icon = "roblox"; + string smallimagetext = "Roblox"; + string smallimage = "roblox"; + long placeId = _activityWatcher.ActivityPlaceId; - + string userId = _activityWatcher.ActivityUserId; + App.Logger.WriteLine(LOG_IDENT, $"Setting presence for Place ID {placeId}"); var universeIdResponse = await Http.GetJson($"https://apis.roblox.com/universes/v1/places/{placeId}/universe"); @@ -231,6 +235,34 @@ public async Task SetCurrentGame() App.Logger.WriteLine(LOG_IDENT, $"Got Universe thumbnail as {icon}"); } + //right now this is configured in a way so that it will only show your avatar and username if you have chosen to allow people to join you from their profile. + if (!App.Settings.Prop.HideRPCButtons) + { + var userPfpResponse = await Http.GetJson>($"https://thumbnails.roblox.com/v1/users/avatar-headshot?userIds={userId}&size=180x180&format=Png&isCircular=false"); //we can remove '-headshot' from the url if we want a full avatar picture + if (userPfpResponse is null || !userPfpResponse.Data.Any()) + { + App.Logger.WriteLine(LOG_IDENT, "Could not get user thumbnail info!"); + } + else + { + smallimage = userPfpResponse.Data.ToArray()[0].ImageUrl; + App.Logger.WriteLine(LOG_IDENT, $"Got user thumbnail as {smallimage}"); + } + + var userInfoResponse = await Http.GetJson>($"https://users.roblox.com/v1/users/{userId}"); + if (userInfoResponse is null || !userInfoResponse.Data.Any()) + { + App.Logger.WriteLine(LOG_IDENT, "Could not get user info!"); + } + else + { + smallimagetext = userInfoResponse.Data.ToArray()[0].DisplayName + " (@{userInfoResponse.Data.ToArray()[0].Username})"; //example: john doe (@johndoe) + App.Logger.WriteLine(LOG_IDENT, $"Got user info as {smallimagetext}"); + } + + } + + List