Skip to content

Commit

Permalink
cleaner looking bot message for outdated mods check
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxiao921 committed Aug 10, 2022
1 parent 9ca1a1d commit 64a0281
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions CHEF/Components/Watcher/CommonIssues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ public static async Task<bool> CheckForOutdatedAndDeprecatedMods(string text, St
RegexOptions.Compiled | RegexOptions.IgnoreCase);
var matches = rx.Matches(text);

var outdatedMods = new StringBuilder();
var deprecatedMods = new StringBuilder();

foreach (Match match in matches)
{
if (match.Groups.Count > 2)
{
var outdatedMods = new StringBuilder();
var deprecatedMods = new StringBuilder();

// A log line is like this :
// TS Manifest: Random-Team-Name-ModName-1.0.0

Expand All @@ -99,32 +99,34 @@ public static async Task<bool> CheckForOutdatedAndDeprecatedMods(string text, St
{
deprecatedMods.AppendLine($"{modName}");
}
}

if (outdatedMods.Length > 0)
{
var outdatedModsS = outdatedMods.ToString();
var plural = outdatedModsS.Count(c => c == '\n') > 1;
answer.AppendLine(
$"{author.Mention}, you don't have the latest version installed of " +
$"the following mod{(plural ? "s" : "")}:" + Environment.NewLine +
outdatedModsS);

textContainsAnyBadMod = true;
}
}

if (deprecatedMods.Length > 0)
{
var deprecatedModsS = deprecatedMods.ToString();
var plural = deprecatedModsS.Count(c => c == '\n') > 1;
answer.AppendLine(
$"{author.Mention}, you have {(plural ? "" : "a")} deprecated " +
$"mod{(plural ? "s" : "")} installed. Deprecated mods usually don't work:" + Environment.NewLine +
deprecatedModsS);

textContainsAnyBadMod = true;
}
}
var notMentionedYet = true;
if (outdatedMods.Length > 0)
{
var outdatedModsS = outdatedMods.ToString();
var plural = outdatedModsS.Count(c => c == '\n') > 1;
answer.AppendLine(
$"{(notMentionedYet ? author.Mention + " y" : "Y")}ou don't have the latest version installed of " +
$"the following mod{(plural ? "s" : "")}:" + Environment.NewLine +
outdatedModsS);

textContainsAnyBadMod = true;
notMentionedYet = false;
}

if (deprecatedMods.Length > 0)
{
var deprecatedModsS = deprecatedMods.ToString();
var plural = deprecatedModsS.Count(c => c == '\n') > 1;
answer.AppendLine(
$"{(notMentionedYet ? author.Mention + " y" : "Y")}ou have {(plural ? "" : "a")} deprecated " +
$"mod{(plural ? "s" : "")} installed. Deprecated mods usually don't work:" + Environment.NewLine +
deprecatedModsS);

textContainsAnyBadMod = true;
}
}
}
Expand Down

0 comments on commit 64a0281

Please sign in to comment.