Exemplo n.º 1
0
 private void btn_bots_update_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(txt_steamAPI.Text))
     {
         MessageBox.Show("Error - Steam API Key is Null! Enter valid  Steam API key", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         Thread th = new Thread(() => Update_Bots_DB.Update_Bots());
         th.Start();
     }
 }
Exemplo n.º 2
0
        public static bool CheckGameOwnsOnBot(List <int> AppIDs, BotInfo bot)
        {
            if (bot.GamesHave != null)
            {
                foreach (var appid in AppIDs)
                {
                    if (bot.GamesHave.Contains(appid))
                    {
                        return(false);///ja tem algum dos jogos
                    }
                }
            }

            string URL = $"http://{Main._Main.txt_IPC.Text}:{Main._Main.txt_PORT.Text}/Api/Command";

            string       AppIDsString = string.Join(",", AppIDs.ToArray());
            Exec_Command comando      = new Exec_Command {
                Command = $"owns {bot.BotName} {AppIDsString}"
            };

            string json = JsonConvert.SerializeObject(comando);

            var http = (HttpWebRequest)WebRequest.Create(new Uri(URL));

            http.Accept          = "application/json";
            http.ContentType     = "application/json";
            http.Method          = "POST";
            http.PreAuthenticate = true;
            http.Headers.Add("Authentication", Main._Main.txt_passIPC.Text);

            ASCIIEncoding encoding = new ASCIIEncoding();

            Byte[] bytes = encoding.GetBytes(json);

            Stream newStream = http.GetRequestStream();

            newStream.Write(bytes, 0, bytes.Length);
            newStream.Close();

            var response = http.GetResponse();

            var stream  = response.GetResponseStream();
            var sr      = new StreamReader(stream);
            var content = sr.ReadToEnd();

            Exec_ComandResponse resp = JsonConvert.DeserializeObject <Exec_ComandResponse>(content);

            if (resp.Success)
            {
                List <string> Results = resp.Result.Split(new[] { "\n" }, StringSplitOptions.None).ToList();

                var OwnsGame = Results.Where(a => a.Contains("Owned already") || a.Contains("Já possui")).FirstOrDefault();

                if (OwnsGame == null)
                {
                    return(true);
                }
                else
                {
                    int gameIDOwned = AppIDs.Where(a => OwnsGame.Contains(a.ToString())).FirstOrDefault();

                    if (gameIDOwned != 0)
                    {
                        Log.orange($"<ASF_Owns> <{bot.BotName}> Have AppID {gameIDOwned}");
                        Update_Bots_DB.Add_active_Game_to_File(bot.SteamID, new List <int> {
                            gameIDOwned
                        });
                    }

                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        //string result: Timeout, DuplicateActivationCode, AlreadyPurchased,AccountLocked
        public static string Post_Command_Active_Game(string BotName, long SteamID64, string codigo_game, List <int> AppIDs)
        {
            string URL = $"http://{Main._Main.txt_IPC.Text}:{Main._Main.txt_PORT.Text}/Api/Command";

            Exec_Command comando = new Exec_Command {
                Command = $"redeem {BotName} {codigo_game}"
            };

            string json = JsonConvert.SerializeObject(comando);

            var http = (HttpWebRequest)WebRequest.Create(new Uri(URL));

            http.Accept          = "application/json";
            http.ContentType     = "application/json";
            http.Method          = "POST";
            http.PreAuthenticate = true;
            http.Headers.Add("Authentication", Main._Main.txt_passIPC.Text);


            ASCIIEncoding encoding = new ASCIIEncoding();

            Byte[] bytes = encoding.GetBytes(json);

            Stream newStream = http.GetRequestStream();

            newStream.Write(bytes, 0, bytes.Length);
            newStream.Close();

            var response = http.GetResponse();

            var stream  = response.GetResponseStream();
            var sr      = new StreamReader(stream);
            var content = sr.ReadToEnd();

            File.AppendAllText("response.txt", content + "\n");


            if (content.Contains("OK/NoDetail"))
            {
                Update_Bots_DB.Add_active_Game_to_File(SteamID64, AppIDs);
                string msg = $"{BotName} - {codigo_game} - OK";
                File.AppendAllText("ActivatedSuccess.txt", $"{msg} - {String.Join("_", AppIDs)}\n");
                Log.info(msg);
                return("Sucess");
            }
            else if (content.Contains("Timeout/Timeout"))
            {
                Log.orange($"{BotName} - {codigo_game} - Timeout");
                return("Timeout");
            }
            else if (content.Contains("Fail/AccountLocked"))
            {
                Log.blue(content);
                return("AccountLocked");
            }
            else if (content.Contains("Fail/DuplicateActivationCode"))
            {
                Log.blue(content);
                File.AppendAllText("activation_fail.txt", content + "\n");
                return("DuplicateActivationCode");
            }
            else if (content.Contains("Fail/AlreadyPurchased"))
            {
                Update_Bots_DB.Add_active_Game_to_File(SteamID64, AppIDs);
                Log.orange(content);
                return("AlreadyPurchased");
            }
            else if (content.Contains("Fail/RateLimited"))
            {
                Log.orange(content);
                return("RateLimited");
            }
            else
            {
                Log.blue(content);
                File.AppendAllText("activation_fail.txt", content + "\n");
                return("Fail");
            }
        }