Skip to content

Commit de3a402

Browse files
committed
Allow to use "all" as target input for command removal options
1 parent 809b9d7 commit de3a402

1 file changed

Lines changed: 52 additions & 16 deletions

File tree

ArchiSteamFarm/Steam/Interaction/Commands.cs

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,11 +1399,20 @@ internal void OnNewLicenseList() {
13991399
HashSet<uint> appIDs = [];
14001400

14011401
foreach (string target in targets) {
1402-
if (!uint.TryParse(target, out uint appID) || (appID == 0)) {
1403-
return FormatBotResponse(Strings.FormatErrorParsingObject(nameof(appID)));
1404-
}
1402+
switch (target.ToUpperInvariant()) {
1403+
case "ALL":
1404+
appIDs.UnionWith(Bot.BotDatabase.FarmingBlacklistAppIDs);
14051405

1406-
appIDs.Add(appID);
1406+
break;
1407+
default:
1408+
if (!uint.TryParse(target, out uint appID) || (appID == 0)) {
1409+
return FormatBotResponse(Strings.FormatErrorParsingObject(nameof(appID)));
1410+
}
1411+
1412+
appIDs.Add(appID);
1413+
1414+
break;
1415+
}
14071416
}
14081417

14091418
if (!Bot.BotDatabase.FarmingBlacklistAppIDs.RemoveRange(appIDs)) {
@@ -1556,11 +1565,20 @@ internal void OnNewLicenseList() {
15561565
HashSet<uint> appIDs = [];
15571566

15581567
foreach (string target in targets) {
1559-
if (!uint.TryParse(target, out uint appID) || (appID == 0)) {
1560-
return FormatBotResponse(Strings.FormatErrorParsingObject(nameof(appID)));
1561-
}
1568+
switch (target.ToUpperInvariant()) {
1569+
case "ALL":
1570+
appIDs.UnionWith(Bot.BotDatabase.FarmingPriorityQueueAppIDs);
15621571

1563-
appIDs.Add(appID);
1572+
break;
1573+
default:
1574+
if (!uint.TryParse(target, out uint appID) || (appID == 0)) {
1575+
return FormatBotResponse(Strings.FormatErrorParsingObject(nameof(appID)));
1576+
}
1577+
1578+
appIDs.Add(appID);
1579+
1580+
break;
1581+
}
15641582
}
15651583

15661584
if (!Bot.BotDatabase.FarmingPriorityQueueAppIDs.RemoveRange(appIDs)) {
@@ -1975,11 +1993,20 @@ internal void OnNewLicenseList() {
19751993
HashSet<uint> appIDs = [];
19761994

19771995
foreach (string target in targets) {
1978-
if (!uint.TryParse(target, out uint appID) || (appID == 0)) {
1979-
return FormatBotResponse(Strings.FormatErrorParsingObject(nameof(appID)));
1980-
}
1996+
switch (target.ToUpperInvariant()) {
1997+
case "ALL":
1998+
appIDs.UnionWith(Bot.BotDatabase.MatchActivelyBlacklistAppIDs);
19811999

1982-
appIDs.Add(appID);
2000+
break;
2001+
default:
2002+
if (!uint.TryParse(target, out uint appID) || (appID == 0)) {
2003+
return FormatBotResponse(Strings.FormatErrorParsingObject(nameof(appID)));
2004+
}
2005+
2006+
appIDs.Add(appID);
2007+
2008+
break;
2009+
}
19832010
}
19842011

19852012
return FormatBotResponse(Bot.BotDatabase.MatchActivelyBlacklistAppIDs.RemoveRange(appIDs) ? Strings.Done : Strings.NothingFound);
@@ -3416,11 +3443,20 @@ internal void OnNewLicenseList() {
34163443
HashSet<ulong> targetIDs = [];
34173444

34183445
foreach (string target in targets) {
3419-
if (!ulong.TryParse(target, out ulong targetID) || (targetID == 0) || !new SteamID(targetID).IsIndividualAccount) {
3420-
return FormatBotResponse(Strings.FormatErrorParsingObject(nameof(targetID)));
3421-
}
3446+
switch (target.ToUpperInvariant()) {
3447+
case "ALL":
3448+
targetIDs.UnionWith(Bot.BotDatabase.TradingBlacklistSteamIDs);
34223449

3423-
targetIDs.Add(targetID);
3450+
break;
3451+
default:
3452+
if (!ulong.TryParse(target, out ulong targetID) || (targetID == 0) || !new SteamID(targetID).IsIndividualAccount) {
3453+
return FormatBotResponse(Strings.FormatErrorParsingObject(nameof(targetID)));
3454+
}
3455+
3456+
targetIDs.Add(targetID);
3457+
3458+
break;
3459+
}
34243460
}
34253461

34263462
return FormatBotResponse(Bot.BotDatabase.TradingBlacklistSteamIDs.RemoveRange(targetIDs) ? Strings.Done : Strings.NothingFound);

0 commit comments

Comments
 (0)