diff --git a/CompatBot/Commands/Vision.cs b/CompatBot/Commands/Vision.cs index 2ee57359..64dd4b6c 100644 --- a/CompatBot/Commands/Vision.cs +++ b/CompatBot/Commands/Vision.cs @@ -308,7 +308,9 @@ namespace CompatBot.Commands .WithContent(description) .WithFile(Path.GetFileNameWithoutExtension(imageUrl) + "_tagged.jpg", resultStream); var respondMsg = await ctx.RespondAsync(messageBuilder).ConfigureAwait(false); - await ReactToTagsAsync(respondMsg, result.Objects.Select(o => o.ObjectProperty).Concat(result.Description.Tags)).ConfigureAwait(false); + var tags = result.Objects.Select(o => o.ObjectProperty).Concat(result.Description.Tags).Distinct().ToList(); + Config.Log.Info($"Tags for image {imageUrl}: {string.Join(", ", tags)}"); + await ReactToTagsAsync(respondMsg, tags).ConfigureAwait(false); } else { diff --git a/CompatBot/EventHandlers/MediaScreenshotMonitor.cs b/CompatBot/EventHandlers/MediaScreenshotMonitor.cs index 517ecde8..76768329 100644 --- a/CompatBot/EventHandlers/MediaScreenshotMonitor.cs +++ b/CompatBot/EventHandlers/MediaScreenshotMonitor.cs @@ -60,7 +60,7 @@ namespace CompatBot.EventHandlers try { var headers = await t.ConfigureAwait(false); - workQueue.Enqueue((evt, new Guid(new Uri(headers.OperationLocation).Segments.Last()))); + workQueue.Enqueue((evt, new(new Uri(headers.OperationLocation).Segments.Last()))); workSemaphore.Release(); } catch (Exception ex) @@ -75,7 +75,7 @@ namespace CompatBot.EventHandlers if (string.IsNullOrEmpty(Config.AzureComputerVisionKey)) return; - Guid? reEnqueId = null; + Guid? reEnqueueId = null; do { await workSemaphore.WaitAsync(Config.Cts.Token).ConfigureAwait(false); @@ -86,10 +86,10 @@ namespace CompatBot.EventHandlers if (!workQueue.TryDequeue(out var item)) continue; - if (item.readOperationId == reEnqueId) + if (item.readOperationId == reEnqueueId) { await Task.Delay(100).ConfigureAwait(false); - reEnqueId = null; + reEnqueueId = null; if (Config.Cts.IsCancellationRequested) return; } @@ -103,13 +103,13 @@ namespace CompatBot.EventHandlers { var cnt = true; var prefix = $"[{item.evt.Message.Id % 100:00}]"; - var ocrText = new StringBuilder($"OCR result of message <{item.evt.Message.JumpLink}>:").AppendLine(); + var ocrTextBuf = new StringBuilder($"OCR result of message <{item.evt.Message.JumpLink}>:").AppendLine(); Config.Log.Debug($"{prefix} OCR result of message {item.evt.Message.JumpLink}:"); var duplicates = new HashSet(); foreach (var r in result.AnalyzeResult.ReadResults) foreach (var l in r.Lines) { - ocrText.AppendLine(l.Text.Sanitize()); + ocrTextBuf.AppendLine(l.Text.Sanitize()); Config.Log.Debug($"{prefix} {l.Text}"); if (cnt && await ContentFilter.FindTriggerAsync(FilterContext.Chat, l.Text).ConfigureAwait(false) is Piracystring hit @@ -130,11 +130,14 @@ namespace CompatBot.EventHandlers cnt &= !hit.Actions.HasFlag(FilterAction.RemoveContent) && !hit.Actions.HasFlag(FilterAction.IssueWarning); } } - if (!cnt) + var ocrText = ocrTextBuf.ToString(); + var hasVkDiagInfo = ocrText.Contains("Vulkan Diagnostics Tool v") + || ocrText.Contains("VkDiag Version:"); + if (!cnt || hasVkDiagInfo) try { var botSpamCh = await client.GetChannelAsync(Config.ThumbnailSpamId).ConfigureAwait(false); - await botSpamCh.SendAutosplitMessageAsync(ocrText, blockStart: "", blockEnd: "").ConfigureAwait(false); + await botSpamCh.SendAutosplitMessageAsync(ocrTextBuf, blockStart: "", blockEnd: "").ConfigureAwait(false); } catch (Exception ex) { @@ -145,7 +148,7 @@ namespace CompatBot.EventHandlers else if (result.Status == OperationStatusCodes.NotStarted || result.Status == OperationStatusCodes.Running) { workQueue.Enqueue(item); - reEnqueId ??= item.readOperationId; + reEnqueueId ??= item.readOperationId; workSemaphore.Release(); } } diff --git a/CompatBot/Watchdog.cs b/CompatBot/Watchdog.cs index c23fd1fb..51f66409 100644 --- a/CompatBot/Watchdog.cs +++ b/CompatBot/Watchdog.cs @@ -109,7 +109,7 @@ namespace CompatBot tc.TrackMetric("time-since-last-incoming-message", TimeSinceLastIncomingMessage.ElapsedMilliseconds); tc.TrackMetric("memory-gc-total", gcMemInfo.HeapSizeBytes); tc.TrackMetric("memory-gc-load", gcMemInfo.MemoryLoadBytes); - tc.TrackMetric("memory-gc-commited", gcMemInfo.TotalCommittedBytes); + tc.TrackMetric("memory-gc-committed", gcMemInfo.TotalCommittedBytes); tc.TrackMetric("memory-process-private", process.PrivateMemorySize64); tc.TrackMetric("memory-process-ws", process.WorkingSet64); tc.TrackMetric("github-limit-remaining", GithubClient.Client.RateLimitRemaining);