Skip to content

Commit

Permalink
Fix missing class and some code readability issues
Browse files Browse the repository at this point in the history
This fixes being able to build the project and fixes the client side addons detection mechanism.
It also fixes some line spacing and indentation issues.
  • Loading branch information
Refragg committed Nov 12, 2023
1 parent be1f015 commit 8c95b78
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
9 changes: 9 additions & 0 deletions ClientSideAddons.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace RoboBot;

public static class ClientSideAddons
{
public static string[] Addons { get; } =
{
"speedometer"
};
}
23 changes: 7 additions & 16 deletions Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,24 +145,20 @@ public async Task ReplayConverterWithAddons(CommandContext ctx, params string[]
addonLister.fileName = fileName;
byte[] file = File.ReadAllBytes(fileName);
string[] addonss = addonLister.GetFilesFromReplay(file);
ClientSideAddons clientSideAddons = new ClientSideAddons();

foreach (var modName in addonss)
{
bool clientSide = clientSideAddons.addons.Any(s=>modName.Contains(s));
if (!clientSide)

Console.WriteLine("Added");
if (!ClientSideAddons.Addons.Any(s=>modName.ToLower().Contains(s)))
addonsList.Add(modName);
}
}


}

FileInfo replay = new FileInfo(ctx.Message.Attachments.First().FileName);
string replayID = Path.GetRandomFileName() + ".lmp";
byte[] fileBytes = File.ReadAllBytes(replay.FullName).ToArray();
string addonPath;
string version;

if (fileBytes[12] == 201)
{
addonPath = $"/root/.srb2/.srb21/addons/";
Expand All @@ -178,6 +174,7 @@ public async Task ReplayConverterWithAddons(CommandContext ctx, params string[]
await ctx.RespondAsync("File not playable on 2.2 or 2.1. Is it a valid replay?");
return;
}

File.Move(replay.Name,$"/root/.srb2/replaystogif/{replayID}");

string confirmationMessage = $"Processing {version} replay sent by {ctx.Member.Username}";
Expand All @@ -201,20 +198,17 @@ public async Task ReplayConverterWithAddons(CommandContext ctx, params string[]
addonsList.Remove(addonName);
}
}


}
confirmationMessage += " with addon(s) " + string.Join(" ", addonsList);

confirmationMessage += " with addon(s) " + string.Join(" ", addonsList);
}

if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))

{
await ctx.RespondAsync(confirmationMessage);
Program.convertQueue.Add(ctx);
}
JobInfo addonsJobInfo = addonsList.Any() ? JobInfo.CreateFromStrings((byte)addonsList.Count, addonsList) : JobInfo.NoAddons;


Program.replayEvents.AddToQueue(addonsJobInfo, $"/root/.srb2/replaystogif/{replayID}", "/var/www/html/gifs/torename.gif");

Expand All @@ -239,9 +233,6 @@ public async Task ReplayConverterWithAddons(CommandContext ctx, params string[]
}
}




[Command("help")]
public async Task Help(CommandContext ctx)
{
Expand Down

0 comments on commit 8c95b78

Please sign in to comment.