Compare commits

..

21 Commits

Author SHA1 Message Date
JustArchi
2b3a5ff337 Work on extra GUI app 2016-03-20 05:27:30 +01:00
JustArchi
0387eb3746 Misc 2016-03-19 15:33:07 +01:00
JustArchi
3ebc6d618a Misc 2016-03-19 15:31:54 +01:00
JustArchi
92d9e10cb8 Bump 2016-03-19 12:03:39 +01:00
JustArchi
d0d670f1a5 Add warning for invalid protocols 2016-03-19 11:48:51 +01:00
JustArchi
3597c8f138 Make it possible to run steam client with UDP 2016-03-19 11:33:39 +01:00
JustArchi
8a8ec29b41 Fix OnBotShutdown() firing too fast 2016-03-18 20:56:23 +01:00
JustArchi
a3352d032d Bump 2016-03-18 20:45:31 +01:00
JustArchi
d5f8647fcc Misc 2016-03-18 20:36:13 +01:00
JustArchi
79a700d786 Fix group chat commands, #165 2016-03-18 20:35:42 +01:00
JustArchi
bc223f0644 Misc 2016-03-18 14:54:42 +01:00
JustArchi
2b0d82453b Speedup login by doing independent tasks in parallel 2016-03-18 14:47:52 +01:00
JustArchi
fa0150e745 Code review 2016-03-18 14:39:59 +01:00
JustArchi
c95d11ef66 Actually do not respond to non-authorized users at all 2016-03-18 14:13:04 +01:00
JustArchi
63b268f9c4 Bump 2016-03-18 14:09:24 +01:00
JustArchi
03d38f8a2a Fix derp, #165 2016-03-18 14:05:18 +01:00
JustArchi
c88d9bf123 Implement SteamOwnerID 2016-03-18 09:02:09 +01:00
JustArchi
053ebe15bb Prepare for SteamOwnerID 2016-03-18 03:52:36 +01:00
JustArchi
b03bfb6bbc Don't touch old log when disabled 2016-03-18 03:48:00 +01:00
JustArchi
e48867000e Add LogToFile, closes #168 2016-03-18 03:45:59 +01:00
JustArchi
e08cdbd74d Bump 2016-03-16 19:58:21 +01:00
29 changed files with 1636 additions and 209 deletions

3
.gitignore vendored
View File

