mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
Misc GetBots() enhancements
This commit is contained in:
@@ -314,9 +314,8 @@ namespace ArchiSteamFarm {
|
||||
|
||||
foreach (string botName in botNames) {
|
||||
if (botName.Equals(SharedInfo.ASF, StringComparison.OrdinalIgnoreCase)) {
|
||||
foreach (Bot bot in Bots.OrderBy(bot => bot.Key).Select(bot => bot.Value)) {
|
||||
result.Add(bot);
|
||||
}
|
||||
IEnumerable<Bot> allBots = Bots.OrderBy(bot => bot.Key).Select(bot => bot.Value);
|
||||
result.UnionWith(allBots);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -324,38 +323,34 @@ namespace ArchiSteamFarm {
|
||||
if (botName.Contains("..")) {
|
||||
string[] botRange = botName.Split(new[] { ".." }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (botRange.Length == 2) {
|
||||
if (Bots.TryGetValue(botRange[0], out Bot firstBot) && Bots.TryGetValue(botRange[1], out Bot lastBot)) {
|
||||
bool inRange = false;
|
||||
if ((botRange.Length == 2) && Bots.TryGetValue(botRange[0], out Bot firstBot) && Bots.TryGetValue(botRange[1], out Bot lastBot)) {
|
||||
foreach (Bot bot in Bots.OrderBy(bot => bot.Key).Select(bot => bot.Value).SkipWhile(bot => bot != firstBot)) {
|
||||
result.Add(bot);
|
||||
|
||||
foreach (Bot bot in Bots.OrderBy(bot => bot.Key).Select(bot => bot.Value)) {
|
||||
if (bot == firstBot) {
|
||||
inRange = true;
|
||||
} else if (!inRange) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result.Add(bot);
|
||||
|
||||
if (bot == lastBot) {
|
||||
break;
|
||||
}
|
||||
if (bot == lastBot) {
|
||||
break;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
} else if (botName.StartsWith("r!", StringComparison.OrdinalIgnoreCase)) {
|
||||
}
|
||||
|
||||
if (botName.StartsWith("r!", StringComparison.OrdinalIgnoreCase)) {
|
||||
string botPattern = botName.Substring(2);
|
||||
|
||||
try {
|
||||
IEnumerable<Bot> regexMatches = Bots.Where(kvp => Regex.IsMatch(kvp.Key, botPattern, BotsRegex)).Select(kvp => kvp.Value);
|
||||
Regex regex = new Regex(botPattern, BotsRegex);
|
||||
|
||||
IEnumerable<Bot> regexMatches = Bots.Where(kvp => regex.IsMatch(kvp.Key)).Select(kvp => kvp.Value);
|
||||
result.UnionWith(regexMatches);
|
||||
} catch (ArgumentException e) {
|
||||
ASF.ArchiLogger.LogGenericWarningException(e);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Bots.TryGetValue(botName, out Bot targetBot)) {
|
||||
|
||||
Reference in New Issue
Block a user