Ejemplo n.º 1
0
        private PropertyItemsFloat GetFloat(string link)
        {
            try
            {
                //       string newProxy = Program.ProxyList.Dequeue();
                HttpClient client = null;

                //handler2.CookieContainer = cookies;
                //handler2.Proxy = null;
                //client = Prox(client, handler2, newProxy);
                client         = new HttpClient();
                client.Timeout = TimeSpan.FromSeconds(3);
                //client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36");
                //client.DefaultRequestHeaders.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
                //client.DefaultRequestHeaders.Add("Accept-Language", "ru,uk;q=0.9,en;q=0.8");
                //client.DefaultRequestHeaders.Add("Connection", "keep-alive");
                //client.DefaultRequestHeaders.Add("Accept-Encoding", "gzip, deflate, br");

                var response = client.GetAsync("https://api.csgofloat.com:1738/?url=" + link).Result;
                if (response.IsSuccessStatusCode)
                {
                    var    responseContent = response.Content;
                    string responseString  = responseContent.ReadAsStringAsync().Result;
                    if (responseString != "null")
                    {
                        var res = JsonConvert.DeserializeObject <dynamic>(responseString);
                        PropertyItemsFloat PIF = new PropertyItemsFloat {
                            floatt = res.iteminfo.floatvalue.Value.ToString(), stickerCount = res.iteminfo.stickers.Count.ToString()
                        };
                        return(PIF);
                    }
                    //else { Program.Mess.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "ID={" + ID + "}|BOT:" + BotId + "|" + "null" ); }
                }
                client.Dispose();
            }
            catch (Exception ex)
            {
                //Types.LogInfo er = new Types.LogInfo() { Id = ID, Error = "GET|"+ex.Message, Timeerror = DateTime.Now.ToString("HH:mm:ss:fff") };
                //Program.MessLog.Enqueue(er);
            }
            return(new PropertyItemsFloat());
        }