@@ -12,6 +12,9 @@ ArchiSteamFarm/config/*
ArchiSteamFarm/log.txt
ArchiSteamFarm/debug/*
# Ignore out
out/
#################
## Eclipse
#################

View File

@@ -1,12 +1,17 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArchiSteamFarm", "ArchiSteamFarm\ArchiSteamFarm.csproj", "{35AF7887-08B9-40E8-A5EA-797D8B60B30C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SteamAuth", "SteamAuth\SteamAuth.csproj", "{5AD0934E-F6C4-4AE5-83AF-C788313B2A87}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfigGenerator", "ConfigGenerator\ConfigGenerator.csproj", "{C3F6FE68-5E75-415E-BEA1-1E7C16D6A433}"
ProjectSection(ProjectDependencies) = postProject
{35AF7887-08B9-40E8-A5EA-797D8B60B30C} = {35AF7887-08B9-40E8-A5EA-797D8B60B30C}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +26,10 @@ Global
{5AD0934E-F6C4-4AE5-83AF-C788313B2A87}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5AD0934E-F6C4-4AE5-83AF-C788313B2A87}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5AD0934E-F6C4-4AE5-83AF-C788313B2A87}.Release|Any CPU.Build.0 = Release|Any CPU
{C3F6FE68-5E75-415E-BEA1-1E7C16D6A433}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C3F6FE68-5E75-415E-BEA1-1E7C16D6A433}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C3F6FE68-5E75-415E-BEA1-1E7C16D6A433}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C3F6FE68-5E75-415E-BEA1-1E7C16D6A433}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -160,20 +160,20 @@
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent Condition=" '$(OS)' != 'Unix' AND '$(ConfigurationName)' == 'Release' ">
mkdir "$(TargetDir)out" "$(TargetDir)out\config"
copy "$(TargetDir)config\ASF.json" "$(TargetDir)out\config"
copy "$(TargetDir)config\example.json" "$(TargetDir)out\config"
copy "$(TargetDir)config\minimal.json" "$(TargetDir)out\config"
"$(SolutionDir)tools\ILRepack.exe" /ndebug /internalize /parallel /targetplatform:v4 /wildcards /out:"$(TargetDir)out\ASF.exe" "$(TargetDir)$(TargetName).exe" "$(TargetDir)*.dll"
del "$(TargetDir)out\ASF.exe.config"
mkdir "$(SolutionDir)out" "$(SolutionDir)out\config"
copy "$(TargetDir)config\ASF.json" "$(SolutionDir)out\config"
copy "$(TargetDir)config\example.json" "$(SolutionDir)out\config"
copy "$(TargetDir)config\minimal.json" "$(SolutionDir)out\config"
"$(SolutionDir)tools\ILRepack.exe" /ndebug /internalize /parallel /targetplatform:v4 /wildcards /out:"$(SolutionDir)out\ASF.exe" "$(TargetDir)$(TargetName).exe" "$(TargetDir)*.dll"
del "$(SolutionDir)out\ASF.exe.config"
</PostBuildEvent>
<PostBuildEvent Condition=" '$(OS)' == 'Unix' AND '$(ConfigurationName)' == 'Release' ">
mkdir -p "$(TargetDir)out" "$(TargetDir)out/config"
cp "$(TargetDir)config/ASF.json" "$(TargetDir)out/config"
cp "$(TargetDir)config/example.json" "$(TargetDir)out/config"
cp "$(TargetDir)config/minimal.json" "$(TargetDir)out/config"
mono -O=all "$(SolutionDir)tools/ILRepack.exe" /ndebug /internalize /parallel /targetplatform:v4 /wildcards /out:"$(TargetDir)out/ASF.exe" "$(TargetDir)$(TargetName).exe" "$(TargetDir)*.dll"
rm "$(TargetDir)out/ASF.exe.config"
mkdir -p "$(SolutionDir)out" "$(SolutionDir)out/config"
cp "$(TargetDir)config/ASF.json" "$(SolutionDir)out/config"
cp "$(TargetDir)config/example.json" "$(SolutionDir)out/config"
cp "$(TargetDir)config/minimal.json" "$(SolutionDir)out/config"
mono -O=all "$(SolutionDir)tools/ILRepack.exe" /ndebug /internalize /parallel /targetplatform:v4 /wildcards /out:"$(SolutionDir)out/ASF.exe" "$(TargetDir)$(TargetName).exe" "$(TargetDir)*.dll"
rm "$(SolutionDir)out/ASF.exe.config"
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@@ -43,10 +43,6 @@ namespace ArchiSteamFarm {
private static readonly uint LoginID = MsgClientLogon.ObfuscationMask; // This must be the same for all ASF bots and all ASF processes
private readonly string SentryFile;
private readonly Timer AcceptConfirmationsTimer;
private readonly Timer SendItemsTimer;
internal readonly string BotName;
internal readonly ArchiHandler ArchiHandler;
internal readonly ArchiWebHandler ArchiWebHandler;
@@ -54,6 +50,9 @@ namespace ArchiSteamFarm {
internal readonly BotDatabase BotDatabase;
internal readonly SteamClient SteamClient;
private readonly string SentryFile;
private readonly Timer AcceptConfirmationsTimer;
private readonly Timer SendItemsTimer;
private readonly CallbackManager CallbackManager;
private readonly CardsFarmer CardsFarmer;
private readonly SteamApps SteamApps;
@@ -63,8 +62,7 @@ namespace ArchiSteamFarm {
internal bool KeepRunning { get; private set; } = false;
private bool InvalidPassword = false;
private bool LoggedInElsewhere = false;
private bool InvalidPassword, LoggedInElsewhere;
private string AuthCode, TwoFactorAuth;
internal static async Task RefreshCMs(uint cellID) {
@@ -87,6 +85,14 @@ namespace ArchiSteamFarm {
}
}
private static bool IsOwner(ulong steamID) {
if (steamID == 0) {
return false;
}
return steamID == Program.GlobalConfig.SteamOwnerID;
}
private static bool IsValidCdKey(string key) {
if (string.IsNullOrEmpty(key)) {
return false;
@@ -171,14 +177,16 @@ namespace ArchiSteamFarm {
BotDatabase = BotDatabase.Load(botPath + ".db");
SentryFile = botPath + ".bin";
// Support and convert SDA files
string maFilePath = botPath + ".maFile";
if (BotDatabase.SteamGuardAccount == null && File.Exists(maFilePath)) {
ImportAuthenticator(maFilePath);
if (BotDatabase.SteamGuardAccount == null) {
// Support and convert SDA files
string maFilePath = botPath + ".maFile";
if (File.Exists(maFilePath)) {
ImportAuthenticator(maFilePath);
}
}
// Initialize
SteamClient = new SteamClient();
SteamClient = new SteamClient(Program.GlobalConfig.SteamProtocol);
if (Program.GlobalConfig.Debug && !Debugging.NetHookAlreadyInitialized && Directory.Exists(Program.DebugDirectory)) {
try {
@@ -232,7 +240,7 @@ namespace ArchiSteamFarm {
if (BotConfig.SendTradePeriod > 0 && SendItemsTimer == null) {
SendItemsTimer = new Timer(
async e => await ResponseSendTrade().ConfigureAwait(false),
async e => await ResponseSendTrade(BotConfig.SteamMasterID).ConfigureAwait(false),
null,
TimeSpan.FromHours(BotConfig.SendTradePeriod), // Delay
TimeSpan.FromHours(BotConfig.SendTradePeriod) // Period
@@ -244,7 +252,15 @@ namespace ArchiSteamFarm {
}
// Start
Start().Wait();
Task.Run(async () => await Start().ConfigureAwait(false)).Forget();
}
internal bool IsMaster(ulong steamID) {
if (steamID == 0) {
return false;
}
return steamID == BotConfig.SteamMasterID || IsOwner(steamID);
}
internal async Task AcceptConfirmations(Confirmation.ConfirmationType allowedConfirmationType = Confirmation.ConfirmationType.Unknown) {
@@ -294,99 +310,97 @@ namespace ArchiSteamFarm {
internal async Task OnFarmingFinished(bool farmedSomething) {
if (farmedSomething && BotConfig.SendOnFarmingFinished) {
await ResponseSendTrade().ConfigureAwait(false);
await ResponseSendTrade(BotConfig.SteamMasterID).ConfigureAwait(false);
}
if (BotConfig.ShutdownOnFarmingFinished) {
await Shutdown().ConfigureAwait(false);
}
}
internal async Task<string> HandleMessage(string message) {
if (string.IsNullOrEmpty(message)) {
internal async Task<string> Response(ulong steamID, string message) {
if (steamID == 0 || string.IsNullOrEmpty(message)) {
return null;
}
if (!message.StartsWith("!")) {
return await ResponseRedeem(BotName, message, true).ConfigureAwait(false);
return await ResponseRedeem(steamID, BotName, message, true).ConfigureAwait(false);
}
if (!message.Contains(" ")) {
switch (message) {
case "!2fa":
return Response2FA();
return Response2FA(steamID);
case "!2faoff":
return Response2FAOff();
return Response2FAOff(steamID);
case "!2faok":
return await Response2FAOK().ConfigureAwait(false);
return await Response2FAOK(steamID).ConfigureAwait(false);
case "!exit":
Program.Exit();
return null;
return ResponseExit(steamID);
case "!farm":
return await ResponseFarm().ConfigureAwait(false);
return await ResponseFarm(steamID).ConfigureAwait(false);
case "!loot":
return await ResponseSendTrade().ConfigureAwait(false);
return await ResponseSendTrade(steamID).ConfigureAwait(false);
case "!rejoinchat":
return ResponseRejoinChat();
return ResponseRejoinChat(steamID);
case "!restart":
Program.Restart();
return null;
return ResponseRestart(steamID);
case "!status":
return ResponseStatus();
return ResponseStatus(steamID);
case "!statusall":
return ResponseStatusAll();
return ResponseStatusAll(steamID);
case "!stop":
return await ResponseStop().ConfigureAwait(false);
return await ResponseStop(steamID).ConfigureAwait(false);
case "!update":
await Program.CheckForUpdate().ConfigureAwait(false);
return "Done!";
return await ResponseUpdate(steamID).ConfigureAwait(false);
default:
return "Unrecognized command: " + message;
return ResponseUnknown(steamID);
}
} else {
string[] args = message.Split(' ');
switch (args[0]) {
case "!2fa":
return Response2FA(args[1]);
return Response2FA(steamID, args[1]);
case "!2faoff":
return Response2FAOff(args[1]);
return Response2FAOff(steamID, args[1]);
case "!2faok":
return await Response2FAOK(args[1]).ConfigureAwait(false);
return await Response2FAOK(steamID, args[1]).ConfigureAwait(false);
case "!addlicense":
if (args.Length > 2) {
return await ResponseAddLicense(args[1], args[2]).ConfigureAwait(false);
return await ResponseAddLicense(steamID, args[1], args[2]).ConfigureAwait(false);
} else {
return await ResponseAddLicense(BotName, args[1]).ConfigureAwait(false);
return await ResponseAddLicense(steamID, BotName, args[1]).ConfigureAwait(false);
}
case "!farm":
return await ResponseFarm(args[1]).ConfigureAwait(false);
return await ResponseFarm(steamID, args[1]).ConfigureAwait(false);
case "!loot":
return await ResponseSendTrade(args[1]).ConfigureAwait(false);
return await ResponseSendTrade(steamID, args[1]).ConfigureAwait(false);
case "!owns":
if (args.Length > 2) {
return await ResponseOwns(args[1], args[2]).ConfigureAwait(false);
return await ResponseOwns(steamID, args[1], args[2]).ConfigureAwait(false);
} else {
return await ResponseOwns(BotName, args[1]).ConfigureAwait(false);
return await ResponseOwns(steamID, BotName, args[1]).ConfigureAwait(false);
}
case "!play":
if (args.Length > 2) {
return await ResponsePlay(args[1], args[2]).ConfigureAwait(false);
return await ResponsePlay(steamID, args[1], args[2]).ConfigureAwait(false);
} else {
return await ResponsePlay(BotName, args[1]).ConfigureAwait(false);
return await ResponsePlay(steamID, BotName, args[1]).ConfigureAwait(false);
}
case "!redeem":
if (args.Length > 2) {
return await ResponseRedeem(args[1], args[2], false).ConfigureAwait(false);
return await ResponseRedeem(steamID, args[1], args[2], false).ConfigureAwait(false);
} else {
return await ResponseRedeem(BotName, args[1], false).ConfigureAwait(false);
return await ResponseRedeem(steamID, BotName, args[1], false).ConfigureAwait(false);
}
case "!start":
return await ResponseStart(args[1]).ConfigureAwait(false);
return await ResponseStart(steamID, args[1]).ConfigureAwait(false);
case "!status":
return ResponseStatus(args[1]);
return ResponseStatus(steamID, args[1]);
case "!stop":
return await ResponseStop(args[1]).ConfigureAwait(false);
return await ResponseStop(steamID, args[1]).ConfigureAwait(false);
default:
return "Unrecognized command: " + args[0];
return ResponseUnknown(steamID);
}
}
}
@@ -492,7 +506,15 @@ namespace ArchiSteamFarm {
Logging.LogGenericInfo("Successfully finished importing mobile authenticator!", BotName);
}
private string ResponseStatus() {
private string ResponseStatus(ulong steamID) {
if (steamID == 0) {
return null;
}
if (!IsMaster(steamID)) {
return null;
}
if (CardsFarmer.CurrentGamesFarming.Count > 0) {
return "Bot " + BotName + " is currently farming appIDs: " + string.Join(", ", CardsFarmer.CurrentGamesFarming) + " and has a total of " + CardsFarmer.GamesToFarm.Count + " games left to farm.";
} else {
@@ -500,8 +522,8 @@ namespace ArchiSteamFarm {
}
}
private static string ResponseStatus(string botName) {
if (string.IsNullOrEmpty(botName)) {
private static string ResponseStatus(ulong steamID, string botName) {
if (steamID == 0 || string.IsNullOrEmpty(botName)) {
return null;
}
@@ -510,17 +532,25 @@ namespace ArchiSteamFarm {
return "Couldn't find any bot named " + botName + "!";
}
return bot.ResponseStatus();
return bot.ResponseStatus(steamID);
}
private static string ResponseStatusAll() {
private static string ResponseStatusAll(ulong steamID) {
if (steamID == 0) {
return null;
}
if (!IsOwner(steamID)) {
return null;
}
StringBuilder result = new StringBuilder(Environment.NewLine);
int totalBotsCount = Bots.Count;
int runningBotsCount = 0;
foreach (Bot bot in Bots.Values) {
result.Append(bot.ResponseStatus() + Environment.NewLine);
result.Append(bot.ResponseStatus(steamID) + Environment.NewLine);
if (bot.KeepRunning) {
runningBotsCount++;
}
@@ -530,7 +560,15 @@ namespace ArchiSteamFarm {
return result.ToString();
}
private async Task<string> ResponseSendTrade() {
private async Task<string> ResponseSendTrade(ulong steamID) {
if (steamID == 0) {
return null;
}
if (!IsMaster(steamID)) {
return null;
}
if (BotConfig.SteamMasterID == 0) {
return "Trade couldn't be send because SteamMasterID is not defined!";
}
@@ -550,8 +588,8 @@ namespace ArchiSteamFarm {
}
}
private static async Task<string> ResponseSendTrade(string botName) {
if (string.IsNullOrEmpty(botName)) {
private static async Task<string> ResponseSendTrade(ulong steamID, string botName) {
if (steamID == 0 || string.IsNullOrEmpty(botName)) {
return null;
}
@@ -560,10 +598,18 @@ namespace ArchiSteamFarm {
return "Couldn't find any bot named " + botName + "!";
}
return await bot.ResponseSendTrade().ConfigureAwait(false);
return await bot.ResponseSendTrade(steamID).ConfigureAwait(false);
}
private string Response2FA() {
private string Response2FA(ulong steamID) {
if (steamID == 0) {
return null;
}
if (!IsMaster(steamID)) {
return null;
}
if (BotDatabase.SteamGuardAccount == null) {
return "That bot doesn't have ASF 2FA enabled!";
}
@@ -572,8 +618,8 @@ namespace ArchiSteamFarm {
return "2FA Token: " + BotDatabase.SteamGuardAccount.GenerateSteamGuardCode() + " (expires in " + timeLeft + " seconds)";
}
private static string Response2FA(string botName) {
if (string.IsNullOrEmpty(botName)) {
private static string Response2FA(ulong steamID, string botName) {
if (steamID == 0 || string.IsNullOrEmpty(botName)) {
return null;
}
@@ -582,10 +628,18 @@ namespace ArchiSteamFarm {
return "Couldn't find any bot named " + botName + "!";
}
return bot.Response2FA();
return bot.Response2FA(steamID);
}
private string Response2FAOff() {
private string Response2FAOff(ulong steamID) {
if (steamID == 0) {
return null;
}
if (!IsMaster(steamID)) {
return null;
}
if (BotDatabase.SteamGuardAccount == null) {
return "That bot doesn't have ASF 2FA enabled!";
}
@@ -597,8 +651,8 @@ namespace ArchiSteamFarm {
}
}
private static string Response2FAOff(string botName) {
if (string.IsNullOrEmpty(botName)) {
private static string Response2FAOff(ulong steamID, string botName) {
if (steamID == 0 || string.IsNullOrEmpty(botName)) {
return null;
}
@@ -607,10 +661,18 @@ namespace ArchiSteamFarm {
return "Couldn't find any bot named " + botName + "!";
}
return bot.Response2FAOff();
return bot.Response2FAOff(steamID);
}
private async Task<string> Response2FAOK() {
private async Task<string> Response2FAOK(ulong steamID) {
if (steamID == 0) {
return null;
}
if (!IsMaster(steamID)) {
return null;
}
if (BotDatabase.SteamGuardAccount == null) {
return "That bot doesn't have ASF 2FA enabled!";
}
@@ -619,8 +681,8 @@ namespace ArchiSteamFarm {
return "Done!";
}
private static async Task<string> Response2FAOK(string botName) {
if (string.IsNullOrEmpty(botName)) {
private static async Task<string> Response2FAOK(ulong steamID, string botName) {
if (steamID == 0 || string.IsNullOrEmpty(botName)) {
return null;
}
@@ -629,16 +691,37 @@ namespace ArchiSteamFarm {
return "Couldn't find any bot named " + botName + "!";
}
return await bot.Response2FAOK().ConfigureAwait(false);
return await bot.Response2FAOK(steamID).ConfigureAwait(false);
}
private async Task<string> ResponseFarm() {
private static string ResponseExit(ulong steamID) {
if (steamID == 0) {
return null;
}
if (!IsOwner(steamID)) {
return null;
}
Environment.Exit(0);
return null;
}
private async Task<string> ResponseFarm(ulong steamID) {
if (steamID == 0) {
return null;
}
if (!IsMaster(steamID)) {
return null;
}
await CardsFarmer.RestartFarming().ConfigureAwait(false);
return "Done!";
}
private static async Task<string> ResponseFarm(string botName) {
if (string.IsNullOrEmpty(botName)) {
private static async Task<string> ResponseFarm(ulong steamID, string botName) {
if (steamID == 0 || string.IsNullOrEmpty(botName)) {
return null;
}
@@ -647,11 +730,15 @@ namespace ArchiSteamFarm {
return "Couldn't find any bot named " + botName + "!";
}
return await bot.ResponseFarm().ConfigureAwait(false);
return await bot.ResponseFarm(steamID).ConfigureAwait(false);
}
private async Task<string> ResponseRedeem(string message, bool validate) {
if (string.IsNullOrEmpty(message)) {
private async Task<string> ResponseRedeem(ulong steamID, string message, bool validate) {
if (steamID == 0 || string.IsNullOrEmpty(message)) {
return null;
}
if (!IsMaster(steamID)) {
return null;
}
@@ -791,8 +878,8 @@ namespace ArchiSteamFarm {
return response.ToString();
}
private static async Task<string> ResponseRedeem(string botName, string message, bool validate) {
if (string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(message)) {
private static async Task<string> ResponseRedeem(ulong steamID, string botName, string message, bool validate) {
if (steamID == 0 || string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(message)) {
return null;
}
@@ -801,10 +888,18 @@ namespace ArchiSteamFarm {
return "Couldn't find any bot named " + botName + "!";
}
return await bot.ResponseRedeem(message, validate).ConfigureAwait(false);
return await bot.ResponseRedeem(steamID, message, validate).ConfigureAwait(false);
}
private static string ResponseRejoinChat() {
private static string ResponseRejoinChat(ulong steamID) {
if (steamID == 0) {
return null;
}
if (!IsOwner(steamID)) {
return null;
}
foreach (Bot bot in Bots.Values) {
bot.JoinMasterChat();
}
@@ -812,8 +907,25 @@ namespace ArchiSteamFarm {
return "Done!";
}
private async Task<string> ResponseAddLicense(HashSet<uint> gameIDs) {
if (gameIDs == null || gameIDs.Count == 0) {
private static string ResponseRestart(ulong steamID) {
if (steamID == 0) {
return null;
}
if (!IsOwner(steamID)) {
return null;
}
Program.Restart();
return null;
}
private async Task<string> ResponseAddLicense(ulong steamID, HashSet<uint> gameIDs) {
if (steamID == 0 || gameIDs == null || gameIDs.Count == 0) {
return null;
}
if (!IsMaster(steamID)) {
return null;
}
@@ -833,8 +945,8 @@ namespace ArchiSteamFarm {
return result.ToString();
}
private static async Task<string> ResponseAddLicense(string botName, string games) {
if (string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(games)) {
private static async Task<string> ResponseAddLicense(ulong steamID, string botName, string games) {
if (steamID == 0 || string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(games)) {
return null;
}
@@ -858,11 +970,15 @@ namespace ArchiSteamFarm {
return "Couldn't parse any games given!";
}
return await bot.ResponseAddLicense(gamesToRedeem).ConfigureAwait(false);
return await bot.ResponseAddLicense(steamID, gamesToRedeem).ConfigureAwait(false);
}
private async Task<string> ResponseOwns(string games) {
if (string.IsNullOrEmpty(games)) {
private async Task<string> ResponseOwns(ulong steamID, string games) {
if (steamID == 0 || string.IsNullOrEmpty(games)) {
return null;
}
if (!IsMaster(steamID)) {
return null;
}
@@ -900,8 +1016,8 @@ namespace ArchiSteamFarm {
}
}
private static async Task<string> ResponseOwns(string botName, string games) {
if (string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(games)) {
private static async Task<string> ResponseOwns(ulong steamID, string botName, string games) {
if (steamID == 0 || string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(games)) {
return null;
}
@@ -910,11 +1026,15 @@ namespace ArchiSteamFarm {
return "Couldn't find any bot named " + botName + "!";
}
return await bot.ResponseOwns(games).ConfigureAwait(false);
return await bot.ResponseOwns(steamID, games).ConfigureAwait(false);
}
private async Task<string> ResponsePlay(HashSet<uint> gameIDs) {
if (gameIDs == null || gameIDs.Count == 0) {
private async Task<string> ResponsePlay(ulong steamID, HashSet<uint> gameIDs) {
if (steamID == 0 || gameIDs == null || gameIDs.Count == 0) {
return null;
}
if (!IsMaster(steamID)) {
return null;
}
@@ -930,8 +1050,8 @@ namespace ArchiSteamFarm {
return "Done!";
}
private static async Task<string> ResponsePlay(string botName, string games) {
if (string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(games)) {
private static async Task<string> ResponsePlay(ulong steamID, string botName, string games) {
if (steamID == 0 || string.IsNullOrEmpty(botName) || string.IsNullOrEmpty(games)) {
return null;
}
@@ -955,10 +1075,18 @@ namespace ArchiSteamFarm {
return "Couldn't parse any games given!";
}
return await bot.ResponsePlay(gamesToPlay).ConfigureAwait(false);
return await bot.ResponsePlay(steamID, gamesToPlay).ConfigureAwait(false);
}
private async Task<string> ResponseStart() {
private async Task<string> ResponseStart(ulong steamID) {
if (steamID == 0) {
return null;
}
if (!IsMaster(steamID)) {
return null;
}
if (KeepRunning) {
return "That bot instance is already running!";
}
@@ -967,8 +1095,8 @@ namespace ArchiSteamFarm {
return "Done!";
}
private static async Task<string> ResponseStart(string botName) {
if (string.IsNullOrEmpty(botName)) {
private static async Task<string> ResponseStart(ulong steamID, string botName) {
if (steamID == 0 || string.IsNullOrEmpty(botName)) {
return null;
}
@@ -977,10 +1105,18 @@ namespace ArchiSteamFarm {
return "Couldn't find any bot named " + botName + "!";
}
return await bot.ResponseStart().ConfigureAwait(false);
return await bot.ResponseStart(steamID).ConfigureAwait(false);
}
private async Task<string> ResponseStop() {
private async Task<string> ResponseStop(ulong steamID) {
if (steamID == 0) {
return null;
}
if (!IsMaster(steamID)) {
return null;
}
if (!KeepRunning) {
return "That bot instance is already inactive!";
}
@@ -989,8 +1125,8 @@ namespace ArchiSteamFarm {
return "Done!";
}
private static async Task<string> ResponseStop(string botName) {
if (string.IsNullOrEmpty(botName)) {
private static async Task<string> ResponseStop(ulong steamID, string botName) {
if (steamID == 0 || string.IsNullOrEmpty(botName)) {
return null;
}
@@ -999,7 +1135,32 @@ namespace ArchiSteamFarm {
return "Couldn't find any bot named " + botName + "!";
}
return await bot.ResponseStop().ConfigureAwait(false);
return await bot.ResponseStop(steamID).ConfigureAwait(false);
}
private string ResponseUnknown(ulong steamID) {
if (steamID == 0) {
return null;
}
if (!IsMaster(steamID)) {
return null;
}
return "ERROR: Unknown command!";
}
private static async Task<string> ResponseUpdate(ulong steamID) {
if (steamID == 0) {
return null;
}
if (!IsOwner(steamID)) {
return null;
}
await Program.CheckForUpdate().ConfigureAwait(false);
return "Done!";
}
private void HandleCallbacks() {
@@ -1009,12 +1170,12 @@ namespace ArchiSteamFarm {
}
}
private async Task HandleMessage(ulong steamID, string message) {
if (steamID == 0 || string.IsNullOrEmpty(message)) {
private async Task HandleMessage(ulong chatID, ulong steamID, string message) {
if (chatID == 0 || steamID == 0 || string.IsNullOrEmpty(message)) {
return;
}
SendMessage(steamID, await HandleMessage(message).ConfigureAwait(false));
SendMessage(chatID, await Response(steamID, message).ConfigureAwait(false));
}
private void SendMessage(ulong steamID, string message) {
@@ -1223,7 +1384,7 @@ namespace ArchiSteamFarm {
return;
}
if (callback.PatronID != BotConfig.SteamMasterID) {
if (!IsMaster(callback.PatronID)) {
return;
}
@@ -1239,7 +1400,7 @@ namespace ArchiSteamFarm {
return;
}
if (callback.ChatterID != BotConfig.SteamMasterID) {
if (!IsMaster(callback.ChatterID)) {
return;
}
@@ -1248,7 +1409,7 @@ namespace ArchiSteamFarm {
SteamFriends.LeaveChat(callback.ChatRoomID);
break;
default:
await HandleMessage(callback.ChatRoomID, callback.Message).ConfigureAwait(false);
await HandleMessage(callback.ChatRoomID, callback.ChatterID, callback.Message).ConfigureAwait(false);
break;
}
}
@@ -1268,9 +1429,10 @@ namespace ArchiSteamFarm {
// TODO: Accept clan invites from master?
break;
default:
if (friend.SteamID == BotConfig.SteamMasterID) {
SteamFriends.AddFriend(friend.SteamID);
if (!IsMaster(friend.SteamID)) {
break;
}
SteamFriends.AddFriend(friend.SteamID);
break;
}
}
@@ -1285,11 +1447,7 @@ namespace ArchiSteamFarm {
return;
}
if (callback.Sender != BotConfig.SteamMasterID) {
return;
}
await HandleMessage(callback.Sender, callback.Message).ConfigureAwait(false);
await HandleMessage(callback.Sender, callback.Sender, callback.Message).ConfigureAwait(false);
}
private async void OnFriendMsgHistory(SteamFriends.FriendMsgHistoryCallback callback) {
@@ -1301,7 +1459,7 @@ namespace ArchiSteamFarm {
return;
}
if (callback.SteamID != BotConfig.SteamMasterID) {
if (!IsMaster(callback.SteamID)) {
return;
}
@@ -1323,7 +1481,7 @@ namespace ArchiSteamFarm {
}
// Handle the message
await HandleMessage(callback.SteamID, lastMessage.Message).ConfigureAwait(false);
await HandleMessage(callback.SteamID, callback.SteamID, lastMessage.Message).ConfigureAwait(false);
}
private void OnAccountInfo(SteamUser.AccountInfoCallback callback) {
@@ -1379,19 +1537,18 @@ namespace ArchiSteamFarm {
Program.GlobalDatabase.CellID = callback.CellID;
}
// Support and convert SDA files
string maFilePath = Path.Combine(Program.ConfigDirectory, callback.ClientSteamID.ConvertToUInt64() + ".maFile");
if (BotDatabase.SteamGuardAccount == null && File.Exists(maFilePath)) {
ImportAuthenticator(maFilePath);
}
if (BotConfig.UseAsfAsMobileAuthenticator && TwoFactorAuth == null && BotDatabase.SteamGuardAccount == null) {
LinkMobileAuthenticator();
if (BotDatabase.SteamGuardAccount == null) {
// Support and convert SDA files
string maFilePath = Path.Combine(Program.ConfigDirectory, callback.ClientSteamID.ConvertToUInt64() + ".maFile");
if (File.Exists(maFilePath)) {
ImportAuthenticator(maFilePath);
} else if (TwoFactorAuth == null && BotConfig.UseAsfAsMobileAuthenticator) {
LinkMobileAuthenticator();
}
}
// Reset one-time-only access tokens
AuthCode = null;
TwoFactorAuth = null;
AuthCode = TwoFactorAuth = null;
ResetGamesPlayed();
@@ -1405,20 +1562,24 @@ namespace ArchiSteamFarm {
}
if (BotConfig.DismissInventoryNotifications) {
await ArchiWebHandler.MarkInventory().ConfigureAwait(false);
Task.Run(async () => await ArchiWebHandler.MarkInventory().ConfigureAwait(false)).Forget();
}
if (BotConfig.SteamMasterClanID != 0) {
await ArchiWebHandler.JoinClan(BotConfig.SteamMasterClanID).ConfigureAwait(false);
JoinMasterChat();
Task.Run(async () => {
await ArchiWebHandler.JoinClan(BotConfig.SteamMasterClanID).ConfigureAwait(false);
JoinMasterChat();
}).Forget();
}
if (Program.GlobalConfig.Statistics) {
await ArchiWebHandler.JoinClan(ArchiSCFarmGroup).ConfigureAwait(false);
SteamFriends.JoinChat(ArchiSCFarmGroup);
Task.Run(async () => {
await ArchiWebHandler.JoinClan(ArchiSCFarmGroup).ConfigureAwait(false);
SteamFriends.JoinChat(ArchiSCFarmGroup);
}).Forget();
}
Trading.CheckTrades();
Task.Run(() => Trading.CheckTrades()).Forget();
Task.Run(async () => await CardsFarmer.StartFarming().ConfigureAwait(false)).Forget();
break;

View File

@@ -57,10 +57,10 @@ namespace ArchiSteamFarm {
}
}
[JsonProperty(Required = Required.AllowNull)]
[JsonProperty]
private string _LoginKey;
[JsonProperty(Required = Required.AllowNull)]
[JsonProperty]
private SteamGuardAccount _SteamGuardAccount;
private string FilePath;

View File

@@ -26,6 +26,7 @@ using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Sockets;
namespace ArchiSteamFarm {
internal sealed class GlobalConfig {
@@ -47,6 +48,12 @@ namespace ArchiSteamFarm {
[JsonProperty(Required = Required.DisallowNull)]
internal EUpdateChannel UpdateChannel { get; private set; } = EUpdateChannel.Stable;
[JsonProperty(Required = Required.DisallowNull)]
internal ProtocolType SteamProtocol { get; private set; } = ProtocolType.Tcp;
[JsonProperty(Required = Required.DisallowNull)]
internal ulong SteamOwnerID { get; private set; } = 0;
[JsonProperty(Required = Required.DisallowNull)]
internal byte MaxFarmingTime { get; private set; } = 10;
@@ -77,6 +84,9 @@ namespace ArchiSteamFarm {
[JsonProperty(Required = Required.DisallowNull)]
internal ushort WCFPort { get; private set; } = 1242;
[JsonProperty(Required = Required.DisallowNull)]
internal bool LogToFile { get; private set; } = true;
[JsonProperty(Required = Required.DisallowNull)]
internal bool Statistics { get; private set; } = true;
@@ -101,6 +111,18 @@ namespace ArchiSteamFarm {
return null;
}
// SK2 supports only TCP and UDP steam protocols
// Make sure that user can't screw this up
switch (globalConfig.SteamProtocol) {
case ProtocolType.Tcp:
case ProtocolType.Udp:
break;
default:
Logging.LogGenericWarning("Configured SteamProtocol is invalid: " + globalConfig.SteamProtocol + ", default TCP protocol will be used instead");
globalConfig.SteamProtocol = ProtocolType.Tcp;
break;
}
return globalConfig;
}

View File

@@ -31,18 +31,18 @@ namespace ArchiSteamFarm {
internal static class Logging {
private static readonly object FileLock = new object();
internal static bool? LogToFile { get; set; } = null;
private static bool LogToFile = false;
internal static void Init() {
if (!LogToFile.HasValue) {
LogToFile = true;
}
LogToFile = Program.GlobalConfig.LogToFile;
lock (FileLock) {
try {
File.Delete(Program.LogFile);
} catch (Exception e) {
LogGenericException(e);
if (LogToFile) {
lock (FileLock) {
try {
File.Delete(Program.LogFile);
} catch (Exception e) {
LogGenericException(e);
}
}
}
}
@@ -123,7 +123,7 @@ namespace ArchiSteamFarm {
} catch { }
}
if (LogToFile.GetValueOrDefault()) {
if (LogToFile) {
lock (FileLock) {
try {
File.AppendAllText(Program.LogFile, loggedMessage);

View File

@@ -242,34 +242,15 @@ namespace ArchiSteamFarm {
Logging.LogGenericInfo("Update process is finished! ASF will now restart itself...");
await Utilities.SleepAsync(5000);
if (!Restart()) {
// Make sure that we won't try updating again in this case
if (AutoUpdatesTimer != null) {
AutoUpdatesTimer.Dispose();
AutoUpdatesTimer = null;
}
// Inform user about failure
Logging.LogGenericWarning("ASF could not restart itself, you may need to restart it manually!");
await Utilities.SleepAsync(5000);
}
Restart();
}
internal static void Exit(int exitCode = 0) {
Environment.Exit(exitCode);
}
internal static bool Restart() {
internal static void Restart() {
try {
if (Process.Start(ExecutableFile, string.Join(" ", Environment.GetCommandLineArgs().Skip(1))) != null) {
Exit();
return true;
} else {
return false;
}
Process.Start(ExecutableFile, string.Join(" ", Environment.GetCommandLineArgs().Skip(1)));
Environment.Exit(0);
} catch (Exception e) {
Logging.LogGenericException(e);
return false;
}
}
@@ -343,6 +324,7 @@ namespace ArchiSteamFarm {
}
Logging.LogGenericInfo("No bots are running, exiting");
Thread.Sleep(5000);
ShutdownResetEvent.Set();
}
@@ -351,14 +333,14 @@ namespace ArchiSteamFarm {
if (GlobalConfig == null) {
Logging.LogGenericError("Global config could not be loaded, please make sure that ASF.json exists and is valid!");
Thread.Sleep(5000);
Exit(1);
Environment.Exit(1);
}
GlobalDatabase = GlobalDatabase.Load();
if (GlobalDatabase == null) {
Logging.LogGenericError("Global database could not be loaded!");
Thread.Sleep(5000);
Exit(1);
Environment.Exit(1);
}
ArchiWebHandler.Init();
@@ -371,13 +353,6 @@ namespace ArchiSteamFarm {
switch (arg) {
case "--client":
Mode = EMode.Client;
Logging.LogToFile = false;
break;
case "--log":
Logging.LogToFile = true;
break;
case "--no-log":
Logging.LogToFile = false;
break;
case "--server":
Mode = EMode.Server;
@@ -424,7 +399,7 @@ namespace ArchiSteamFarm {
Logging.LogGenericException(args.Exception);
}
private static void Main(string[] args) {
private static void Init(string[] args) {
AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
TaskScheduler.UnobservedTaskException += UnobservedTaskExceptionHandler;
@@ -451,11 +426,11 @@ namespace ArchiSteamFarm {
// If debugging is on, we prepare debug directory prior to running
if (GlobalConfig.Debug) {
if (Directory.Exists(Program.DebugDirectory)) {
Directory.Delete(Program.DebugDirectory, true);
if (Directory.Exists(DebugDirectory)) {
Directory.Delete(DebugDirectory, true);
Thread.Sleep(1000); // Dirty workaround giving Windows some time to sync
}
Directory.CreateDirectory(Program.DebugDirectory);
Directory.CreateDirectory(DebugDirectory);
SteamKit2.DebugLog.AddListener(new Debugging.DebugListener(Path.Combine(Program.DebugDirectory, "debug.txt")));
SteamKit2.DebugLog.Enabled = true;
@@ -475,7 +450,7 @@ namespace ArchiSteamFarm {
if (!Directory.Exists(ConfigDirectory)) {
Logging.LogGenericError("Config directory doesn't exist!");
Thread.Sleep(5000);
Exit(1);
Environment.Exit(1);
}
CheckForUpdate().Wait();
@@ -483,6 +458,8 @@ namespace ArchiSteamFarm {
// Before attempting to connect, initialize our list of CMs
Bot.RefreshCMs(GlobalDatabase.CellID).Wait();
bool isRunning = false;
foreach (var configFile in Directory.EnumerateFiles(ConfigDirectory, "*.json")) {
string botName = Path.GetFileNameWithoutExtension(configFile);
if (botName.Equals(ASF)) {
@@ -490,7 +467,9 @@ namespace ArchiSteamFarm {
}
Bot bot = new Bot(botName);
if (bot.BotConfig == null || !bot.BotConfig.Enabled) {
if (bot.BotConfig != null && bot.BotConfig.Enabled) {
isRunning = true;
} else {
Logging.LogGenericInfo("Not starting this instance because it's disabled in config file", botName);
}
}
@@ -500,23 +479,28 @@ namespace ArchiSteamFarm {
string botName = Path.GetFileNameWithoutExtension(configFile);
Logging.LogGenericWarning("Found legacy " + botName + ".xml config file, it will now be converted to new ASF V2.0 format!");
Bot bot = new Bot(botName);
if (bot.BotConfig == null || !bot.BotConfig.Enabled) {
if (bot.BotConfig != null && bot.BotConfig.Enabled) {
isRunning = true;
} else {
Logging.LogGenericInfo("Not starting this instance because it's disabled in config file", botName);
}
}
// CONVERSION END
// Check if we got any bots running
OnBotShutdown();
if (!isRunning) {
OnBotShutdown();
}
}
private static void Main(string[] args) {
Init(args);
// Wait for signal to shutdown
ShutdownResetEvent.WaitOne();
// We got a signal to shutdown, consider giving user some time to read the message
Thread.Sleep(5000);
// This is over, cleanup only now
WCF.StopServer();
// We got a signal to shutdown
Environment.Exit(0);
}
}
}

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
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.1.1")]
[assembly: AssemblyFileVersion("2.0.1.1")]
[assembly: AssemblyVersion("2.0.1.5")]
[assembly: AssemblyFileVersion("2.0.1.5")]

View File

@@ -116,7 +116,7 @@ namespace ArchiSteamFarm {
Logging.LogGenericInfo("Received command: " + input);
string command = '!' + input;
string output = bot.HandleMessage(command).Result; // TODO: This should be asynchronous
string output = bot.Response(Program.GlobalConfig.SteamOwnerID, command).Result; // TODO: This should be asynchronous
Logging.LogGenericInfo("Answered to command: " + input + " with: " + output);
return output;

View File

@@ -2,6 +2,8 @@
"Debug": false,
"AutoUpdates": true,
"UpdateChannel": 1,
"SteamProtocol": 6,
"SteamOwnerID": 0,
"MaxFarmingTime": 10,
"IdleFarmingPeriod": 3,
"FarmingDelay": 5,
@@ -12,6 +14,7 @@
"HttpTimeout": 60,
"WCFHostname": "localhost",
"WCFPort": 1242,
"LogToFile": true,
"Statistics": true,
"HackIgnoreMachineID": false,
"Blacklist": [

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
</configuration>

View File

@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C3F6FE68-5E75-415E-BEA1-1E7C16D6A433}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ConfigGenerator</RootNamespace>
<AssemblyName>ConfigGenerator</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>
</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="EnhancedPropertyGrid.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Debugging.cs" />
<Compile Include="GlobalConfig.cs" />
<Compile Include="GlobalConfigPage.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Logging.cs" />
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="GlobalConfigPage.resx">
<DependentUpon>GlobalConfigPage.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent Condition=" '$(OS)' != 'Unix' AND '$(ConfigurationName)' == 'Release' ">
mkdir "$(SolutionDir)out" "$(SolutionDir)out\config"
"$(SolutionDir)tools\ILRepack.exe" /ndebug /internalize /parallel /targetplatform:v4 /wildcards /out:"$(SolutionDir)out\ASF-GUI.exe" "$(TargetDir)$(TargetName).exe" "$(TargetDir)*.dll"
del "$(SolutionDir)out\ASF-GUI.exe.config"
</PostBuildEvent>
<PostBuildEvent Condition=" '$(OS)' == 'Unix' AND '$(ConfigurationName)' == 'Release' ">
mkdir -p "$(SolutionDir)out" "$(SolutionDir)out/config"
mono -O=all "$(SolutionDir)tools/ILRepack.exe" /ndebug /internalize /parallel /targetplatform:v4 /wildcards /out:"$(SolutionDir)out/ASF-GUI.exe" "$(TargetDir)$(TargetName).exe" "$(TargetDir)*.dll"
rm "$(SolutionDir)out/ASF-GUI.exe.config"
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,38 @@
/*
_ _ _ ____ _ _____
/ \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
/ _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
/ ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
/_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
Copyright 2015-2016 Łukasz "JustArchi" Domeradzki
Contact: JustArchi@JustArchi.net
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using System;
using System.IO;
namespace ConfigGenerator {
internal static class Debugging {
#if DEBUG
internal static readonly bool IsDebugBuild = true;
#else
internal static readonly bool IsDebugBuild = false;
#endif
internal static bool IsReleaseBuild => !IsDebugBuild;
}
}

View File

@@ -0,0 +1,20 @@
using System.Windows.Forms;
namespace ConfigGenerator {
internal sealed class EnhancedPropertyGrid : PropertyGrid {
private GlobalConfig GlobalConfig;
internal EnhancedPropertyGrid(GlobalConfig globalConfig) : base() {
if (globalConfig == null) {
return;
}
GlobalConfig = globalConfig;
SelectedObject = globalConfig;
Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
Dock = DockStyle.Fill;
HelpVisible = false;
ToolbarVisible = false;
}
}
}

View File

@@ -0,0 +1,154 @@
/*
_ _ _ ____ _ _____
/ \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
/ _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
/ ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
/_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
Copyright 2015-2016 Łukasz "JustArchi" Domeradzki
Contact: JustArchi@JustArchi.net
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Sockets;
namespace ConfigGenerator {
internal sealed class GlobalConfig {
internal enum EUpdateChannel : byte {
Unknown,
Stable,
Experimental
}
// This is hardcoded blacklist which should not be possible to change
internal static readonly HashSet<uint> GlobalBlacklist = new HashSet<uint> { 267420, 303700, 335590, 368020, 425280 };
[JsonProperty(Required = Required.DisallowNull)]
public bool Debug { get; set; } = false;
[JsonProperty(Required = Required.DisallowNull)]
public bool AutoUpdates { get; set; } = true;
[JsonProperty(Required = Required.DisallowNull)]
public EUpdateChannel UpdateChannel { get; set; } = EUpdateChannel.Stable;
[JsonProperty(Required = Required.DisallowNull)]
public ProtocolType SteamProtocol { get; set; } = ProtocolType.Tcp;
[JsonProperty(Required = Required.DisallowNull)]
public ulong SteamOwnerID { get; set; } = 0;
[JsonProperty(Required = Required.DisallowNull)]
public byte MaxFarmingTime { get; set; } = 10;
[JsonProperty(Required = Required.DisallowNull)]
public byte IdleFarmingPeriod { get; set; } = 3;
[JsonProperty(Required = Required.DisallowNull)]
public byte FarmingDelay { get; set; } = 5;
[JsonProperty(Required = Required.DisallowNull)]
public byte AccountPlayingDelay { get; set; } = 5;
[JsonProperty(Required = Required.DisallowNull)]
public byte LoginLimiterDelay { get; set; } = 7;
[JsonProperty(Required = Required.DisallowNull)]
public byte InventoryLimiterDelay { get; set; } = 3;
[JsonProperty(Required = Required.DisallowNull)]
public bool ForceHttp { get; set; } = false;
[JsonProperty(Required = Required.DisallowNull)]
public byte HttpTimeout { get; set; } = 60;
[JsonProperty(Required = Required.DisallowNull)]
public string WCFHostname { get; set; } = "localhost";
[JsonProperty(Required = Required.DisallowNull)]
public ushort WCFPort { get; set; } = 1242;
[JsonProperty(Required = Required.DisallowNull)]
public bool LogToFile { get; set; } = true;
[JsonProperty(Required = Required.DisallowNull)]
public bool Statistics { get; set; } = true;
// TODO: Please remove me immediately after https://github.com/SteamRE/SteamKit/issues/254 gets fixed
[JsonProperty(Required = Required.DisallowNull)]
public bool HackIgnoreMachineID { get; set; } = false;
[JsonProperty(Required = Required.DisallowNull)]
public List<uint> Blacklist { get; set; } = new List<uint>();
private string FilePath;
internal static GlobalConfig Load(string filePath) {
if (string.IsNullOrEmpty(filePath)) {
return null;
}
if (!File.Exists(filePath)) {
return new GlobalConfig(filePath);
}
GlobalConfig globalConfig;
try {
globalConfig = JsonConvert.DeserializeObject<GlobalConfig>(File.ReadAllText(filePath));
} catch (Exception e) {
Logging.LogGenericException(e);
return null;
}
globalConfig.FilePath = filePath;
// SK2 supports only TCP and UDP steam protocols
// Make sure that user can't screw this up
switch (globalConfig.SteamProtocol) {
case ProtocolType.Tcp:
case ProtocolType.Udp:
break;
default:
Logging.LogGenericWarning("Configured SteamProtocol is invalid: " + globalConfig.SteamProtocol + ", default TCP protocol will be used instead");
globalConfig.SteamProtocol = ProtocolType.Tcp;
break;
}
return globalConfig;
}
internal void Save() {
lock (FilePath) {
try {
File.WriteAllText(FilePath, JsonConvert.SerializeObject(this, Formatting.Indented));
} catch (Exception e) {
Logging.LogGenericException(e);
}
}
}
// This constructor is used only by deserializer
private GlobalConfig() { }
private GlobalConfig(string filePath) {
FilePath = filePath;
Blacklist.AddRange(GlobalBlacklist);
}
}
}

View File

@@ -0,0 +1,51 @@
using System.IO;
using System.Windows.Forms;
namespace ConfigGenerator {
internal sealed class GlobalConfigPage : TabPage {
internal GlobalConfig GlobalConfig { get; private set; }
private EnhancedPropertyGrid EnhancedPropertyGrid;
internal GlobalConfigPage(string filePath) : base() {
if (string.IsNullOrEmpty(filePath)) {
return;
}
GlobalConfig = GlobalConfig.Load(filePath);
if (GlobalConfig == null) {
Logging.LogNullError("GlobalConfig");
return;
}
Text = Path.GetFileNameWithoutExtension(filePath);
EnhancedPropertyGrid = new EnhancedPropertyGrid(GlobalConfig);
Controls.Add(EnhancedPropertyGrid);
Panel panel = new Panel() {
Height = 20,
Dock = DockStyle.Bottom,
};
panel.Controls.Add(new Button() {
Dock = DockStyle.Left,
Text = "Load"
});
panel.Controls.Add(new Button() {
Dock = DockStyle.Right,
Text = "Save"
});
Controls.Add(panel);
}
private void InitializeComponent() {
this.SuspendLayout();
this.ResumeLayout(false);
}
}
}

View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>

View File

@@ -0,0 +1,93 @@
/*
_ _ _ ____ _ _____
/ \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
/ _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
/ ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
/_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
Copyright 2015-2016 Łukasz "JustArchi" Domeradzki
Contact: JustArchi@JustArchi.net
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
namespace ConfigGenerator {
internal static class Logging {
internal static void LogGenericWTF(string message, [CallerMemberName] string previousMethodName = "") {
if (string.IsNullOrEmpty(message)) {
return;
}
MessageBox.Show(previousMethodName + "() " + message, "WTF", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
internal static void LogGenericError(string message, [CallerMemberName] string previousMethodName = "") {
if (string.IsNullOrEmpty(message)) {
return;
}
MessageBox.Show(previousMethodName + "() " + message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
internal static void LogGenericException(Exception exception, [CallerMemberName] string previousMethodName = "") {
if (exception == null) {
return;
}
MessageBox.Show(previousMethodName + "() " + exception.Message + Environment.NewLine + exception.StackTrace, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
if (exception.InnerException != null) {
LogGenericException(exception.InnerException, previousMethodName);
}
}
internal static void LogGenericWarning(string message, [CallerMemberName] string previousMethodName = "") {
if (string.IsNullOrEmpty(message)) {
return;
}
MessageBox.Show(previousMethodName + "() " + message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
internal static void LogGenericInfo(string message, [CallerMemberName] string previousMethodName = "") {
if (string.IsNullOrEmpty(message)) {
return;
}
MessageBox.Show(previousMethodName + "() " + message, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
internal static void LogNullError(string nullObjectName, [CallerMemberName] string previousMethodName = "") {
if (string.IsNullOrEmpty(nullObjectName)) {
return;
}
LogGenericError(nullObjectName + " is null!", previousMethodName);
}
[Conditional("DEBUG")]
internal static void LogGenericDebug(string message, [CallerMemberName] string previousMethodName = "") {
if (string.IsNullOrEmpty(message)) {
return;
}
MessageBox.Show(previousMethodName + "() " + message, "Debug", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}

135
ConfigGenerator/MainForm.Designer.cs generated Normal file
View File

@@ -0,0 +1,135 @@
namespace ConfigGenerator {
partial class MainForm {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.MenuPanel = new System.Windows.Forms.MenuStrip();
this.FileMenu = new System.Windows.Forms.ToolStripMenuItem();
this.FileMenuHelp = new System.Windows.Forms.ToolStripMenuItem();
this.BotMenu = new System.Windows.Forms.ToolStripMenuItem();
this.BotMenuNew = new System.Windows.Forms.ToolStripMenuItem();
this.BotMenuDelete = new System.Windows.Forms.ToolStripMenuItem();
this.MainTab = new System.Windows.Forms.TabControl();
this.FileMenuExit = new System.Windows.Forms.ToolStripMenuItem();
this.MenuPanel.SuspendLayout();
this.SuspendLayout();
//
// MenuPanel
//
this.MenuPanel.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.FileMenu,
this.BotMenu});
this.MenuPanel.Location = new System.Drawing.Point(0, 0);
this.MenuPanel.Name = "MenuPanel";
this.MenuPanel.Size = new System.Drawing.Size(784, 24);
this.MenuPanel.TabIndex = 0;
this.MenuPanel.Text = "menuStrip1";
//
// FileMenu
//
this.FileMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.FileMenuHelp,
this.FileMenuExit});
this.FileMenu.Name = "FileMenu";
this.FileMenu.Size = new System.Drawing.Size(37, 20);
this.FileMenu.Text = "File";
//
// FileMenuHelp
//
this.FileMenuHelp.Name = "FileMenuHelp";
this.FileMenuHelp.Size = new System.Drawing.Size(152, 22);
this.FileMenuHelp.Text = "Help";
this.FileMenuHelp.Click += new System.EventHandler(this.FileMenuHelp_Click);
//
// BotMenu
//
this.BotMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.BotMenuNew,
this.BotMenuDelete});
this.BotMenu.Name = "BotMenu";
this.BotMenu.Size = new System.Drawing.Size(37, 20);
this.BotMenu.Text = "Bot";
//
// BotMenuNew
//
this.BotMenuNew.Name = "BotMenuNew";
this.BotMenuNew.Size = new System.Drawing.Size(107, 22);
this.BotMenuNew.Text = "New";
this.BotMenuNew.Click += new System.EventHandler(this.BotMenuNew_Click);
//
// BotMenuDelete
//
this.BotMenuDelete.Name = "BotMenuDelete";
this.BotMenuDelete.Size = new System.Drawing.Size(107, 22);
this.BotMenuDelete.Text = "Delete";
this.BotMenuDelete.Click += new System.EventHandler(this.BotMenuDelete_Click);
//
// MainTab
//
this.MainTab.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.MainTab.Location = new System.Drawing.Point(12, 27);
this.MainTab.Name = "MainTab";
this.MainTab.SelectedIndex = 0;
this.MainTab.Size = new System.Drawing.Size(760, 522);
this.MainTab.TabIndex = 1;
//
// FileMenuExit
//
this.FileMenuExit.Name = "FileMenuExit";
this.FileMenuExit.Size = new System.Drawing.Size(152, 22);
this.FileMenuExit.Text = "Exit";
this.FileMenuExit.Click += new System.EventHandler(this.FileMenuExit_Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(784, 561);
this.Controls.Add(this.MainTab);
this.Controls.Add(this.MenuPanel);
this.MainMenuStrip = this.MenuPanel;
this.Name = "MainForm";
this.Text = "Form1";
this.Load += new System.EventHandler(this.MainForm_Load);
this.MenuPanel.ResumeLayout(false);
this.MenuPanel.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip MenuPanel;
private System.Windows.Forms.ToolStripMenuItem BotMenu;
private System.Windows.Forms.ToolStripMenuItem BotMenuNew;
private System.Windows.Forms.ToolStripMenuItem BotMenuDelete;
private System.Windows.Forms.TabControl MainTab;
private System.Windows.Forms.ToolStripMenuItem FileMenu;
private System.Windows.Forms.ToolStripMenuItem FileMenuHelp;
private System.Windows.Forms.ToolStripMenuItem FileMenuExit;
}
}

View File

@@ -0,0 +1,52 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
namespace ConfigGenerator {
public partial class MainForm : Form {
public MainForm() {
InitializeComponent();
}
private void BotMenuNew_Click(object sender, EventArgs e) {
if (sender == null || e == null) {
return;
}
Logging.LogGenericError("This option is not ready yet!");
}
private void BotMenuDelete_Click(object sender, EventArgs e) {
if (sender == null || e == null) {
return;
}
Logging.LogGenericError("This option is not ready yet!");
}
private void FileMenuHelp_Click(object sender, EventArgs e) {
if (sender == null || e == null) {
return;
}
Process.Start("https://github.com/JustArchi/ArchiSteamFarm/wiki/Configuration");
}
private void FileMenuExit_Click(object sender, EventArgs e) {
if (sender == null || e == null) {
return;
}
Application.Exit();
}
private void MainForm_Load(object sender, EventArgs e) {
if (sender == null || e == null) {
return;
}
MainTab.TabPages.Add(new GlobalConfigPage(Path.Combine(Program.ConfigDirectory, Program.GlobalConfigFile)));
}
}
}

View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="MenuPanel.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@@ -0,0 +1,77 @@
using System;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ConfigGenerator {
internal static class Program {
internal const string ASF = "ASF";
internal const string ConfigDirectory = "config";
internal const string GlobalConfigFile = ASF + ".json";
private const string ASFDirectory = "ArchiSteamFarm";
private static readonly Assembly Assembly = Assembly.GetExecutingAssembly();
private static readonly string ExecutableFile = Assembly.Location;
private static readonly string ExecutableName = Path.GetFileName(ExecutableFile);
private static readonly string ExecutableDirectory = Path.GetDirectoryName(ExecutableFile);
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
private static void Main() {
Init();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
private static void Init() {
AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
TaskScheduler.UnobservedTaskException += UnobservedTaskExceptionHandler;
Directory.SetCurrentDirectory(ExecutableDirectory);
// Allow loading configs from source tree if it's a debug build
if (Debugging.IsDebugBuild) {
// Common structure is bin/(x64/)Debug/ArchiSteamFarm.exe, so we allow up to 4 directories up
for (byte i = 0; i < 4; i++) {
Directory.SetCurrentDirectory("..");
if (Directory.Exists(ASFDirectory)) {
Directory.SetCurrentDirectory(ASFDirectory);
break;
}
}
// If config directory doesn't exist after our adjustment, abort all of that
if (!Directory.Exists(ConfigDirectory)) {
Directory.SetCurrentDirectory(ExecutableDirectory);
}
}
if (!Directory.Exists(ConfigDirectory)) {
Logging.LogGenericError("Config directory could not be found!");
Application.Exit();
}
}
private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args) {
if (sender == null || args == null) {
return;
}
Logging.LogGenericException((Exception) args.ExceptionObject);
}
private static void UnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs args) {
if (sender == null || args == null) {
return;
}
Logging.LogGenericException(args.Exception);
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ConfigGenerator")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConfigGenerator")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("c3f6fe68-5e75-415e-bea1-1e7c16d6a433")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,62 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ConfigGenerator.Properties {
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if ((resourceMan == null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ConfigGenerator.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ConfigGenerator.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings) (global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net451" />
</packages>