mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 06:00:46 +00:00
Make !play accept more than one game, #106
This commit is contained in:
@@ -777,14 +777,24 @@ namespace ArchiSteamFarm {
|
|||||||
return await bot.ResponseAddLicense(gameID).ConfigureAwait(false);
|
return await bot.ResponseAddLicense(gameID).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<string> ResponsePlay(uint gameID) {
|
internal async Task<string> ResponsePlay(HashSet<uint> gameIDs) {
|
||||||
await CardsFarmer.SwitchToManualMode(gameID != 0).ConfigureAwait(false);
|
if (gameIDs == null || gameIDs.Count == 0) {
|
||||||
ArchiHandler.PlayGames(gameID);
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gameIDs.Contains(0)) {
|
||||||
|
await CardsFarmer.SwitchToManualMode(false).ConfigureAwait(false);
|
||||||
|
ArchiHandler.PlayGames(0);
|
||||||
|
} else {
|
||||||
|
await CardsFarmer.SwitchToManualMode(true).ConfigureAwait(false);
|
||||||
|
ArchiHandler.PlayGames(gameIDs);
|
||||||
|
}
|
||||||
|
|
||||||
return "Done!";
|
return "Done!";
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static async Task<string> ResponsePlay(string botName, string game) {
|
internal static async Task<string> ResponsePlay(string botName, string games) {
|
||||||
if (string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(game)) {
|
if (string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(games)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -793,12 +803,22 @@ namespace ArchiSteamFarm {
|
|||||||
return "Couldn't find any bot named " + botName + "!";
|
return "Couldn't find any bot named " + botName + "!";
|
||||||
}
|
}
|
||||||
|
|
||||||
uint gameID;
|
string[] gameIDs = games.Split(',');
|
||||||
if (!uint.TryParse(game, out gameID)) {
|
|
||||||
return "Couldn't parse game as a number!";
|
HashSet<uint> gamesToPlay = new HashSet<uint>();
|
||||||
|
foreach (string game in gameIDs) {
|
||||||
|
uint gameID;
|
||||||
|
if (!uint.TryParse(game, out gameID)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
gamesToPlay.Add(gameID);
|
||||||
}
|
}
|
||||||
|
|
||||||
return await bot.ResponsePlay(gameID).ConfigureAwait(false);
|
if (gamesToPlay.Count == 0) {
|
||||||
|
return "Couldn't parse any games given!";
|
||||||
|
}
|
||||||
|
|
||||||
|
return await bot.ResponsePlay(gamesToPlay).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<string> ResponseStart() {
|
internal async Task<string> ResponseStart() {
|
||||||
|
|||||||
Reference in New Issue
Block a user