Ejemplo n.º 2
0
        private void Work()
        {
            try
            {
                while (true)
                {
                    try
                    {
                        pp++;
                        Random rr = new Random();
                        int    sl = rr.Next(100, 500);
                        Thread.Sleep(sl);


                        var items = Get();
                        if (items != null)
                        {
                            List <Data> list = new List <Data>();
                            int         k    = 0;
                            foreach (var item in items.rgInventory)
                            {
                                Data d = new Data {
                                    _classid = item.First.classid.ToString(), _id = item.First.id.ToString(), _instanceid = item.First.instanceid.ToString()
                                };
                                list.Add(d);
                            }
                            foreach (var item in items.rgDescriptions)
                            {
                                foreach (var it in Program.Data)
                                {
                                    string factory = "";
                                    switch (it.Factory)
                                    {
                                    case "MW": factory = "(MinimalWear)"; break;

                                    case "FN": factory = "(FactoryNew)"; break;

                                    case "FT": factory = "(Field-Tested)"; break;

                                    case "BS": factory = "(Battle-Scarred)"; break;

                                    case "WW": factory = "(Well-Worn)"; break;
                                    }
                                    string FullName = it.Name + factory;
                                    if (item.First.market_hash_name.Value.ToString().Replace(" ", "") == FullName.Replace(" ", ""))
                                    {
                                        Program.MessageForSendItems.Enqueue("|_____________________________________________________________|");
                                        try
                                        {
                                            Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + $"Нашел предмет {item.First.market_hash_name.Value.ToString()}");
                                            string id       = list.Find(N => (N._classid == item.First.classid.Value.ToString()))._id;
                                            var    linkView = item.First.actions.First["link"].Value.ToString().Replace("%owner_steamid%", BotId).Replace("%assetid%", id);
                                            Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + $"Получил ID {id}");
                                            double price = Program.DataMoney.Find(N => (N.Name.Replace(" ", "") == FullName.Replace(" ", ""))).Price;
                                            Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + $"Получил Price {price}");

                                            if (price <= it.Price)
                                            {
                                                if (it.count > 0)
                                                {
                                                    //DataStruct.GoodItems.Enqueue(it);
                                                    PropertyItemsFloat PIF = GetFloat(linkView);
                                                    Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + $"Получил Float {PIF.floatt}");


                                                    IJavaScriptExecutor js = Program._driver as IJavaScriptExecutor;
                                                    string ss1             = "function test() {var xhr = new XMLHttpRequest();" +
                                                                             //     "var body = \"{\\\"steamid\\\":\\\"" + b.ToString() + "\\\",\\\"peopleItems\\\":[],\\\"botItems\\\":[\\\"" + id.ToString() + "\\\"],\\\"onWallet\\\":-" + p.ToString().Replace(",", ".") + ",\\\"gid\\\":\\\"" + "\\\"}\";" +
                                                                             "var body = \"{\\\"peopleItems\\\":[],\\\"botItems\\\":[{\\\"assetid\\\":\\\"" + id + "\\\",\\\"local_price\\\":\\\"" + price.ToString().Replace(",", ".") + "\\\",\\\"price\\\":" + price.ToString().Replace(",", ".") + ",\\\"float\\\":\\\"" + Math.Round(Convert.ToDouble(PIF.floatt), 8).ToString().Replace(",", ".") + "\\\",\\\"stickers_count\\\":" + PIF.stickerCount + ",\\\"market_hash_name\\\":\\\"" + item.First.market_hash_name.Value.ToString() + "" + "\\\",\\\"bot\\\":\\\"" + BotId + "\\\"}],\\\"onWallet\\\":-" + price.ToString().Replace(",", ".") + "}\";" +
                                                                             " xhr.open(\"POST\", 'https://cs.money/send_offer', false); " +
                                                                             "xhr.setRequestHeader('Content-Type', 'application/json');" +
                                                                             " xhr.setRequestHeader('accept', '*/*');" +
                                                                             " xhr.send(body);return xhr.status+'|'+xhr.responseText; } return test();";
                                                    ArgumentsChek.Value = ss1;//передаем строку запроса на дочерние программы через событие
                                                    var title = js.ExecuteScript(ss1);
                                                    Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Результат отправленного обмена:" + title.ToString());
                                                    Program.OfferSend++;
                                                    Program.Dat NewItem = new Program.Dat()
                                                    {
                                                        Id          = it.Id,
                                                        Name        = it.Name,
                                                        Factory     = it.Factory,
                                                        Price       = it.Price,
                                                        AutoAddItem = it.AutoAddItem,
                                                        SiteName    = it.SiteName,
                                                        count       = it.count - 1
                                                    };
                                                    Program.Data.Remove(it);
                                                    Program.Data.Add(NewItem);
                                                    Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Осталось количество предметов" + NewItem.count.ToString());
                                                }
                                                else
                                                {
                                                    Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Лимит на взятие предметов исчерпан!");
                                                }
                                            }
                                            else
                                            {
                                                Program.DontOfferSend++;
                                                Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + $"Цена не подошла PriceMoney:{price.ToString()}-PriceData:{it.Price.ToString()}");
                                            }
                                        }
                                        catch (Exception ex) { Program.MessageFailed.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "ID={" + ID + "}|BOT:{" + BotId + "}Work1|" + ex.Message); }
                                        Program.MessageForSendItems.Enqueue("|_____________________________________________________________|");
                                        //   Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Результат отправленного обмена:" + title.ToString());
                                    }
                                }
                                k++;
                            }
                            Program.Mess.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "ID={" + ID + "}|BOT:{" + BotId + "}|Количсетво предметов:{-" + k + "-}");
                        }
                        else
                        {
                            Program.Mess.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "ID={" + ID + "}|BOT:" + BotId + "|" + "|null");
                        }
                    }
                    catch (Exception ex)
                    {
                        Program.MessageFailed.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "ID={" + ID + "}|BOT:{" + BotId + "}Work1|" + ex.Message);
                        //Types.LogInfo er = new Types.LogInfo() { Id = ID, Error = "Work1|"+ex.Message, Timeerror = DateTime.Now.ToString("HH:mm:ss:fff") };
                        //Program.MessLog.Enqueue(er);
                    }
                }
            }
            catch (Exception ex)
            {
                Program.MessageFailed.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "ID={" + ID + "}|BOT:{" + BotId + "}Work2|" + ex.Message);
                //Types.LogInfo er = new Types.LogInfo() { Id = ID, Error = "Work2|" + ex.Message, Timeerror = DateTime.Now.ToString("HH:mm:ss:fff") };
                //Program.MessLog.Enqueue(er);
            }
        }