|
|
|
|
@@ -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) {
|
|
|
|
|
@@ -179,10 +177,12 @@ 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
|
|
|
|
|
@@ -252,7 +252,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Start
|
|
|
|
|
Start().Wait();
|
|
|
|
|
Task.Run(async () => await Start().ConfigureAwait(false)).Forget();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal bool IsMaster(ulong steamID) {
|
|
|
|
|
@@ -312,6 +312,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
if (farmedSomething && BotConfig.SendOnFarmingFinished) {
|
|
|
|
|
await ResponseSendTrade(BotConfig.SteamMasterID).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (BotConfig.ShutdownOnFarmingFinished) {
|
|
|
|
|
await Shutdown().ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
@@ -353,7 +354,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
case "!update":
|
|
|
|
|
return await ResponseUpdate(steamID).ConfigureAwait(false);
|
|
|
|
|
default:
|
|
|
|
|
return "Unrecognized command: " + message;
|
|
|
|
|
return ResponseUnknown(steamID);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
string[] args = message.Split(' ');
|
|
|
|
|
@@ -399,7 +400,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
case "!stop":
|
|
|
|
|
return await ResponseStop(steamID, args[1]).ConfigureAwait(false);
|
|
|
|
|
default:
|
|
|
|
|
return "Unrecognized command: " + args[0];
|
|
|
|
|
return ResponseUnknown(steamID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -511,7 +512,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsMaster(steamID)) {
|
|
|
|
|
return "ERROR: Not authorized!";
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CardsFarmer.CurrentGamesFarming.Count > 0) {
|
|
|
|
|
@@ -540,7 +541,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsOwner(steamID)) {
|
|
|
|
|
return "ERROR: Not authorized!";
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StringBuilder result = new StringBuilder(Environment.NewLine);
|
|
|
|
|
@@ -565,7 +566,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsMaster(steamID)) {
|
|
|
|
|
return "ERROR: Not authorized!";
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (BotConfig.SteamMasterID == 0) {
|
|
|
|
|
@@ -606,7 +607,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsMaster(steamID)) {
|
|
|
|
|
return "ERROR: Not authorized!";
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (BotDatabase.SteamGuardAccount == null) {
|
|
|
|
|
@@ -636,7 +637,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsMaster(steamID)) {
|
|
|
|
|
return "ERROR: Not authorized!";
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (BotDatabase.SteamGuardAccount == null) {
|
|
|
|
|
@@ -669,7 +670,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsMaster(steamID)) {
|
|
|
|
|
return "ERROR: Not authorized!";
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (BotDatabase.SteamGuardAccount == null) {
|
|
|
|
|
@@ -699,7 +700,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsOwner(steamID)) {
|
|
|
|
|
return "ERROR: Not authorized!";
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Program.Exit();
|
|
|
|
|
@@ -712,7 +713,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsMaster(steamID)) {
|
|
|
|
|
return "ERROR: Not authorized!";
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await CardsFarmer.RestartFarming().ConfigureAwait(false);
|
|
|
|
|
@@ -738,7 +739,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsMaster(steamID)) {
|
|
|
|
|
return "ERROR: Not authorized!";
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StringBuilder response = new StringBuilder();
|
|
|
|
|
@@ -896,7 +897,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsOwner(steamID)) {
|
|
|
|
|
return "ERROR: Not authorized!";
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (Bot bot in Bots.Values) {
|
|
|
|
|
@@ -912,7 +913,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsOwner(steamID)) {
|
|
|
|
|
return "ERROR: Not authorized!";
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Program.Restart();
|
|
|
|
|
@@ -925,7 +926,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsMaster(steamID)) {
|
|
|
|
|
return "ERROR: Not authorized!";
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StringBuilder result = new StringBuilder();
|
|
|
|
|
@@ -978,7 +979,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsMaster(steamID)) {
|
|
|
|
|
return "ERROR: Not authorized!";
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Dictionary<uint, string> ownedGames = await ArchiWebHandler.GetOwnedGames().ConfigureAwait(false);
|
|
|
|
|
@@ -1034,7 +1035,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsMaster(steamID)) {
|
|
|
|
|
return "ERROR: Not authorized!";
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (gameIDs.Contains(0)) {
|
|
|
|
|
@@ -1083,7 +1084,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsMaster(steamID)) {
|
|
|
|
|
return "ERROR: Not authorized!";
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (KeepRunning) {
|
|
|
|
|
@@ -1113,7 +1114,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsMaster(steamID)) {
|
|
|
|
|
return "ERROR: Not authorized!";
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!KeepRunning) {
|
|
|
|
|
@@ -1137,13 +1138,25 @@ namespace ArchiSteamFarm {
|
|
|
|
|
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 "ERROR: Not authorized!";
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await Program.CheckForUpdate().ConfigureAwait(false);
|
|
|
|
|
@@ -1157,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 Response(steamID, message).ConfigureAwait(false));
|
|
|
|
|
SendMessage(chatID, await Response(steamID, message).ConfigureAwait(false));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SendMessage(ulong steamID, string message) {
|
|
|
|
|
@@ -1396,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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -1434,11 +1447,7 @@ namespace ArchiSteamFarm {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsMaster(callback.Sender)) {
|
|
|
|
|
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) {
|
|
|
|
|
@@ -1472,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) {
|
|
|
|
|
@@ -1528,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();
|
|
|
|
|
|
|
|
|
|
@@ -1554,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;
|
|
|
|
|
|