Skip to content

Commit

Permalink
Merge pull request #274 from Unity-Developer-Community/feat/more-misc…
Browse files Browse the repository at this point in the history
…-fixes

Feature: More misc fixes
  • Loading branch information
Pierre-Demessence authored Jan 24, 2024
2 parents a78a8be + 9aef1ef commit 3017d12
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
28 changes: 24 additions & 4 deletions DiscordBot/Services/ModerationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ private async Task MessageUpdated(Cacheable<IMessage, ulong> before, SocketMessa
else
content = beforeMessage.Content;

// Check the message aren't the same
if (content == after.Content)
return;
if (content.Length == 0 && beforeMessage.Attachments.Count == 0)
return;

bool isTruncated = false;
if (content.Length > MaxMessageLength)
{
Expand All @@ -80,12 +86,26 @@ private async Task MessageUpdated(Cacheable<IMessage, ulong> before, SocketMessa
.FooterInChannel(after.Channel)
.AddAuthorWithAction(user, "Updated a message", true);
if (isCached)
{
builder.AddField($"Previous message content {(isTruncated ? "(truncated)" : "")}", content);
// if any attachments that after does not, add a link to them and a count
if (beforeMessage.Attachments.Count > 0)
{
var attachments = beforeMessage.Attachments.Where(x => after.Attachments.All(y => y.Url != x.Url));
var removedAttachments = attachments.ToList();
if (removedAttachments.Any())
{
var attachmentString = string.Join("\n", removedAttachments.Select(x => $"[{x.Filename}]({x.Url})"));
builder.AddField($"Previous attachments ({removedAttachments.Count()})", attachmentString);
}
}
}

builder.WithDescription($"Message: [{after.Id}]({after.GetJumpUrl()})");
var embed = builder.Build();
var embed = builder.Build();

// TimeStamp for the Footer
await _loggingService.Log(LogBehaviour.Channel,string.Empty, ExtendedLogSeverity.Info, embed);

await _loggingService.Log(LogBehaviour.Channel, string.Empty, ExtendedLogSeverity.Info, embed);
}
}
15 changes: 9 additions & 6 deletions DiscordBot/Services/UnityHelp/UnityHelpService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public class UnityHelpService
.WithFooter($"Remember to Right click a message and select 'Apps->Correct Answer'")
.WithColor(Color.Green)
.Build();
private static readonly Emoji CloseEmoji = new Emoji(":lock:");
private const int HasResponseIdleTimeSelfUser = 60 * 8;
private static readonly Emoji CloseEmoji = new Emoji("\ud83d\udd12");
private const int HasResponseIdleTimeSelfUser = 60 * 14;
private static readonly string HasResponseIdleTimeSelfUserMessage = $"Hello {{0}}! This forum has been inactive for {HasResponseIdleTimeSelfUser / 60} hours. If the question has been appropriately answered, click the {CloseEmoji} emoji to close this thread.";
private const int HasResponseIdleTimeOtherUser = 60 * 12;
private const int HasResponseIdleTimeOtherUser = 60 * 20;
private static readonly string HasResponseMessageRequestClose = $"Hello {{0}}! This forum has been inactive for {HasResponseIdleTimeOtherUser / 60} hours without your input. If the question has been appropriately answered, click the {CloseEmoji} emoji to close this thread.";
private const string HasResponseExtraMessage = $"If you still need help, perhaps include additional details!";

private const int NoResponseNotResolvedIdleTime = 60 * 24 * 2;
private const int NoResponseNotResolvedIdleTime = 60 * 24 * 3;
private readonly Embed _stealthDeleteEmbed = new EmbedBuilder()
.WithTitle("Warning: No Activity")
.WithDescription($"This question has been idle for {NoResponseNotResolvedIdleTime / 60} hours and has no response.\n" +
Expand All @@ -49,7 +49,7 @@ public class UnityHelpService

private readonly Embed _noAppliedTagsEmbed = new EmbedBuilder()
.WithTitle("Warning: No Tags Applied")
.WithDescription($"Apply tags to your thread to help others find it!\n" +
.WithDescription($"Consider adding tags to your question to help others find it!\n" +
$"Right click on the thread title and select 'Edit Tags'!\n")
.WithFooter($"Relevant tags help experienced users find you!")
.WithColor(Color.LightOrange)
Expand Down Expand Up @@ -214,9 +214,12 @@ private Task GatewayOnThreadCreated(SocketThreadChannel thread)
return Task.CompletedTask;
if (thread.Owner.HasRoleGroup(ModeratorRole))
return Task.CompletedTask;
// Gateway is called twice for forums, not sure why
// Gateway is called twice for forums/threads (When Bot joins channel)
if (_activeThreads.ContainsKey(thread.Id))
return Task.CompletedTask;
// Ignore new thread if age is over, 5 mins?
if (thread.CreatedAt < DateTime.Now.AddMinutes(-5))
return Task.CompletedTask;

LoggingService.DebugLog($"[{ServiceName}] New Thread Created: {thread.Id} - {thread.Name}", LogSeverity.Debug);
Task.Run(() => OnThreadCreated(thread));
Expand Down

0 comments on commit 3017d12

Please sign in to comment.