added extended !status syntax

This commit is contained in:
jogger 2015-11-18 22:15:10 +02:00
parent f873da7236
commit dfd4513b16
2 changed files with 44 additions and 9 deletions

27
ArchiSteamFarm/Bot.cs Normal file → Executable file
View file

@ -277,7 +277,31 @@ namespace ArchiSteamFarm {
if (steamID == 0) {
return;
}
if (CardsFarmer.CurrentGame > 0) {
SendMessageToUser(steamID, "Farming " + CardsFarmer.CurrentGame + " now");
SendMessageToUser(steamID, CardsFarmer.GamesLeft + " games left");
}
SendMessageToUser(steamID, "Currently " + Bots.Count + " bots are running");
}
private void ResponseStatus(ulong steamID, string botName)
{
if (steamID == 0 || string.IsNullOrEmpty(botName))
{
return;
}
Bot botToGet;
if (!Bots.TryGetValue(botName, out botToGet))
{
SendMessageToUser(steamID, "Running bot with this name not found!");
return;
}
if (botToGet.CardsFarmer.CurrentGame > 0)
{
SendMessageToUser(steamID, "Bot " + botName + " farming " + botToGet.CardsFarmer.CurrentGame +" now");
SendMessageToUser(steamID, "Bot " + botName + " has " + botToGet.CardsFarmer.GamesLeft + " games left");
}
SendMessageToUser(steamID, "Currently " + Bots.Count + " bots are running");
}
@ -455,6 +479,9 @@ namespace ArchiSteamFarm {
case "!stop":
await ResponseStop(steamID, args[1]).ConfigureAwait(false);
break;
case "!status":
ResponseStatus(steamID, args[1]);
break;
}
}
}

8
ArchiSteamFarm/CardsFarmer.cs Normal file → Executable file
View file

@ -29,6 +29,8 @@ using System.Threading.Tasks;
namespace ArchiSteamFarm {
internal class CardsFarmer {
internal ulong CurrentGame { get; private set; } = 0;
internal int GamesLeft { get; private set; } = 0;
private const byte StatusCheckSleep = 5; // In minutes, how long to wait before checking the appID again
private readonly ManualResetEvent FarmResetEvent = new ManualResetEvent(false);
@ -111,16 +113,22 @@ namespace ArchiSteamFarm {
// Start farming
while (appIDs.Count > 0) {
GamesLeft = appIDs.Count;
uint appID = appIDs[0];
Logging.LogGenericInfo(Bot.BotName, "Now farming: " + appID);
CurrentGame = appID;
if (await Farm(appID).ConfigureAwait(false)) {
appIDs.Remove(appID);
} else {
GamesLeft = 0;
CurrentGame = 0;
NowFarming = false;
return;
}
}
GamesLeft = 0;
CurrentGame = 0;
NowFarming = false;
Logging.LogGenericInfo(Bot.BotName, "Farming finished!");
await Bot.OnFarmingFinished().ConfigureAwait(false);