diff --git a/ArchiSteamFarm/ArchiWebHandler.cs b/ArchiSteamFarm/ArchiWebHandler.cs index 7ddef628f347d..f8bbdc668dfac 100644 --- a/ArchiSteamFarm/ArchiWebHandler.cs +++ b/ArchiSteamFarm/ArchiWebHandler.cs @@ -34,13 +34,14 @@ limitations under the License. namespace ArchiSteamFarm { internal class ArchiWebHandler { - private const int Timeout = 1000 * 15; // In miliseconds + private const int Timeout = 1000 * 30; // In miliseconds + private readonly Bot Bot; private readonly string ApiKey; + private readonly Dictionary SteamCookieDictionary = new Dictionary(); private ulong SteamID; private string VanityURL; - private readonly Dictionary SteamCookieDictionary = new Dictionary(); // This is required because home_process request must be done on final URL private string GetHomeProcess() { diff --git a/ArchiSteamFarm/Bot.cs b/ArchiSteamFarm/Bot.cs index c7a835fc0fcca..a5443dae72f26 100755 --- a/ArchiSteamFarm/Bot.cs +++ b/ArchiSteamFarm/Bot.cs @@ -37,14 +37,13 @@ internal class Bot { private static readonly ConcurrentDictionary Bots = new ConcurrentDictionary(); - private readonly string ConfigFile; - private readonly string SentryFile; + private readonly string ConfigFile, SentryFile; + + internal readonly string BotName; private bool IsRunning = false; private string AuthCode, TwoFactorAuth; - internal readonly string BotName; - internal ArchiHandler ArchiHandler { get; private set; } internal ArchiWebHandler ArchiWebHandler { get; private set; } internal CallbackManager CallbackManager { get; private set; } @@ -112,7 +111,6 @@ internal Bot(string botName) { SteamFriends = SteamClient.GetHandler(); CallbackManager.Subscribe(OnFriendsList); CallbackManager.Subscribe(OnFriendMsg); - CallbackManager.Subscribe(OnPersonaState); SteamUser = SteamClient.GetHandler(); CallbackManager.Subscribe(OnAccountInfo); @@ -399,7 +397,7 @@ private void OnFriendsList(SteamFriends.FriendsListCallback callback) { SteamID steamID = friend.SteamID; switch (steamID.AccountType) { case EAccountType.Clan: - //ArchiHandler.AcceptClanInvite(steamID); + ArchiHandler.DeclineClanInvite(steamID); break; default: if (steamID == SteamMasterID) { @@ -446,6 +444,7 @@ private async void OnFriendMsg(SteamFriends.FriendMsgCallback callback) { await ShutdownAllBots().ConfigureAwait(false); break; case "!farm": + SendMessageToUser(steamID, "Please wait..."); await CardsFarmer.StartFarming().ConfigureAwait(false); SendMessageToUser(steamID, "Done!"); break; @@ -462,6 +461,9 @@ private async void OnFriendMsg(SteamFriends.FriendMsgCallback callback) { } else { string[] args = message.Split(' '); switch (args[0]) { + case "!redeem": + ArchiHandler.RedeemKey(args[1]); + break; case "!start": ResponseStart(steamID, args[1]); break; @@ -475,18 +477,6 @@ private async void OnFriendMsg(SteamFriends.FriendMsgCallback callback) { } } - private void OnPersonaState(SteamFriends.PersonaStateCallback callback) { - if (callback == null) { - return; - } - - SteamID steamID = callback.FriendID; - SteamID sourceSteamID = callback.SourceSteamID; - string steamNickname = callback.Name; - EPersonaState personaState = callback.State; - EClanRank clanRank = (EClanRank) callback.ClanRank; - } - private void OnAccountInfo(SteamUser.AccountInfoCallback callback) { if (callback == null) { return; diff --git a/ArchiSteamFarm/CMsgClientClanInviteAction.cs b/ArchiSteamFarm/CMsgClientClanInviteAction.cs index 7115c98f8c8a9..1b92feca8f813 100644 --- a/ArchiSteamFarm/CMsgClientClanInviteAction.cs +++ b/ArchiSteamFarm/CMsgClientClanInviteAction.cs @@ -27,28 +27,21 @@ limitations under the License. using System.IO; namespace ArchiSteamFarm { - /// - /// Message used to Accept or Decline a group(clan) invite. - /// internal sealed class CMsgClientClanInviteAction : ISteamSerializableMessage, ISteamSerializable { EMsg ISteamSerializableMessage.GetEMsg() { return EMsg.ClientAcknowledgeClanInvite; } - public CMsgClientClanInviteAction() { - } - - /// - /// Group invited to. - /// internal ulong GroupID = 0; - - /// - /// To accept or decline the invite. - /// internal bool AcceptInvite = true; + public CMsgClientClanInviteAction() { } + void ISteamSerializable.Serialize(Stream stream) { + if (stream == null) { + return; + } + try { BinaryWriter binaryWriter = new BinaryWriter(stream); binaryWriter.Write(GroupID); @@ -59,6 +52,10 @@ void ISteamSerializable.Serialize(Stream stream) { } void ISteamSerializable.Deserialize(Stream stream) { + if (stream == null) { + return; + } + try { BinaryReader binaryReader = new BinaryReader(stream); GroupID = binaryReader.ReadUInt64();