mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Finish up on Axell's work
caching, better presentation, etc
This commit is contained in:
parent
55f5ef48e8
commit
43ab5626ee
@ -3,5 +3,7 @@
|
||||
public static class GlobalCache
|
||||
{
|
||||
public static readonly Dictionary<string, string?> ServerLocation = new();
|
||||
|
||||
public static readonly Dictionary<long, ThumbnailResponse> UserThumbnails = new();
|
||||
}
|
||||
}
|
||||
|
@ -222,7 +222,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UInt64.TryParse(match.Groups[1].Value, out ulong result))
|
||||
if (!Int64.TryParse(match.Groups[1].Value, out long result))
|
||||
{
|
||||
App.Logger.WriteLine(LOG_IDENT, "Failed to parse userid from game join load time entry");
|
||||
App.Logger.WriteLine(LOG_IDENT, match.Groups[1].Value);
|
||||
|
@ -227,29 +227,12 @@ namespace Bloxstrap.Integrations
|
||||
|
||||
icon = universeDetails.Thumbnail.ImageUrl;
|
||||
|
||||
if (App.Settings.Prop.AccountShownOnProfile)
|
||||
if (App.Settings.Prop.ShowAccountOnRichPresence)
|
||||
{
|
||||
var userPfpResponse = await Http.GetJson<ApiArrayResponse<ThumbnailResponse>>($"https://thumbnails.roblox.com/v1/users/avatar-headshot?userIds={activity.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.First().ImageUrl;
|
||||
App.Logger.WriteLine(LOG_IDENT, $"Got user thumbnail as {smallImage}");
|
||||
}
|
||||
var userDetails = await UserDetails.Fetch(activity.UserId);
|
||||
|
||||
var userInfoResponse = await Http.GetJson<UserInfoResponse>($"https://users.roblox.com/v1/users/{activity.UserId}");
|
||||
if (userInfoResponse is null)
|
||||
{
|
||||
App.Logger.WriteLine(LOG_IDENT, "Could not get user info!");
|
||||
}
|
||||
else
|
||||
{
|
||||
smallImageText = userInfoResponse.DisplayName + $" (@{userInfoResponse.Username})"; //example: john doe (@johndoe)
|
||||
App.Logger.WriteLine(LOG_IDENT, $"Got user info as {smallImageText}");
|
||||
}
|
||||
smallImage = userDetails.Thumbnail.ImageUrl;
|
||||
smallImageText = $"Playing on {userDetails.Data.DisplayName} (@{userDetails.Data.Name})"; // i.e. "axell (@Axelan_se)"
|
||||
}
|
||||
|
||||
if (!_activityWatcher.InGame || placeId != activity.PlaceId)
|
||||
|
56
Bloxstrap/Models/APIs/Roblox/GetUserResponse.cs
Normal file
56
Bloxstrap/Models/APIs/Roblox/GetUserResponse.cs
Normal file
@ -0,0 +1,56 @@
|
||||
namespace Bloxstrap.Models.RobloxApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Roblox.Users.Api.GetUserResponse
|
||||
/// </summary>
|
||||
public class GetUserResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The user description.
|
||||
/// </summary>
|
||||
[JsonPropertyName("description")]
|
||||
public string Description { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// When the user signed up.
|
||||
/// </summary>
|
||||
[JsonPropertyName("created")]
|
||||
public DateTime Created { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the user is banned
|
||||
/// </summary>
|
||||
[JsonPropertyName("isBanned")]
|
||||
public bool IsBanned { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Unused, legacy attribute… rely on its existence.
|
||||
/// </summary>
|
||||
[JsonPropertyName("externalAppDisplayName")]
|
||||
public string ExternalAppDisplayName { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// The user's verified badge status.
|
||||
/// </summary>
|
||||
[JsonPropertyName("hasVerifiedBadge")]
|
||||
public bool HasVerifiedBadge { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The user Id.
|
||||
/// </summary>
|
||||
[JsonPropertyName("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The user name.
|
||||
/// </summary>
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// The user DisplayName.
|
||||
/// </summary>
|
||||
[JsonPropertyName("displayName")]
|
||||
public string DisplayName { get; set; } = null!;
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
namespace Bloxstrap.Models.RobloxApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Roblox.Web.Responses.Users.UserInfoResponse
|
||||
/// </summary>
|
||||
public class UserInfoResponse
|
||||
{
|
||||
[JsonPropertyName("description")]
|
||||
public string ProfileDescription { get; set; } = null!;
|
||||
|
||||
[JsonPropertyName("created")]
|
||||
public string JoinDate { get; set; } = null!;
|
||||
|
||||
[JsonPropertyName("isBanned")]
|
||||
public bool IsBanned { get; set; }
|
||||
|
||||
[JsonPropertyName("hasVerifiedBadge")]
|
||||
public bool HasVerifiedBadge { get; set; }
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
public string Username { get; set; } = null!;
|
||||
|
||||
[JsonPropertyName("displayName")]
|
||||
public string DisplayName { get; set; } = null!;
|
||||
}
|
||||
}
|
@ -35,7 +35,7 @@ namespace Bloxstrap.Models.Entities
|
||||
/// </summary>
|
||||
public string AccessCode { get; set; } = string.Empty;
|
||||
|
||||
public ulong UserId { get; set; } = 0;
|
||||
public long UserId { get; set; } = 0;
|
||||
|
||||
public string MachineAddress { get; set; } = string.Empty;
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
using Bloxstrap.Models.APIs.Roblox;
|
||||
|
||||
namespace Bloxstrap.Models.Entities
|
||||
namespace Bloxstrap.Models.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Explicit loading. Load from cache before and after a fetch.
|
||||
/// </summary>
|
||||
public class UniverseDetails
|
||||
{
|
||||
private static List<UniverseDetails> _cache { get; set; } = new();
|
||||
|
42
Bloxstrap/Models/Entities/UserDetails.cs
Normal file
42
Bloxstrap/Models/Entities/UserDetails.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using Bloxstrap.Models.RobloxApi;
|
||||
|
||||
namespace Bloxstrap.Models.Entities
|
||||
{
|
||||
public class UserDetails
|
||||
{
|
||||
private static List<UserDetails> _cache { get; set; } = new();
|
||||
|
||||
public GetUserResponse Data { get; set; } = null!;
|
||||
|
||||
public ThumbnailResponse Thumbnail { get; set; } = null!;
|
||||
|
||||
public static async Task<UserDetails> Fetch(long id)
|
||||
{
|
||||
var cacheQuery = _cache.Where(x => x.Data?.Id == id);
|
||||
|
||||
if (cacheQuery.Any())
|
||||
return cacheQuery.First();
|
||||
|
||||
var userResponse = await Http.GetJson<GetUserResponse>($"https://users.roblox.com/v1/users/{id}");
|
||||
|
||||
if (userResponse is null)
|
||||
throw new InvalidHTTPResponseException("Roblox API for User Details returned invalid data");
|
||||
|
||||
// we can remove '-headshot' from the url if we want a full avatar picture
|
||||
var thumbnailResponse = await Http.GetJson<ApiArrayResponse<ThumbnailResponse>>($"https://thumbnails.roblox.com/v1/users/avatar-headshot?userIds={id}&size=180x180&format=Png&isCircular=false");
|
||||
|
||||
if (thumbnailResponse is null || !thumbnailResponse.Data.Any())
|
||||
throw new InvalidHTTPResponseException("Roblox API for Thumbnails returned invalid data");
|
||||
|
||||
var details = new UserDetails
|
||||
{
|
||||
Data = userResponse,
|
||||
Thumbnail = thumbnailResponse.Data.First()
|
||||
};
|
||||
|
||||
_cache.Add(details);
|
||||
|
||||
return details;
|
||||
}
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ namespace Bloxstrap.Models.Persistable
|
||||
public bool EnableActivityTracking { get; set; } = true;
|
||||
public bool UseDiscordRichPresence { get; set; } = true;
|
||||
public bool HideRPCButtons { get; set; } = true;
|
||||
public bool AccountShownOnProfile { get; set; } = true;
|
||||
public bool ShowAccountOnRichPresence { get; set; } = false;
|
||||
public bool ShowServerDetails { get; set; } = false;
|
||||
public ObservableCollection<CustomIntegration> CustomIntegrations { get; set; } = new();
|
||||
|
||||
|
36
Bloxstrap/Resources/Strings.Designer.cs
generated
36
Bloxstrap/Resources/Strings.Designer.cs
generated
@ -2665,24 +2665,6 @@ namespace Bloxstrap.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Show account on profile.
|
||||
/// </summary>
|
||||
public static string Menu_Integrations_ShowAccountOnProfile_Title {
|
||||
get {
|
||||
return ResourceManager.GetString("Menu.Integrations.ShowAccountOnProfile.Title", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Shows what Roblox account your using on your Discord profile.
|
||||
/// </summary>
|
||||
public static string Menu_Integrations_ShowAccountOnProfile_Description {
|
||||
get {
|
||||
return ResourceManager.GetString("Menu.Integrations.ShowAccountOnProfile.Description", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Allow activity joining.
|
||||
/// </summary>
|
||||
@ -2836,6 +2818,24 @@ namespace Bloxstrap.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Shows the Roblox account you're playing with on your Discord profile..
|
||||
/// </summary>
|
||||
public static string Menu_Integrations_ShowAccountOnProfile_Description {
|
||||
get {
|
||||
return ResourceManager.GetString("Menu.Integrations.ShowAccountOnProfile.Description", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Show Roblox account.
|
||||
/// </summary>
|
||||
public static string Menu_Integrations_ShowAccountOnProfile_Title {
|
||||
get {
|
||||
return ResourceManager.GetString("Menu.Integrations.ShowAccountOnProfile.Title", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The Roblox game you're playing will be shown on your Discord profile. [Not working?]({0}).
|
||||
/// </summary>
|
||||
|
@ -702,10 +702,10 @@ Selecting 'No' will ignore this warning and continue installation.</value>
|
||||
<value>Allow activity joining</value>
|
||||
</data>
|
||||
<data name="Menu.Integrations.ShowAccountOnProfile.Description" xml:space="preserve">
|
||||
<value>Shows which Roblox account you are using on your Discord profile.</value>
|
||||
<value>Shows the Roblox account you're playing with on your Discord profile.</value>
|
||||
</data>
|
||||
<data name="Menu.Integrations.ShowAccountOnProfile.Title" xml:space="preserve">
|
||||
<value>Show account on profile</value>
|
||||
<value>Show Roblox account</value>
|
||||
</data>
|
||||
<data name="Menu.Integrations.Custom.AppLocation" xml:space="preserve">
|
||||
<value>Application Location</value>
|
||||
|
@ -102,6 +102,7 @@
|
||||
<controls:MarkdownTextBlock MarkdownText="[fxeP1](https://github.com/fxeP1)" />
|
||||
<controls:MarkdownTextBlock MarkdownText="[Redusofficial](https://github.com/Redusofficial)" />
|
||||
<controls:MarkdownTextBlock MarkdownText="[srthMD](https://github.com/srthMD)" />
|
||||
<controls:MarkdownTextBlock MarkdownText="[axellse](https://github.com/axellse)" />
|
||||
</StackPanel>
|
||||
</controls:Expander>
|
||||
|
||||
@ -133,7 +134,7 @@
|
||||
<controls:MarkdownTextBlock MarkdownText="[MaximumADHD](https://github.com/MaximumADHD)" />
|
||||
<controls:MarkdownTextBlock MarkdownText="[Multako](https://www.roblox.com/users/2485612194/profile)" />
|
||||
<controls:MarkdownTextBlock MarkdownText="[axstin](https://github.com/axstin)" />
|
||||
<controls:MarkdownTextBlock MarkdownText="[taskmanager](https://github.com/Mantaraix)" />
|
||||
<controls:MarkdownTextBlock MarkdownText="[Mantaraix](https://github.com/Mantaraix)" />
|
||||
<controls:MarkdownTextBlock MarkdownText="[apprehensions](https://github.com/apprehensions)" />
|
||||
</StackPanel>
|
||||
</controls:Expander>
|
||||
|
@ -115,8 +115,8 @@ namespace Bloxstrap.UI.ViewModels.Settings
|
||||
|
||||
public bool DiscordAccountOnProfile
|
||||
{
|
||||
get => App.Settings.Prop.AccountShownOnProfile;
|
||||
set => App.Settings.Prop.AccountShownOnProfile = value;
|
||||
get => App.Settings.Prop.ShowAccountOnRichPresence;
|
||||
set => App.Settings.Prop.ShowAccountOnRichPresence = value;
|
||||
}
|
||||
|
||||
public bool DisableAppPatchEnabled
|
||||
|
Loading…
Reference in New Issue
Block a user