internal GiveawayForm(SMAForm initializer, WebBot bot)
        {
            this.bot             = bot;
            this.initializerForm = initializer;

            InitializeComponent();
        }
        public BotSettings(SMAForm mainForm, string BotName = "")
        {
            _mainForm = mainForm;
            _botName  = BotName;
            if (string.IsNullOrEmpty(_botName))
            {
                GetBotname();
            }

            InitializeComponent();
            Init();
        }
Beispiel #3
0
        internal Bot(string botName, SMAForm initializer)
        {
            if (string.IsNullOrEmpty(botName))
            {
                return;
            }
            if (initializer == null)
            {
                return;
            }
            InitializerForm = initializer;
            BotName         = botName;
            BotPath         = Path.Combine(SMAForm.ConfigDirectory, BotName);

            AlreadyOwnedGames = new List <uint>();
            CurrentFarming    = new List <Game>();
            Commands          = new Dictionary <string, MyDelegate>()
            {
                { CommandsKeys[0], ChangeNickname },
                { CommandsKeys[1], Sellcards },
                { CommandsKeys[2], WatchBroadcastCommand },
                { CommandsKeys[3], UnWatchBroadcastCommand },
                { CommandsKeys[4], BuyApps },
                { CommandsKeys[5], PlayDota },
            };

            logging         = new Logging();
            BotConfig       = new BotConfig(BotPath);
            steamClient     = new SteamClient();
            steamUser       = steamClient.GetHandler <SteamUser>();
            steamFriends    = steamClient.GetHandler <SteamFriends>();
            steamApps       = steamClient.GetHandler <SteamApps>();
            callbackManager = new CallbackManager(steamClient);
            webBot          = new WebBot(this);
            customHandler   = new CustomHandler();

            BotConfig = BotConfig.Load();
            timer     = new System.Threading.Timer(e => Farm());

            steamClient.AddHandler(customHandler);
            callbackManager.Subscribe <SteamClient.ConnectedCallback>(OnConnected);
            callbackManager.Subscribe <SteamClient.DisconnectedCallback>(OnDisconnected);

            callbackManager.Subscribe <SteamUser.LoggedOnCallback>(OnLoggedOn);
            callbackManager.Subscribe <SteamUser.LoggedOffCallback>(OnLoggedOff);
            callbackManager.Subscribe <SteamUser.UpdateMachineAuthCallback>(OnMachinAuth);
            callbackManager.Subscribe <SteamUser.LoginKeyCallback>(OnLoginKey);
            callbackManager.Subscribe <SteamUser.AccountInfoCallback>(OnAccountInfo);
            callbackManager.Subscribe <SteamUser.WalletInfoCallback>(OnWalletInfo);

            //callbackManager.Subscribe<SteamFriends.FriendMsgCallback>(OnFriendMessage); Dont handle messages
            //callbackManager.Subscribe<SteamFriends.FriendsListCallback>(OnFriendList); Dont add everybody

            callbackManager.Subscribe <SteamApps.GuestPassListCallback>(OnGuestPass);
            callbackManager.Subscribe <SteamApps.FreeLicenseCallback>(OnFreeLicense);

            // TODO: Join to game aways on sites

            if (Bots.ContainsKey(BotName))
            {
                return;
            }
            Bots[BotName] = this;
            if (ProgramConfig == null)
            {
                ProgramConfig = new ProgramConfig();
                ProgramConfig = ProgramConfig.Load();
            }
            SteamClient.Servers.CellID             = BotConfig.CellID;
            SteamClient.Servers.ServerListProvider = new SteamKit2.Discovery.FileStorageServerListProvider(SMAForm.ServerList);
            NetDebug();

            SteamCheckCancel = new CancellationTokenSource();

            if (BotConfig.Enabled)
            {
                Start().Forget();
            }
            else
            {
                Status      = StatusEnum.Disabled;
                initialized = true;
            }
        }