Improve owns command to take into account owned packageIDs

Idea thanks to @ryzhehvost
This commit is contained in:
JustArchi
2019-07-02 15:06:01 +02:00
parent 495684dfee
commit b30e3f3b5d
2 changed files with 160 additions and 74 deletions

View File

@@ -373,25 +373,27 @@ namespace ArchiSteamFarm {
if (botName.StartsWith("r!", StringComparison.OrdinalIgnoreCase)) {
string botsPattern = botName.Substring(2);
RegexOptions botsRegex = RegexOptions.None;
if ((BotsComparer == StringComparer.InvariantCulture) || (BotsComparer == StringComparer.Ordinal)) {
botsRegex |= RegexOptions.CultureInvariant;
} else if ((BotsComparer == StringComparer.InvariantCultureIgnoreCase) || (BotsComparer == StringComparer.OrdinalIgnoreCase)) {
botsRegex |= RegexOptions.CultureInvariant | RegexOptions.IgnoreCase;
}
Regex regex;
try {
RegexOptions botsRegex = RegexOptions.None;
if ((BotsComparer == StringComparer.InvariantCulture) || (BotsComparer == StringComparer.Ordinal)) {
botsRegex |= RegexOptions.CultureInvariant;
} else if ((BotsComparer == StringComparer.InvariantCultureIgnoreCase) || (BotsComparer == StringComparer.OrdinalIgnoreCase)) {
botsRegex |= RegexOptions.CultureInvariant | RegexOptions.IgnoreCase;
}
Regex regex = new Regex(botsPattern, botsRegex);
IEnumerable<Bot> regexMatches = Bots.Where(kvp => regex.IsMatch(kvp.Key)).Select(kvp => kvp.Value);
result.UnionWith(regexMatches);
regex = new Regex(botsPattern, botsRegex);
} catch (ArgumentException e) {
ASF.ArchiLogger.LogGenericWarningException(e);
return null;
}
IEnumerable<Bot> regexMatches = Bots.Where(kvp => regex.IsMatch(kvp.Key)).Select(kvp => kvp.Value);
result.UnionWith(regexMatches);
continue;
}