Skip to content

Commit

Permalink
Fixes issue with malformed screenshot error on requested raids.
Browse files Browse the repository at this point in the history
Modified RequestEmbedTime setting to a drop down list of available options
  • Loading branch information
bdawg1989 committed Aug 4, 2024
1 parent 512787a commit 7fdbc98
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 17 deletions.
2 changes: 1 addition & 1 deletion SysBot.Pokemon/Helpers/NotRaidBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public static class NotRaidBot
{
public const string Version = "v8.1.7";
public const string Version = "v8.1.8";
public const string Repo = "https://github.com/bdawg1989/NotRaidBot";
public const string ConfigPath = "config.json";
}
Expand Down
9 changes: 9 additions & 0 deletions SysBot.Pokemon/SV/BotRaid/RaidEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ public enum ScreenshotTimingOptions
_10000 = 10000 // Everything SS
}

public enum RequestEmbedTimingOptions
{
_2500 = 2500,
_3000 = 3000,
_3500 = 3500,
_4000 = 4000,
_4500 = 4500
}

public enum GifQuality
{
[Description("Default quality")]
Expand Down
25 changes: 11 additions & 14 deletions SysBot.Pokemon/SV/BotRaid/RotatingRaidBotSV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1926,25 +1926,20 @@ private async Task<bool> CheckIfTrainerBanned(RaidMyStatus trainer, ulong nid, i
{
if (!await IsConnectedToLobby(token))
return (false, new List<(ulong, RaidMyStatus)>());
await EnqueueEmbed(null, "", false, false, false, false, token).ConfigureAwait(false);

Task? delayTask = null;
List<(ulong, RaidMyStatus)> lobbyTrainers = [];
TimeSpan wait;

if (Settings.ActiveRaids[RotationCount].AddedByRACommand &&
Settings.ActiveRaids[RotationCount].Title != "Mystery Shiny Raid")
{
delayTask = Task.Delay(Settings.EmbedToggles.RequestEmbedTime * 1000, token)
.ContinueWith(async _ => await EnqueueEmbed(null, "", false, false, false, false, token), token);
wait = TimeSpan.FromSeconds(160);
wait = TimeSpan.FromSeconds(160) - TimeSpan.FromMilliseconds((int)Settings.EmbedToggles.RequestEmbedTime);
}
else
{
await EnqueueEmbed(null, "", false, false, false, false, token).ConfigureAwait(false);
wait = TimeSpan.FromSeconds(160);
}

List<(ulong, RaidMyStatus)> lobbyTrainers = [];

var endTime = DateTime.Now + wait;
bool full = false;

Expand Down Expand Up @@ -2016,11 +2011,7 @@ private async Task<bool> CheckIfTrainerBanned(RaidMyStatus trainer, ulong nid, i
}
}


if (delayTask != null)
{
await delayTask;
}
await Task.Delay(5_000, token).ConfigureAwait(false);

if (lobbyTrainers.Count == 0)
{
Expand Down Expand Up @@ -2324,7 +2315,13 @@ private async Task EnqueueEmbed(List<string>? names, string message, bool hatTri
// If it's a "Free For All", set the code as such
code = "Free For All";
}

// Apply delay only if the raid was added by RA command, not a Mystery Shiny Raid, and has a code
if (Settings.ActiveRaids[RotationCount].AddedByRACommand &&
Settings.ActiveRaids[RotationCount].Title != "Mystery Shiny Raid" &&
code != "Free For All")
{
await Task.Delay((int)Settings.EmbedToggles.RequestEmbedTime, token).ConfigureAwait(false);
}
// Description can only be up to 4096 characters.
//var description = Settings.ActiveRaids[RotationCount].Description.Length > 0 ? string.Join("\n", Settings.ActiveRaids[RotationCount].Description) : "";
var description = Settings.EmbedToggles.RaidEmbedDescription.Length > 0 ? string.Join("\n", Settings.EmbedToggles.RaidEmbedDescription) : "";
Expand Down
25 changes: 23 additions & 2 deletions SysBot.Pokemon/SV/BotRaid/RotatingRaidSettingsSV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,30 @@ public class RotatingRaidPresetFiltersCategory
"PP Up"
};

[Category(Hosting), Description("Amount of time (in seconds) to post a requested raid embed.")]
private RequestEmbedTimingOptions _requestEmbedTime = RequestEmbedTimingOptions._3500;

[Category(Hosting)]
[Description("Amount of time (in milliseconds) to post a requested raid embed.")]
[DisplayName("Post User Request Embeds in...")]
public int RequestEmbedTime { get; set; } = 30;
public RequestEmbedTimingOptions RequestEmbedTime
{
get => _requestEmbedTime;
set
{
if (value != RequestEmbedTimingOptions._2500 &&
value != RequestEmbedTimingOptions._3000 &&
value != RequestEmbedTimingOptions._3500 &&
value != RequestEmbedTimingOptions._4000 &&
value != RequestEmbedTimingOptions._4500)
{
_requestEmbedTime = RequestEmbedTimingOptions._3500;
}
else
{
_requestEmbedTime = value;
}
}
}

[Category(FeatureToggle), Description("When enabled, the bot will attempt take screenshots for the Raid Embeds. If you experience crashes often about \"Size/Parameter\" try setting this to false.")]
[DisplayName("Use Screenshots?")]
Expand Down

0 comments on commit 7fdbc98

Please sign in to comment.