Skip to content

Commit

Permalink
Add unverify command
Browse files Browse the repository at this point in the history
fix #215
  • Loading branch information
Ekwav committed Nov 2, 2024
1 parent cdc9a86 commit 2fc8ce4
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
1 change: 1 addition & 0 deletions Commands/MinecraftSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ static MinecraftSocket()
Commands.Add<RewardHandler.ClaimHypixelRewardCommand>();
Commands.Add<LicensesCommand>("license");
Commands.Add<VerifyCommand>();
Commands.Add<UnVerifyCommand>();
Commands.Add<AttributeFlipCommand>();
Commands.Add<ForgeCommand>();
Commands.Add<CraftsCommand>("craft");
Expand Down
47 changes: 47 additions & 0 deletions Commands/Utility/UnVerifyCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Coflnet.Sky.Commands.Shared;
using Coflnet.Sky.McConnect.Api;

namespace Coflnet.Sky.Commands.MC;

public class UnVerifyCommand : McCommand
{
public override bool IsPublic => true;
public override async Task Execute(MinecraftSocket socket, string arguments)
{
var accountsTask = socket.sessionLifesycle.GetMinecraftAccountUuids();
var passedName = arguments.Trim('"');
var uuid = await GetUserIdFromMcName(socket, passedName);
var accounts = (await accountsTask).ToHashSet();
if (!accounts.Contains(uuid))
{
socket.Dialog(db => db.MsgLine("This account is/was not verified."));
return;
}
var trackingService = socket.GetService<FlipTrackingService>();
var delayInfo = await trackingService.GetSpeedComp(accounts);
if (delayInfo.BadIds.Count > 0)
{
socket.Dialog(db => db.MsgLine("You can't unverify accounts as one of them was blacklisted."));
return;
}
var connectApi = socket.GetService<IConnectApi>();
var user = await connectApi.ConnectMinecraftMcUuidGetAsync(uuid);
if (user.ExternalId == socket.AccountInfo.UserId)
{
socket.Dialog(db => db.MsgLine("You can't unverify your own account."));
return;
}
var premiumService = socket.GetService<PremiumService>();
var isPremium = await premiumService.ExpiresWhen(user.ExternalId);
if (isPremium > DateTime.UtcNow + TimeSpan.FromDays(7))
{
socket.Dialog(db => db.MsgLine("The new account doesn't have more than 7 days of premium left, thats required to proof its not a throwaway account."));
return;
}
await connectApi.ConnectUserUserIdMcUuidDeleteAsync(user.ExternalId, uuid);
socket.Dialog(db => db.MsgLine("Account unverified, have a nice day."));
}
}
1 change: 1 addition & 0 deletions Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public void ConfigureServices(IServiceCollection services)
services.AddSingleton<CircumventTracker>();
services.AddSingleton<IBlockedService, BlockedService>();
services.AddSingleton<Sniper.Client.Api.IAuctionApi, Sniper.Client.Api.AuctionApi>(s => new Sniper.Client.Api.AuctionApi(Configuration["SNIPER_BASE_URL"]));
services.AddSingleton<McConnect.Api.IConnectApi, McConnect.Api.ConnectApi>(s => new McConnect.Api.ConnectApi(Configuration["MCCONNECT_BASE_URL"]));
services.AddSingleton<HypixelItemService>();
services.AddSingleton<IHypixelItemStore, HypixelItemService>(di=>di.GetRequiredService<HypixelItemService>());
services.AddSingleton<System.Net.Http.HttpClient>();
Expand Down
2 changes: 1 addition & 1 deletion appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@
},
"JAEGER_SAMPLER_PARAM": "2",
"MARIADB_VERSION": "10.5.5",
"JAEGER_AGENT_HOST": "jaeger",
"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT": "http://jaeger",
"JAEGER_SERVICE_NAME": "sky-commands-mod"
}

0 comments on commit 2fc8ce4

Please sign in to comment.