Skip to content

Commit

Permalink
Merge pull request #45 from bobbahbrown/v1.3.13
Browse files Browse the repository at this point in the history
Version 1.3.13
  • Loading branch information
bobbah authored Aug 23, 2021
2 parents d8f050a + 58c1357 commit 52d7b4b
Show file tree
Hide file tree
Showing 21 changed files with 984 additions and 51 deletions.
51 changes: 18 additions & 33 deletions .idea/.idea.CentCom/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion CentCom.API/CentCom.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<Version>1.3.12</Version>
<Version>1.3.13</Version>
<UserSecretsId>1f5f48fa-862f-4472-ba34-2c5a26035e88</UserSecretsId>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion CentCom.Bot/CentCom.Bot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<Version>1.3.12</Version>
<Version>1.3.13</Version>
<TargetFramework>net5.0</TargetFramework>
<UserSecretsId>c8af1449-8cdf-4707-a66d-51e896551bfb</UserSecretsId>
</PropertyGroup>
Expand Down
24 changes: 21 additions & 3 deletions CentCom.Bot/Jobs/FailedParseJob.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand Down Expand Up @@ -54,20 +55,37 @@ public async Task Execute(IJobExecutionContext context)
var channel = channelRequest.Entity;
foreach (var failure in failures)
{
// Attach text content of response where available
FileData fileData = null;
var messageSuffix = "The content of the response was missing or empty.";
if (failure.ResponseContent != null)
{
var dataStream = new MemoryStream();
var writer = new StreamWriter(dataStream);
await writer.WriteAsync(failure.ResponseContent);
dataStream.Seek(0, SeekOrigin.Begin);
fileData = new FileData("response_content.txt", dataStream);
messageSuffix = "The content of the response is attached to this message.";
}

var message = new StringBuilder();
if (_config.Value.FailureMention.HasValue)
message.Append($"<@{_config.Value.FailureMention}> ");
message.Append(
$"Failed to parse bans for {failure.Parser} at <t:{failure.Failed.Value.ToUnixTimeSeconds()}>, exception is as follows... ```");

// Ensure that our length fits
var currLength = message.Length + failure.Exception.Length + 3;
var currLength = message.Length + failure.Exception.Length + messageSuffix.Length + 3;
message.Append(currLength > 2000
? $"{failure.Exception[0..^(currLength - 2000 + 4)]}...```"
: $"{failure.Exception}```");

// Add suffix
message.Append(messageSuffix);

// Try to send, only mark completed if successful
var result = await _channelAPI.CreateMessageAsync(channel.ID, message.ToString());
var result = await _channelAPI.CreateMessageAsync(channel.ID, message.ToString(),
file: fileData ?? new Optional<FileData>());
if (result.IsSuccess)
notified.Add(new NotifiedFailure()
{
Expand Down
2 changes: 1 addition & 1 deletion CentCom.Common/CentCom.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<Version>1.3.12</Version>
<Version>1.3.13</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 52d7b4b

Please sign in to comment.