예제 #1
0
 private bool ClickItem(dynamic json)
 {
     try
     {
         var da = json;
         var aa = da.Event.Value;
         foreach (var item in da.data)
         {
             var    b  = item.b[0].Value;
             var    id = item.id[0].Value;
             var    m  = item.m.Value;
             var    p  = item.p.Value;
             string ee = "";
             if (item.e != null)
             {
                 try
                 {
                     ee = item.e.Value;
                 }
                 catch (Exception ex) { Program.Mess.Enqueue("БОТ[" + ID + "] " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Ошибка1 :" + ex.Message); }
             }
             foreach (var name in Program.Data)
             {
                 if (m.Replace(" ", "") == (name.Name).Replace(" ", "") && ee == name.Factory)
                 {
                     Program.Mess.Enqueue("БОТ[" + ID + "] " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "| Нашел предмет :" + m + "|Цена_Сайта:" + p + "|Цена_Наша:" + name.Price);
                     if (p <= name.Price)
                     {
                         // Program.MessTelegram.Enqueue("БОТ[CsMoney]" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Подошел предмет:" + m + "|Цена:" + p);
                         Program.Mess.Enqueue("БОТ[" + ID + "] " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "| Оправил Запрос |Бот:" + b.ToString() + "|IDItems:" + id.ToString() + "|wallet:" + p.ToString());
                         if (Program.BrowesrQuery == false)
                         {
                             Post(handler, 1, b.ToString(), id.ToString(), p.ToString().Replace(",", "."));
                         }
                         else
                         {
                             IJavaScriptExecutor js = driver as IJavaScriptExecutor;
                             string ss1             = "var xhr = new XMLHttpRequest();" +
                                                      "var body = \"{\\\"steamid\\\":\\\"" + b.ToString() + "\\\",\\\"peopleItems\\\":[],\\\"botItems\\\":[\\\"" + id.ToString() + "\\\"],\\\"onWallet\\\":-" + p.ToString().Replace(",", ".") + ",\\\"gid\\\":\\\"" + ga + "\\\"}\";" +
                                                      " xhr.open(\"POST\", 'https://cs.money/send_offer', true); " +
                                                      "xhr.setRequestHeader('Content-Type', 'application/json');" +
                                                      " xhr.setRequestHeader('accept', '*/*');" +
                                                      " xhr.send(body); ";
                             string title = (string)js.ExecuteScript(ss1);
                         }
                         Program.Mess.Enqueue("БОТ[" + ID + "] " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Завершил Запрос");
                         if (Program.autoConfirm == true)
                         {
                             TradingBot tradeBot = new TradingBot(cook, cookAll, apiKey);
                         }
                         //      TradingBot tradeBot = new TradingBot(cook, apiKey);
                         Thread.Sleep(5000);
                         return(true);//main-trade-button
                     }
                     else
                     {
                         SetListBadPrice(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"), "cs.money", m.ToString() + " [" + ee + "]", name.Price.ToString(), p.ToString());
                     }
                 }
             }
         }
     }
     catch (Exception ex) { Program.Mess.Enqueue("БОТ[" + ID + "] " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Ошибка2 :" + ex.Message); }
     return(false);
 }
예제 #2
0
        private bool ClickItem(dynamic json)
        {
            try
            {
                var da = json;
                var aa = da.Event.Value;
                foreach (var item in da.data)
                {
                    var    b  = item.b[0].Value;
                    var    id = item.id[0].Value;
                    var    m  = item.m.Value;
                    var    p  = item.p.Value;
                    var    f  = item.f.First.Value;
                    string ee = "0";
                    string s  = "0";
                    if (item.e != null)
                    {
                        try
                        {
                            ee = item.e.Value;
                        }
                        catch (Exception ex) { Program.Mess.Enqueue("БОТ[" + ID + "] " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Ошибка1 :" + ex.Message); }
                    }
                    if (item.s != null)
                    {
                        try
                        {
                            s = item.s.Count.ToString();
                        }
                        catch (Exception ex) { Program.Mess.Enqueue("БОТ[" + ID + "] " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Ошибка1 :" + ex.Message); }
                    }
                    string factory = "";
                    switch (ee)
                    {
                    case "MW": factory = " (Minimal Wear)"; break;

                    case "FN": factory = " (Factory New)"; break;

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

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

                    case "WW": factory = " (Well-Worn)"; break;
                    }
                    foreach (var name in Program.Data)
                    {
                        if (m.Replace(" ", "") == (name.Name).Replace(" ", "") && ee == name.Factory)
                        {
                            Program.MessageForSendItems.Enqueue("|_____________________________________________________________|");
                            Program.Mess.Enqueue("БОТ[" + ID + "] " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "| Нашел предмет :" + m + "|Цена_Сайта:" + p + "|Цена_Наша:" + name.Price);

                            if (p <= name.Price)
                            {
                                if (name.count > 0)
                                {
                                    // Program.MessTelegram.Enqueue("БОТ[CsMoney]" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Подошел предмет:" + m + "|Цена:" + p);
                                    Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "| Оправил Запрос |Предмет:" + m + "|Цена_Сайта:" + p + "|Цена_Наша:" + name.Price);
                                    if (Program.BrowesrQuery == false)
                                    {
                                        Post(handler, 1, b.ToString(), id.ToString(), p.ToString().Replace(",", "."));
                                    }
                                    else
                                    {
                                        string ff = "";
                                        if (f.ToString() != "0")
                                        {
                                            ff = "\\\"" + f.ToString() + "\\\"";
                                        }
                                        else
                                        {
                                            ff = f.ToString();
                                        }
                                        IJavaScriptExecutor js = 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.ToString() + "\\\",\\\"local_price\\\":\\\"" + p.ToString().Replace(",", ".") + "\\\",\\\"price\\\":" + p.ToString().Replace(",", ".") + ",\\\"float\\\":" + ff + ",\\\"stickers_count\\\":" + s.ToString() + ",\\\"market_hash_name\\\":\\\"" + m.ToString() + factory + "" + "\\\",\\\"bot\\\":\\\"" + b.ToString() + "\\\"}],\\\"onWallet\\\":-" + p.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();";
                                        var title = js.ExecuteScript(ss1);
                                        Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Результат отправленного обмена:" + title.ToString());
                                    }
                                    Program.OfferSend++;
                                    Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Завершил Запрос");
                                    Program.Dat NewItem = new Program.Dat()
                                    {
                                        Id          = name.Id,
                                        Name        = name.Name,
                                        Factory     = name.Factory,
                                        Price       = name.Price,
                                        AutoAddItem = name.AutoAddItem,
                                        SiteName    = name.SiteName,
                                        count       = name.count - 1
                                    };
                                    Program.Data.Remove(name);
                                    Program.Data.Add(NewItem);
                                    Program.MessageForSendItems.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Осталось количество предметов" + NewItem.count.ToString());
                                    if (Program.autoConfirm == true)
                                    {
                                        TradingBot tradeBot = new TradingBot(cook, cookAll, apiKey);
                                    }

                                    //      TradingBot tradeBot = new TradingBot(cook, apiKey);
                                    Thread.Sleep(2000);
                                }
                                else
                                {
                                    Program.DontOfferSend++; Program.MessageFailed.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Не удалось запустить запрос, максимальное количество предметов:" + m);
                                }

                                return(true);//main-trade-button
                            }
                            else
                            {
                                Program.DontOfferSend++;
                                Program.MessageFailed.Enqueue(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Цена не подошла " + m + "|Цена_Сайта:" + p + "|Цена_Наша:" + name.Price);
                                SetListBadPrice(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"), "cs.money", m.ToString() + " [" + ee + "]", name.Price.ToString(), p.ToString());
                            }
                        }
                    }
                }
            }
            catch (Exception ex) { Program.MessageFailed.Enqueue("БОТ[" + ID + "] " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + "|Ошибка2 :" + ex.Message); }
            return(false);
        }