Compare commits

...

7 Commits

Author SHA1 Message Date
JustArchi
14867f470d Derp 2016-03-11 19:49:52 +01:00
JustArchi
187f0800b2 Add !update 2016-03-11 19:48:14 +01:00
JustArchi
3afa202d0b Misc 2016-03-11 19:42:15 +01:00
JustArchi
d33e76c8b0 Add !farm, closes #151 2016-03-11 19:39:25 +01:00
JustArchi
3061c55eaf Bump 2016-03-11 19:15:56 +01:00
JustArchi
621a1dc2cb Do not crash on bad configs 2016-03-11 18:49:29 +01:00
JustArchi
1a832780a2 Bump 2016-03-11 18:35:42 +01:00
3 changed files with 48 additions and 20 deletions

View File

@@ -262,16 +262,16 @@ namespace ArchiSteamFarm {
return; return;
} }
if (!await BotDatabase.SteamGuardAccount.RefreshSessionAsync().ConfigureAwait(false)) {
return;
}
Confirmation[] confirmations = await BotDatabase.SteamGuardAccount.FetchConfirmationsAsync().ConfigureAwait(false);
if (confirmations == null) {
return;
}
try { try {
if (!await BotDatabase.SteamGuardAccount.RefreshSessionAsync().ConfigureAwait(false)) {
return;
}
Confirmation[] confirmations = await BotDatabase.SteamGuardAccount.FetchConfirmationsAsync().ConfigureAwait(false);
if (confirmations == null) {
return;
}
foreach (Confirmation confirmation in confirmations) { foreach (Confirmation confirmation in confirmations) {
if (BotDatabase.SteamGuardAccount.AcceptConfirmation(confirmation)) { if (BotDatabase.SteamGuardAccount.AcceptConfirmation(confirmation)) {
Logging.LogGenericInfo("Accepting confirmation: Success!", BotName); Logging.LogGenericInfo("Accepting confirmation: Success!", BotName);
@@ -283,6 +283,9 @@ namespace ArchiSteamFarm {
Logging.LogGenericWarning("Accepting confirmation: Failed!", BotName); Logging.LogGenericWarning("Accepting confirmation: Failed!", BotName);
Logging.LogGenericWarning("Confirmation could not be accepted because of invalid token exception", BotName); Logging.LogGenericWarning("Confirmation could not be accepted because of invalid token exception", BotName);
Logging.LogGenericWarning("If issue persists, consider removing and readding ASF 2FA", BotName); Logging.LogGenericWarning("If issue persists, consider removing and readding ASF 2FA", BotName);
} catch (Exception e) {
Logging.LogGenericException(e, BotName);
return;
} }
} }
@@ -329,6 +332,10 @@ namespace ArchiSteamFarm {
case "!exit": case "!exit":
Program.Exit(); Program.Exit();
return null; return null;
case "!farm":
return await ResponseFarm().ConfigureAwait(false);
case "!loot":
return await ResponseSendTrade().ConfigureAwait(false);
case "!rejoinchat": case "!rejoinchat":
return ResponseRejoinChat(); return ResponseRejoinChat();
case "!restart": case "!restart":
@@ -340,8 +347,9 @@ namespace ArchiSteamFarm {
return ResponseStatusAll(); return ResponseStatusAll();
case "!stop": case "!stop":
return ResponseStop(); return ResponseStop();
case "!loot": case "!update":
return await ResponseSendTrade().ConfigureAwait(false); await Program.CheckForUpdate().ConfigureAwait(false);
return "Done!";
default: default:
return "Unrecognized command: " + message; return "Unrecognized command: " + message;
} }
@@ -360,6 +368,10 @@ namespace ArchiSteamFarm {
} else { } else {
return await ResponseAddLicense(BotName, args[1]).ConfigureAwait(false); return await ResponseAddLicense(BotName, args[1]).ConfigureAwait(false);
} }
case "!farm":
return await ResponseFarm(args[1]).ConfigureAwait(false);
case "!loot":
return await ResponseSendTrade(args[1]).ConfigureAwait(false);
case "!play": case "!play":
if (args.Length > 2) { if (args.Length > 2) {
return await ResponsePlay(args[1], args[2]).ConfigureAwait(false); return await ResponsePlay(args[1], args[2]).ConfigureAwait(false);
@@ -374,12 +386,10 @@ namespace ArchiSteamFarm {
} }
case "!start": case "!start":
return await ResponseStart(args[1]).ConfigureAwait(false); return await ResponseStart(args[1]).ConfigureAwait(false);
case "!stop":
return ResponseStop(args[1]);
case "!status": case "!status":
return ResponseStatus(args[1]); return ResponseStatus(args[1]);
case "!loot": case "!stop":
return await ResponseSendTrade(args[1]).ConfigureAwait(false); return ResponseStop(args[1]);
default: default:
return "Unrecognized command: " + args[0]; return "Unrecognized command: " + args[0];
} }
@@ -562,6 +572,24 @@ namespace ArchiSteamFarm {
return await bot.Response2FAOK().ConfigureAwait(false); return await bot.Response2FAOK().ConfigureAwait(false);
} }
private async Task<string> ResponseFarm() {
await CardsFarmer.RestartFarming().ConfigureAwait(false);
return "Done!";
}
private static async Task<string> ResponseFarm(string botName) {
if (string.IsNullOrEmpty(botName)) {
return null;
}
Bot bot;
if (!Bots.TryGetValue(botName, out bot)) {
return "Couldn't find any bot named " + botName + "!";
}
return await bot.ResponseFarm().ConfigureAwait(false);
}
private async Task<string> ResponseRedeem(string message, bool validate) { private async Task<string> ResponseRedeem(string message, bool validate) {
if (string.IsNullOrEmpty(message)) { if (string.IsNullOrEmpty(message)) {
return null; return null;

View File

@@ -78,7 +78,7 @@ namespace ArchiSteamFarm {
private static Timer AutoUpdatesTimer; private static Timer AutoUpdatesTimer;
private static EMode Mode = EMode.Normal; private static EMode Mode = EMode.Normal;
private static async Task CheckForUpdate() { internal static async Task CheckForUpdate() {
string oldExeFile = ExecutableFile + ".old"; string oldExeFile = ExecutableFile + ".old";
// We booted successfully so we can now remove old exe file // We booted successfully so we can now remove old exe file
@@ -334,7 +334,7 @@ namespace ArchiSteamFarm {
private static void InitServices() { private static void InitServices() {
GlobalConfig = GlobalConfig.Load(); GlobalConfig = GlobalConfig.Load();
if (GlobalConfig == null) { if (GlobalConfig == null) {
Logging.LogGenericError("Global config could not be loaded, please make sure that ASF.db exists and is valid!"); Logging.LogGenericError("Global config could not be loaded, please make sure that ASF.json exists and is valid!");
Thread.Sleep(5000); Thread.Sleep(5000);
Exit(1); Exit(1);
} }
@@ -464,7 +464,7 @@ namespace ArchiSteamFarm {
string botName = Path.GetFileNameWithoutExtension(configFile); string botName = Path.GetFileNameWithoutExtension(configFile);
Logging.LogGenericWarning("Found legacy " + botName + ".xml config file, it will now be converted to new ASF V2.0 format!"); Logging.LogGenericWarning("Found legacy " + botName + ".xml config file, it will now be converted to new ASF V2.0 format!");
Bot bot = new Bot(botName); Bot bot = new Bot(botName);
if (!bot.BotConfig.Enabled) { if (bot.BotConfig == null || !bot.BotConfig.Enabled) {
Logging.LogGenericInfo("Not starting this instance because it's disabled in config file", botName); Logging.LogGenericInfo("Not starting this instance because it's disabled in config file", botName);
} }
} }

View File

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.0.4")] [assembly: AssemblyVersion("2.0.0.6")]
[assembly: AssemblyFileVersion("2.0.0.4")] [assembly: AssemblyFileVersion("2.0.0.6")]