コード例 #1
0
ファイル: Main.cs プロジェクト: leolongvu/SteamMangementBot
        private void FillInventoryList()
        {
            InvenLV.Items.Clear();

            for (int i = 0; i < SteamParsing.InventList.Count; i++)
            {
                var ourItem = SteamParsing.InventList[i];

                string priceRes; string pricemes;
                if (ourItem.MedianPrice.Equals("0"))
                {
                    pricemes = "Not yer Refreshed";
                }
                else
                {
                    pricemes = SteamParsing.Currencies.GetName() + " " + ourItem.MedianPrice;
                }
                if (ourItem.BuyPrice == "0")
                {
                    priceRes = "Not yet Refreshed";
                }
                else if (ourItem.BuyPrice == "1")
                {
                    priceRes = "Not Tradable";
                }
                else
                {
                    priceRes = SteamParsing.Currencies.GetName() + " " + SteamLibrary.DoFracture(ourItem.BuyPrice);
                }

                string[] row     = { ourItem.Type, ourItem.Name, priceRes, pricemes };
                var      lstItem = new ListViewItem(row);
                InvenLV.Items.Add(lstItem);
            }
        }
コード例 #2
0
        public void DoTrack(string name, string game, string hashname, int buyPer, int sellPer, int interval)
        {
            SteamLibrary.TrackingItem item = new SteamLibrary.TrackingItem(name, game, 0, 0, buyPer, sellPer, false, false, false, "", 0);

            item.hashname = hashname;

            string gameid = SteamLibrary.GetApp(game).AppID;

            try
            {
                SteamLibrary.StrParam price = SteamParseSite.ParseItemPrice(hashname, gameid, cookieCont);

                item.StartPrice  = Convert.ToSingle(price.P1);
                item.MedianPrice = Convert.ToSingle(price.P2);
            }
            catch { }

            item.Link = "http://steamcommunity.com/market/listings/" + SteamLibrary.GetApp(game).AppID + "/" + name;

            int index = TrackingList.Count;

            TrackingList.Add(item);

            item.index = index;

            doMessage(flag.Add_track, 0, item, true);

            item.Refresh           = new System.Timers.Timer();
            item.Refresh.Elapsed  += new System.Timers.ElapsedEventHandler(delegate { TrackProgress(item); });
            item.Refresh.Interval  = interval;
            item.Refresh.AutoReset = true;
            item.Refresh.Start();
        }
コード例 #3
0
ファイル: Main.cs プロジェクト: leolongvu/SteamMangementBot
        public void LoadingCookie()
        {
            if (settingfrm.Visible == false)
            {
                settingfrm.Show();

                SteamAuto.UserName = settingfrm.comboBox1.SelectedItem.ToString();

                settingfrm.Hide();
            }
            else
            {
                SteamAuto.UserName = settingfrm.comboBox1.SelectedItem.ToString();
            }

            var cook = new CookieContainer();

            if (!SteamAuto.UserName.Equals("New Account"))
            {
                cook = (CookieContainer)SteamLibrary.LoadBinary(SteamAuto.UserName + ".dat");
                if (cook == null)
                {
                    cook = new CookieContainer();
                }
            }

            SteamAuto.cookieCont = cook;
        }
コード例 #4
0
        private void TrackProgress(SteamLibrary.TrackingItem item)
        {
            Stopwatch stop = new Stopwatch();

            string gameid = SteamLibrary.GetApp(item.Game).AppID;

            try
            {
                stop.Start();
                SteamLibrary.StrParam price = SteamParseSite.ParseItemPrice(item.hashname, gameid, cookieCont);
                item.StartPrice     = Convert.ToSingle(price.P1);
                item.PreMedianPrice = item.MedianPrice;
                item.MedianPrice    = Convert.ToSingle(price.P2);
                stop.Stop();
            }
            catch { }
            try
            {
                if (((item.StartPrice / item.MedianPrice * 100) < item.BuyPercent) && (item.Buy) && (item.StartPrice > 0) && (item.MedianPrice / item.MedianPrice < 1.2))
                {
                    pricecheck = item.StartPrice;
                    BuyThreadExcute(item.Link, true, true, true);
                }
            }
            catch { }

            doMessage(flag.Track_progress, Convert.ToInt32(stop.ElapsedMilliseconds), item, true);
        }
コード例 #5
0
ファイル: Main.cs プロジェクト: leolongvu/SteamMangementBot
 private void button10_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex != 8)
     {
         string truePrice = string.Empty;
         if (textBox2.Text == string.Empty)
         {
             MessageBox.Show("Wrong Price!", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
         else
         {
             truePrice = SteamLibrary.GetSweetPrice(textBox2.Text);
             if (truePrice == string.Empty)
             {
                 MessageBox.Show("WrongPrice", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 return;
             }
         }
         for (int i = 0; i < InvenLV.SelectedIndices.Count; i++)
         {
             var ourItem = SteamParsing.InventList[InvenLV.SelectedIndices[i]];
             ourItem.BuyPrice = truePrice;
             InvenLV.SelectedItems[i].SubItems[2].Text = SteamParsing.Currencies.GetName() + " " + textBox2.Text;
         }
     }
 }
コード例 #6
0
        public static string SendPostRequest(string req, string url, string refer, CookieContainer cookie, bool tolog)
        {
            var    requestData = Encoding.UTF8.GetBytes(req);
            string content     = string.Empty;

            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

                request.CookieContainer = cookie;
                request.Method          = "POST";

                //New
                request.Proxy   = null;
                request.Timeout = 30000;
                //KeepAlive is True by default
                request.KeepAlive = true;

                request.UserAgent = SteamLibrary.steamUA;

                request.Referer       = refer;
                request.ContentType   = "application/x-www-form-urlencoded";
                request.ContentLength = requestData.Length;

                Stream s = request.GetRequestStream();
                {
                    s.Write(requestData, 0, requestData.Length);
                }
                s.Close();

                HttpWebResponse resp = (HttpWebResponse)request.GetResponse();

                StreamReader stream = new StreamReader(resp.GetResponseStream());
                content = stream.ReadToEnd();

                if (tolog)
                {
                    SteamLibrary.AddtoLog(content);
                }

                cookie = request.CookieContainer;

                resp.Close();
                stream.Close();
            }
            catch (WebException e)
            {
                if (e.Status == WebExceptionStatus.ProtocolError)
                {
                    WebResponse resp = e.Response;
                    using (StreamReader sr = new StreamReader(resp.GetResponseStream()))
                    {
                        content = sr.ReadToEnd();
                    }
                }
            }
            return(content);
        }
コード例 #7
0
ファイル: Main.cs プロジェクト: leolongvu/SteamMangementBot
        private void Main_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!SteamAuto.UserName.Equals("New Account"))
            {
                SteamLibrary.SaveBinary(SteamAuto.UserName + ".dat", SteamAuto.cookieCont);
            }

            StatusPB.Image    = Properties.Resources.icon1;
            StatusLabel1.Text = "Saving";
            SaveTrackList();
            StatusPB.Image = null;
        }
コード例 #8
0
ファイル: Main.cs プロジェクト: leolongvu/SteamMangementBot
 private void textBox1_KeyUp(object sender, KeyEventArgs e)
 {
     try
     {
         if (textBox1.Text != string.Empty)
         {
             textBox2.Text = SteamLibrary.DoFracture(SteamLibrary.AddFee(SteamLibrary.GetSweetPrice(textBox1.Text)));
         }
     }
     catch (Exception)
     {
     }
 }
コード例 #9
0
            public int ParseOnSale(string content)
            {
                InventList.Clear();
                string parseBody = Regex.Match(content, "(?<=section market_home_listing_table\">)(.*)(?=<div id=\"tabContentsMyMarketHistory)",
                                               RegexOptions.Singleline).ToString();

                MatchCollection matches = Regex.Matches(parseBody, "(?<=market_recent_listing_row listing_)(.*?)(?=	</div>\r\n</div>)",
                                                        RegexOptions.Singleline);

                if (matches.Count != 0)
                {
                    foreach (Match match in matches)
                    {
                        string currmatch = match.Groups[1].Value;

                        string ImgLink = Regex.Match(currmatch, "(?<=economy/image/)(.*)(?=/38fx38f)").ToString();

                        //If you need:
                        //string assetid = Regex.Match(currmatch, "(?<='mylisting', ')(.*)(?=\" class=\"item_market)").ToString();
                        //assetid = assetid.Substring(assetid.Length - 11, 9);

                        string listId = Regex.Match(currmatch, "(?<=mylisting_)(.*)(?=_image\" src=)").ToString();

                        string appidRaw = Regex.Match(currmatch, "(?<=market_listing_item_name_link)(.*)(?=</a></span>)").ToString();
                        string pageLnk  = Regex.Match(appidRaw, "(?<=href=\")(.*)(?=\">)").ToString();

                        string captainPrice = Regex.Match(currmatch, @"(?<=>
						)(.*)(?=					</span>
					<br>)"                    , RegexOptions.Singleline).ToString();

                        captainPrice = SteamLibrary.GetSweetPrice(Regex.Replace(captainPrice,
                                                                                Currencies.GetAscii(), string.Empty).Trim());

                        captainPrice.Insert(captainPrice.Length - 2, ".");

                        string[] LinkName = Regex.Match(currmatch, "(?<=_name_link\" href=\")(.*)(?=</a></span><br/>)").
                                            ToString().Split(new string[] { "\">" }, StringSplitOptions.None);

                        string ItemType = Regex.Match(currmatch, "(?<=_listing_game_name\">)(.*)(?=</span>)").ToString();

                        InventList.Add(new SteamLibrary.InventItem(listId, LinkName[1], ItemType, captainPrice, "0", ImgLink,
                                                                   string.Empty, true, true, pageLnk));
                    }
                }
                //else
                //TODO. Add correct error processing
                //MessageBox.Show(Strings.OnSaleErr, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);

                return(matches.Count);
            }
コード例 #10
0
ファイル: Main.cs プロジェクト: leolongvu/SteamMangementBot
 public void SaveConfigs()
 {
     if (!Directory.Exists(System.AppDomain.CurrentDomain.BaseDirectory + @"\Configs"))
     {
         Directory.CreateDirectory(System.AppDomain.CurrentDomain.BaseDirectory + @"\Configs");
     }
     TextWriter config_writer = new StreamWriter(Application.StartupPath + @"\Configs\" + SteamAuto.UserName + ".ini");
     {
         config_writer.WriteLine(settingfrm.comboBox1.SelectedItem.ToString());
         config_writer.WriteLine(SteamLibrary.Encrypt(settingfrm.PassTB.Text));
         config_writer.WriteLine(settingfrm.searchResTB.Text);
         config_writer.WriteLine("//");
         config_writer.Close();
     }
 }
コード例 #11
0
            public int ParseInventory(string content)
            {
                InventList.Clear();

                try
                {
                    var rgDescr = JsonConvert.DeserializeObject <SteamLibrary.InventoryData>(content);

                    foreach (SteamLibrary.InvItem prop in rgDescr.myInvent.Values)
                    {
                        var ourItem = rgDescr.invDescr[prop.classid + "_" + prop.instanceid];

                        //parse cost by url (_lists + 753/ + ourItem.MarketName)
                        string price = "0";

                        if (!ourItem.Marketable)
                        {
                            price = "1";
                        }

                        //fix for special symbols in Item Name
                        string markname = string.Empty;

                        if ((ourItem.MarketName == null) && (ourItem.Name == string.Empty))
                        {
                            ourItem.Name       = ourItem.SimpleName;
                            ourItem.MarketName = ourItem.SimpleName;
                        }

                        //BattleBlock Theater Fix
                        markname = Uri.EscapeDataString(ourItem.MarketName);
                        string pageLnk = string.Format("{0}/{1}/{2}", SteamLibrary._lists, ourItem.AppId, markname);

                        InventList.Add(new SteamLibrary.InventItem(prop.assetid, ourItem.Name, ourItem.Type,
                                                                   price, "0", ourItem.IconUrl, ourItem.MarketName, false, ourItem.Marketable, pageLnk));
                    }
                }
                catch (Exception e)
                {
                    SteamLibrary.AddtoLog(e.Message);
                }

                return(InventList.Count);
            }
コード例 #12
0
        public void DoAdvanceSearch(byte type, int searchResCount, string searchName, bool isGame, string game,
                                    bool isMin, string min, bool isMax, string max)
        {
            switch (type)
            {
            case 0:
                sppos    = new SteamLibrary.SearchPagePos(0, 1);
                lastSrch = searchName;
                break;

            case 1:
                if (sppos.CurrentPos < sppos.PageCount)
                {
                    sppos.CurrentPos += searchResCount;
                }
                else
                {
                    sppos.CurrentPos = 1;
                }

                break;

            case 2:
                if (sppos.CurrentPos > searchResCount)
                {
                    sppos.CurrentPos -= searchResCount;
                }
                else
                {
                    sppos.CurrentPos = sppos.PageCount;
                }
                break;

            default:
                break;
            }

            //search/render/?appid={0}&query={0}&start={1}&count={2}
            advancelinkTxt = string.Format(SteamLibrary._adsearch, SteamLibrary.GetApp(game).AppID, lastSrch, sppos.CurrentPos - 1, searchResCount);
            ThreadPool.QueueUserWorkItem(new WaitCallback(AdvanceSearchProgress), new object[]
                                         { isGame, game, isMin, min, isMax, max, searchResCount });
        }
コード例 #13
0
        public void RefreshProgress(object state)
        {
            object[] parameters = state as object[];

            SteamLibrary.InventItem item = (SteamLibrary.InventItem)parameters[0];
            int index = (int)parameters[1];

            string[] split = item.PageLink.Split('/');

            SteamLibrary.StrParam priceOver = SteamParseSite.ParseItemPrice(split[7], split[6], cookieCont);

            item.MedianPrice = priceOver.P2;

            if (item.BuyPrice == "0")
            {
                item.BuyPrice = SteamLibrary.GetSweetPrice(item.MedianPrice);
            }

            doMessage(flag.InvPrice, index, item, true);
        }
コード例 #14
0
ファイル: Main.cs プロジェクト: leolongvu/SteamMangementBot
 public void LoadConfigs()
 {
     if (File.Exists(Application.StartupPath + @"\Configs\" + SteamAuto.UserName + ".ini"))
     {
         TextReader config_reader = new StreamReader(Application.StartupPath + @"\Configs\" + SteamAuto.UserName + ".ini");
         string     input;
         while ((input = config_reader.ReadLine()) != "//")
         {
             SteamAuto.UserName          = input;
             settingfrm.UserNamTB.Text   = SteamAuto.UserName;
             SteamAuto.Password          = SteamLibrary.Decrypt(config_reader.ReadLine());
             settingfrm.PassTB.Text      = SteamAuto.Password;
             settingfrm.searchResTB.Text = config_reader.ReadLine();
         }
         config_reader.Close();
         AccNameLB.Text = "(Acc: " + SteamAuto.UserName + ")";
     }
     else
     {
         MessageBox.Show("Error loading configs!", "Error");
         AccNameLB.Text = "(Acc: None)";
     }
 }
コード例 #15
0
        public void doMessage(flag myflag, int searchId, object message, bool isMain)
        {
            try
            {
                if (delegMessage != null)
                {
                    Control target = delegMessage.Target as Control;

                    if (target != null && target.InvokeRequired)
                    {
                        target.Invoke(delegMessage, new object[] { this, message, searchId, myflag, isMain });
                    }
                    else
                    {
                        delegMessage(this, message, searchId, myflag, isMain);
                    }
                }
            }
            catch (Exception e)
            {
                SteamLibrary.AddtoLog(e.Message);
            }
        }
コード例 #16
0
            public SteamLibrary.StrParam GetNameBalance(CookieContainer cookieCont)
            {
                SteamLibrary.AddtoLog("Getting account name and balance...");

                string markpage = SendGet(SteamLibrary._market, cookieCont, false, true);

                //For testing purposes!
                //string markpage = System.IO.File.ReadAllText(@"C:\sing.htm");

                //Fix to getting name regex
                string parseName = Regex.Match(markpage, "(?<=buynow_dialog_myaccountname\">)(.*)(?=</span>)").ToString().Trim();

                if (parseName == "")
                {
                    return(null);
                }

                //Set profileId for old Url format
                SteamAutoFunction.MyUserID = Regex.Match(markpage, "(?<=g_steamID = \")(.*)(?=\";)").ToString();

                //30.05.14 Update
                string parseImg = Regex.Match(markpage, "(?<=avatarIcon\"><img src=\")(.*)(?=\" alt=\"\"></span>)", RegexOptions.Singleline).ToString();

                string parseAmount = Regex.Match(markpage, "(?<=marketWalletBalanceAmount\">)(.*)(?=</span>)").ToString();

                string country = Regex.Match(markpage, "(?<=g_strCountryCode = \")(.*)(?=\";)").ToString();
                string strlang = Regex.Match(markpage, "(?<=g_strLanguage = \")(.*)(?=\";)").ToString();

                Currencies.GetType(parseAmount);

                parseAmount = Currencies.ReplaceAscii(parseAmount);

                //?country=RU&language=russian&currency=5&count=20
                string Addon = string.Format(SteamLibrary.jsonAddonUrl, country, strlang, Currencies.GetCode());

                return(new SteamLibrary.StrParam(parseName, SteamAutoFunction.MyUserID, parseAmount, parseImg, Addon));
            }
コード例 #17
0
            public static void loadImg(string imgurl, PictureBox picbox, bool drawtext, bool doWhite)
            {
                try
                {
                    if (imgurl == string.Empty)
                    {
                        return;
                    }

                    WebClient wClient   = new WebClient();
                    byte[]    imageByte = wClient.DownloadData(imgurl);
                    using (MemoryStream ms = new MemoryStream(imageByte, 0, imageByte.Length))
                    {
                        ms.Write(imageByte, 0, imageByte.Length);
                        var resimg = Image.FromStream(ms, true);
                        picbox.BackColor = backColor(resimg, doWhite);
                        picbox.Image     = resimg;
                    }
                }
                catch (Exception exc)
                {
                    SteamLibrary.AddtoLog(exc.Message);
                }
            }
コード例 #18
0
        private void InventoryProgress(object sender, DoWorkEventArgs e)
        {
            int[] parameters = e.Argument as int[];

            int invApp = parameters[0];

            int invCount = 0;

            if (!LoadOnSale)
            {
                invCount = SteamParseSite.ParseInventory(SteamParsing.SendGet(string.Format(SteamLibrary._jsonInv, MyUserID,
                                                                                            SteamLibrary.GetAppFromIndex(invApp, true).AppID), cookieCont, false, true));
            }
            else
            {
                invCount = SteamParseSite.ParseOnSale(SteamParsing.SendGet(SteamLibrary._market, cookieCont, false, true));
            }

            if (invCount > 0)
            {
                doMessage(flag.Inventory_Loaded, 0, string.Empty, true);
            }
            else
            {
                doMessage(flag.Inventory_Loaded, 1, string.Empty, true);
            }
        }
コード例 #19
0
        public void BuyProgress(object sender, DoWorkEventArgs e)
        {
            object[] parameters = e.Argument as object[];

            string link       = Convert.ToString(parameters[0]);
            bool   BuyNow     = Convert.ToBoolean(parameters[1]);
            bool   IgnoreWarn = Convert.ToBoolean(parameters[2]);
            bool   isTrack    = Convert.ToBoolean(parameters[3]);

            try
            {
                string sessid = SteamParseSite.GetSessId(cookieCont);

                string url = link;

                if (BuyNow)
                {
                    SteamParseSite.ParseLotList(SteamParsing.SendGet(url, cookieCont, false, true),
                                                MyUserID, BuyList, false, true, IgnoreWarn);

                    if (BuyList.Count == 0)
                    {
                        doMessage(flag.Error_scan, 0, "0", true);
                    }
                    else
                    {
                        double totalPrice = BuyList[0].Price + BuyList[0].Fee;

                        if (isTrack)
                        {
                            if (totalPrice / 100 == pricecheck)
                            {
                                string totalStr = Convert.ToString(totalPrice);

                                var buyresp = BuyItem(cookieCont, sessid, BuyList[0].ListingId, link, BuyList[0].Price.ToString(),
                                                      BuyList[0].Fee.ToString(), totalStr);

                                BuyNow = false;

                                if (buyresp.Succsess)
                                {
                                    doMessage(flag.Success_buy, 0, buyresp.Mess + ";" + BuyList[0].ItemName, true);
                                }
                                else
                                {
                                    doMessage(flag.Error_buy, 0, buyresp.Mess, true);
                                }
                            }
                        }
                        else
                        {
                            string totalStr = Convert.ToString(totalPrice);

                            var buyresp = BuyItem(cookieCont, sessid, BuyList[0].ListingId, link, BuyList[0].Price.ToString(),
                                                  BuyList[0].Fee.ToString(), totalStr);

                            BuyNow = false;

                            if (buyresp.Succsess)
                            {
                                doMessage(flag.Success_buy, 0, buyresp.Mess + ";" + BuyList[0].ItemName, true);
                            }
                            else
                            {
                                doMessage(flag.Error_buy, 0, buyresp.Mess, true);
                            }
                        }
                    }
                    return;
                }
            }
            catch (Exception exc)
            {
                SteamLibrary.AddtoLog(exc.Message);
            }
            finally
            {
                //CancelScan();
            }
        }
コード例 #20
0
ファイル: Main.cs プロジェクト: leolongvu/SteamMangementBot
        public void Event_Message(object sender, object data, int searchId, flag myflag, bool isMain)
        {
            if (data == null)
            {
                return;
            }

            string message = data.ToString();

            switch (myflag)
            {
            case flag.Already_logged:

                StatusLabel1.Text = "Ready";
                StatusPB.Image    = null;
                SteamLibrary.AddtoLog("Already logged");
                GetAccInfo((SteamLibrary.StrParam)data);
                break;

            case flag.Login_success:

                StatusLabel1.Text = "Ready";
                StatusPB.Image    = null;
                SteamLibrary.AddtoLog("Login succesful");
                GetAccInfo((SteamLibrary.StrParam)data);
                break;

            case flag.Login_cancel:

                MessageBox.Show("Error logging in! " + message + "!", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                StatusPB.Image    = null;
                StatusLabel1.Text = message;
                break;

            case flag.Logout_:

                StatusLabel1.Text = "Ready";
                StatusPB.Image    = null;
                LoginB.Text       = "Login";
                break;

            case flag.Search_success:

                ScanLV.Enabled   = true;
                button15.Enabled = true;

                if (SteamAutoFunction.sppos.CurrentPos == 1)
                {
                    int found = Convert.ToInt32(message);
                    SteamAutoFunction.sppos.PageCount = found / SteamAutoFunction.SearchResCount;
                    if (found % SteamAutoFunction.SearchResCount != 0)
                    {
                        SteamAutoFunction.sppos.PageCount++;
                    }
                }

                label5.Text = string.Format("{0}/{1}", SteamAutoFunction.sppos.CurrentPos.ToString(),
                                            SteamAutoFunction.sppos.PageCount.ToString());

                if (SteamAutoFunction.sppos.PageCount > 1)
                {
                    prepageBT.Visible  = true;
                    nextpageBT.Visible = true;
                    button16.Visible   = false;
                    button17.Visible   = false;
                }
                else
                {
                    prepageBT.Visible  = false;
                    nextpageBT.Visible = false;
                    button16.Visible   = false;
                    button17.Visible   = false;
                }

                ScanLV.Items.Clear();

                for (int i = 0; i < SteamAutoFunction.SearchList.Count; i++)
                {
                    var ourItem = SteamAutoFunction.SearchList[i];

                    string[] row = { ourItem.Game,     ourItem.Name,                                                  SteamParsing.Currencies.GetName() + " " + ourItem.StartPrice,
                                     ourItem.Quantity, SteamParsing.Currencies.GetName() + " " + ourItem.MedianPrice, ourItem.Hashname };
                    var      lstItem = new ListViewItem(row);
                    ScanLV.Items.Add(lstItem);
                }

                button2.Enabled   = true;
                StatusPB.Image    = null;
                StatusLabel1.Text = "Ready";

                break;

            case flag.Advance_search_success:

                ScanLV.Enabled               = true;
                button15.Enabled             = true;
                SteamAutoFunction.searchDone = true;

                if (SteamAutoFunction.sppos.CurrentPos == 1)
                {
                    int found = Convert.ToInt32(message);
                    SteamAutoFunction.sppos.PageCount = found / SteamAutoFunction.SearchResCount;
                    if (found % SteamAutoFunction.SearchResCount != 0)
                    {
                        SteamAutoFunction.sppos.PageCount++;
                    }
                }

                label5.Text = string.Format("{0}/{1}", SteamAutoFunction.sppos.CurrentPos.ToString(),
                                            SteamAutoFunction.sppos.PageCount.ToString());

                if (SteamAutoFunction.sppos.PageCount > 1)
                {
                    prepageBT.Visible  = false;
                    nextpageBT.Visible = false;
                    button16.Visible   = true;
                    button17.Visible   = true;
                }
                else
                {
                    prepageBT.Visible  = false;
                    nextpageBT.Visible = false;
                    button16.Visible   = false;
                    button17.Visible   = false;
                }

                ScanLV.Items.Clear();

                for (int i = 0; i < SteamAutoFunction.SearchList.Count; i++)
                {
                    var ourItem = SteamAutoFunction.SearchList[i];

                    string[] row = { ourItem.Game,     ourItem.Name,                                                  SteamParsing.Currencies.GetName() + " " + ourItem.StartPrice,
                                     ourItem.Quantity, SteamParsing.Currencies.GetName() + " " + ourItem.MedianPrice, ourItem.Hashname };
                    var      lstItem = new ListViewItem(row);
                    ScanLV.Items.Add(lstItem);
                }

                button2.Enabled   = true;
                StatusPB.Image    = null;
                StatusLabel1.Text = "Ready";

                break;

            case flag.Add_track:

                SteamLibrary.TrackingItem item = (SteamLibrary.TrackingItem)data;

                string lp = SteamParsing.Currencies.GetName() + " " + string.Format("{0:N2}", item.StartPrice);
                string mp = SteamParsing.Currencies.GetName() + " " + string.Format("{0:N2}", item.MedianPrice);

                string[] row1 = { item.Game,                   item.Name, lp,        mp, "", "",            item.BuyPercent.ToString(),
                                  item.SellPercent.ToString(), "",        item.Link, "", "", item.hashname, "" };
                var      lst1 = new ListViewItem(row1);
                TraItemLV.Items.Add(lst1);

                break;

            case flag.Track_progress:

                SteamLibrary.TrackingItem item1 = (SteamLibrary.TrackingItem)data;

                string lp1 = SteamParsing.Currencies.GetName() + " " + string.Format("{0:N2}", item1.StartPrice);
                string mp1 = SteamParsing.Currencies.GetName() + " " + string.Format("{0:N2}", item1.MedianPrice);

                TraItemLV.Items[item1.index].SubItems[2].Text  = lp1;
                TraItemLV.Items[item1.index].SubItems[3].Text  = mp1;
                TraItemLV.Items[item1.index].SubItems[13].Text = searchId.ToString();

                break;

            /*case flag.Error_scan:
             *
             *  string mess = GetScanErrMess(message);
             *  button12.Enabled = true;
             *  button3.Enabled = true;
             *  break;*/

            case flag.Success_buy:

                string[] price = message.Split(';');

                double itemcost = Math.Round(Convert.ToSingle(WalletL.Text.Remove(0, 2)) - Convert.ToSingle(price[0]), 2);

                FlashWindow.Flash(this);

                WalletL.Text     = SteamParsing.Currencies.GetName() + " " + price[0];
                button3.Enabled  = true;
                button12.Enabled = true;

                for (int i = 0; i < SteamAutoFunction.TrackingList.Count; i++)
                {
                    if (SteamAutoFunction.TrackingList[i].Name.Equals(price[1]))
                    {
                        SteamAutoFunction.TrackingList[i].Purchased = true;
                        TraItemLV.Items[i].SubItems[8].Text         = "x";
                        TraItemLV.Items[i].SubItems[10].Text        = SteamParsing.Currencies.GetName() + " " + itemcost;
                        TraItemLV.Items[i].SubItems[11].Text        = DateTime.Today.AddDays(7).ToString();
                        if (SteamAutoFunction.TrackingList[i].Buy == true)
                        {
                            SteamAutoFunction.TrackingList[i].Buy = false;
                            TraItemLV.Items[i].SubItems[4].Text   = "";
                        }
                        if (SteamAutoFunction.TrackingList[i].Buying == true)
                        {
                            SteamAutoFunction.TrackingList[i].Buying = false;
                        }
                        SteamAutoFunction.TrackingList[i].Refresh.Stop();
                        break;
                    }
                }

                break;

            case flag.Error_buy:

                button3.Enabled = true;
                break;


            case flag.Load_progress:

                for (int a = 0; a < SteamAutoFunction.TrackingList.Count; a++)
                {
                    SteamAutoFunction.TrackingList[a].index = a;

                    string lp2 = SteamParsing.Currencies.GetName() + " " + string.Format("{0:N2}", SteamAutoFunction.TrackingList[a].StartPrice);
                    string mp2 = SteamParsing.Currencies.GetName() + " " + string.Format("{0:N2}", SteamAutoFunction.TrackingList[a].MedianPrice);

                    string buy = ""; string sell = ""; string pured = ""; string pp = "";

                    if (SteamAutoFunction.TrackingList[a].Buy)
                    {
                        buy = "x";
                    }
                    if (SteamAutoFunction.TrackingList[a].Sell)
                    {
                        sell = "x";
                    }
                    if (SteamAutoFunction.TrackingList[a].Purchased)
                    {
                        pured = "x";
                        pp    = SteamParsing.Currencies.GetName() + " " + string.Format("{0:N2}", SteamAutoFunction.TrackingList[a].PurchasePrice);
                    }

                    string[] row2 = { SteamAutoFunction.TrackingList[a].Game,
                                      SteamAutoFunction.TrackingList[a].Name,                  lp2,                                             mp2,                                    buy, sell,
                                      SteamAutoFunction.TrackingList[a].BuyPercent.ToString(),
                                      SteamAutoFunction.TrackingList[a].SellPercent.ToString(),pured,                                           SteamAutoFunction.TrackingList[a].Link,
                                      pp,                                                      SteamAutoFunction.TrackingList[a].purchasedate,
                                      SteamAutoFunction.TrackingList[a].hashname,              "" };
                    var      lst2 = new ListViewItem(row2);
                    TraItemLV.Items.Add(lst2);
                }

                break;

            case flag.Inventory_Loaded:

                button9.Enabled   = true;
                InvenLV.Enabled   = true;
                StatusPB.Image    = null;
                StatusLabel1.Text = "Ready";
                //SetInvFilter();

                //label4.Text = filteredInvList.Count.ToString();
                button1.Enabled = true;
                if (searchId == 0)
                {
                    FillInventoryList();

                    button7.Enabled = true;
                    if (comboBox1.SelectedIndex != 8)
                    {
                        button10.Enabled = true;
                    }
                    else
                    {
                        button10.Enabled = false;
                    }
                }
                else
                {
                    InvenLV.Items.Clear();
                    button10.Enabled = false;
                    MessageBox.Show("Inventory section is empty!", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                break;

            case flag.InvPrice:

                SteamLibrary.InventItem ourItem1 = (SteamLibrary.InventItem)data;

                string priceRes = SteamParsing.Currencies.GetName() + " " + SteamLibrary.DoFracture(ourItem1.BuyPrice);
                string priceMes = SteamParsing.Currencies.GetName() + " " + ourItem1.MedianPrice.ToString();

                InvenLV.Items[searchId].SubItems[2].Text = priceRes;
                InvenLV.Items[searchId].SubItems[3].Text = priceMes;

                textBox2.Text = SteamLibrary.DoFracture(ourItem1.BuyPrice);
                textBox2_KeyUp(this, null);

                textBox2.ReadOnly = false;

                button11.Enabled = true;
                InvenLV.Enabled  = true;

                break;

            case flag.Items_Sold:
                if (searchId != 1)
                {
                    StatusLabel1.Text = "Ready";
                    StatusPB.Image    = null;

                    button10.Text = "Set price";

                    int app = comboBox1.SelectedIndex;

                    SteamAuto.InventoryThreadExcute(app);
                }
                break;
            }
        }
コード例 #21
0
        public string ParseAdvanceSearchRes(string content, List <SteamLibrary.SearchItem> lst, CookieContainer cookieCont,
                                            bool isGame, string game, bool isMin, string min, bool isMax, string max, int countRes)
        {
            if (searchDone == true)
            {
                lst.Clear();
            }
            searchDone = false;
            string totalFind = "0";

            try
            {
                var searchJS = JsonConvert.DeserializeObject <SteamLibrary.SearchBody>(content);

                if (searchJS.Success)
                {
                    totalFind       = searchJS.TotalCount;
                    sppos.PageCount = Convert.ToInt32(totalFind) / SearchResCount;

                    //content = File.ReadAllText(@"C:\dollar2.html");
                    MatchCollection matches = Regex.Matches(searchJS.HtmlRes,
                                                            "(?<=market_listing_row_link\" href)(.*?)(?<=</a>)",
                                                            RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline);

                    if (matches.Count != 0)
                    {
                        foreach (Match match in matches)
                        {
                            string currmatch = match.Groups[1].Value;

                            //Fix for Steam update 5/01/14 4:00 PM PST
                            string ItemUrl = Regex.Match(currmatch, "(?<==\")(.*)(?=\" id)").ToString();

                            string[] input = ItemUrl.Split('/');
                            string   hash  = input[6];

                            string ItemQuan = Regex.Match(currmatch, "(?<=num_listings_qty\">)(.*)(?=</span>)").ToString();

                            //Fix for Steam update 3/26/14 4:00 PM PST
                            string ItemPrice = Regex.Match(currmatch,
                                                           "(?<=<span style=\"color:)(.*)(?=<div class=\"market_listing_right_cell)",
                                                           RegexOptions.Singleline).ToString();

                            if (SteamParsing.Currencies.NotSet)
                            {
                                SteamParsing.Currencies.GetType(ItemPrice);
                                //If not loggen in then
                                ItemPrice = Regex.Replace(ItemPrice, SteamParsing.Currencies.GetAscii(), string.Empty);
                                //currLst.NotSet = true;
                            }
                            else
                            {
                                ItemPrice = Regex.Replace(ItemPrice, SteamParsing.Currencies.GetAscii(), string.Empty);
                            }

                            ItemPrice = Regex.Replace(ItemPrice, @"[^\d\,\.]+", string.Empty);

                            bool pass = false;

                            if (isMin || isMax)
                            {
                                if (isMin && isMax)
                                {
                                    if (Convert.ToSingle(ItemPrice) > Convert.ToSingle(min) && (Convert.ToSingle(ItemPrice) < Convert.ToSingle(max)))
                                    {
                                        pass = true;
                                    }
                                }
                                else if (isMin)
                                {
                                    if (Convert.ToSingle(ItemPrice) > Convert.ToSingle(min))
                                    {
                                        pass = true;
                                    }
                                }
                                else
                                {
                                    if (Convert.ToSingle(ItemPrice) < Convert.ToSingle(max))
                                    {
                                        pass = true;
                                    }
                                }
                            }
                            else
                            {
                                pass = true;
                            }

                            if (pass)
                            {
                                //Fix fot Steam update 3/26/14 4:00 PM PST
                                string ItemName = Regex.Match(currmatch,
                                                              "(?<=listing_item_name\" style=\"color:)(.*)(?=</span>)").ToString();

                                ItemName = ItemName.Remove(0, ItemName.IndexOf(">") + 1);

                                string ItemGame = Regex.Match(currmatch, "(?<=game_name\">)(.*)(?=</span>)").ToString();

                                if (isGame)
                                {
                                    if (ItemGame.Equals(game))
                                    {
                                        string Median = "0";

                                        try
                                        {
                                            string gameid = SteamLibrary.GetApp(ItemGame).AppID;
                                            Median = SteamParseSite.ParseItemPrice(hash, gameid, cookieCont).P2;

                                            if (Median.Equals("Error"))
                                            {
                                                Median = "0";
                                            }
                                        }
                                        catch { }

                                        string ItemImg = Regex.Match(currmatch, "(?<=net/economy/image/)(.*)(/62fx62f)",
                                                                     RegexOptions.Singleline).ToString();

                                        SteamLibrary.SearchItem item = new SteamLibrary.SearchItem(ItemName, ItemGame, ItemUrl, ItemQuan,
                                                                                                   ItemPrice, ItemImg, Median);

                                        item.Hashname = hash;

                                        lst.Add(item);
                                    }
                                }
                                else
                                {
                                    string Median = "0";

                                    try
                                    {
                                        string gameid = SteamLibrary.GetApp(ItemGame).AppID;
                                        Median = SteamParseSite.ParseItemPrice(hash, gameid, cookieCont).P2;

                                        if (Median.Equals("Error"))
                                        {
                                            Median = "0";
                                        }
                                    }
                                    catch { }

                                    string ItemImg = Regex.Match(currmatch, "(?<=net/economy/image/)(.*)(/62fx62f)",
                                                                 RegexOptions.Singleline).ToString();

                                    SteamLibrary.SearchItem item = new SteamLibrary.SearchItem(ItemName, ItemGame, ItemUrl, ItemQuan,
                                                                                               ItemPrice, ItemImg, Median);

                                    item.Hashname = hash;

                                    lst.Add(item);
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("No item founded!", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception e)
            {
                SteamLibrary.AddtoLog(e.Message);
                MessageBox.Show("Error parsing search results.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (lst.Count < countRes)
            {
                DoAdvanceSearch(1, countRes, lastSrch, isGame, game, isMin, min, isMax, max);
            }
            else
            {
                doMessage(flag.Advance_search_success, 0, totalFind, true);
            }

            return(totalFind);
        }
コード例 #22
0
        public void LoginProgress(object sender, DoWorkEventArgs e)
        {
            LoginProcess = true;
            Logged       = false;

            var accInfo = SteamParseSite.GetNameBalance(cookieCont);

            if (accInfo != null)
            {
                doMessage(flag.Already_logged, 0, accInfo, true);
                LoginProcess = false;
                Logged       = true;
                return;
            }

            string mailCode  = string.Empty;
            string guardDesc = string.Empty;
            string capchaId  = string.Empty;
            string capchaTxt = string.Empty;
            string mailId    = string.Empty;

            //Login cycle
begin:

            var rRSA = GetRSA("toshigawa_tori", cookieCont);

            if (rRSA == null)
            {
                SteamLibrary.AddtoLog("Network Problem");
                doMessage(flag.Login_cancel, 0, "Network Problem", true);
                LoginProcess = false;
                return;
            }

            string finalpass = SteamLibrary.EncryptPassword(Password, rRSA.Module, rRSA.Exponent);

            string MainReq = string.Format(SteamLibrary.loginReq, finalpass, UserName, mailCode, guardDesc, capchaId,
                                           capchaTxt, mailId, rRSA.TimeStamp);

            string BodyResp = SteamParsing.SendPost(MainReq, SteamLibrary._dologin, SteamLibrary._ref, cookieCont, true);

            //Checking login problem
            if (BodyResp.Contains("message"))
            {
                var rProcess = JsonConvert.DeserializeObject <SteamLibrary.RespProcess>(BodyResp);

                //Checking Incorrect Login
                if (rProcess.Message.Contains("Incorrect"))
                {
                    SteamLibrary.AddtoLog("Incorrect login");
                    doMessage(flag.Login_cancel, 0, "Incorrect login", true);
                    LoginProcess = false;
                    return;
                }
                else
                {
                    //Login correct, checking message type...
                    Dialog guardCheckForm = new Dialog();

                    if ((rProcess.isCaptcha) && (rProcess.Message.Contains("humanity")))
                    {
                        //Verifying humanity, loading capcha
                        guardCheckForm.capchgroupEnab = true;
                        guardCheckForm.codgroupEnab   = false;

                        string newcap = SteamLibrary._capcha + rProcess.Captcha_Id;
                        SteamParsing.SteamSite.loadImg(newcap, guardCheckForm.capchImg, false, false);
                    }
                    else
                    if (rProcess.isEmail)
                    {
                        //Steam guard wants email code
                        guardCheckForm.capchgroupEnab = false;
                        guardCheckForm.codgroupEnab   = true;
                    }
                    else
                    {
                        //Whoops!
                        goto begin;
                    }

                    //Re-assign main request values
                    if (guardCheckForm.ShowDialog() == DialogResult.OK)
                    {
                        mailCode  = guardCheckForm.MailCode;
                        guardDesc = guardCheckForm.GuardDesc;
                        capchaId  = rProcess.Captcha_Id;
                        capchaTxt = guardCheckForm.capchaText;
                        mailId    = rProcess.Email_Id;
                        guardCheckForm.Dispose();
                    }
                    else
                    {
                        SteamLibrary.AddtoLog("Dialog has been cancelled!");
                        doMessage(flag.Login_cancel, 0, "Dialog has been cancelled!", true);
                        e.Cancel     = true;
                        Logged       = false;
                        LoginProcess = false;
                        guardCheckForm.Dispose();
                        return;
                    }

                    goto begin;
                }
            }
            else
            {
                //No Messages, Success!
                var rFinal = JsonConvert.DeserializeObject <SteamLibrary.RespFinal>(BodyResp);

                if (rFinal.Success && rFinal.isComplete)
                {
                    //Okay
                    var accInfo2 = SteamParseSite.GetNameBalance(cookieCont);

                    doMessage(flag.Login_success, 0, accInfo2, true);

                    Logged = true;
                    SteamLibrary.AddtoLog("Login Success");
                }
                else
                {
                    //Fail
                    goto begin;
                }
            }

            LoginProcess = false;
        }
コード例 #23
0
ファイル: Main.cs プロジェクト: leolongvu/SteamMangementBot
        private void button7_Click(object sender, EventArgs e)
        {
            if (SteamParsing.InventList.Count == 0)
            {
                MessageBox.Show("Please load inventory first!", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (InvenLV.SelectedItems.Count == 0)
            {
                MessageBox.Show("Please select one item!", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                int app = comboBox1.SelectedIndex;

                SteamAutoFunction.SellingList.Clear();

                for (int i = 0; i < InvenLV.SelectedItems.Count; i++)
                {
                    var ouritem = SteamParsing.InventList[InvenLV.SelectedItems[i].Index];
                    if ((ouritem.Marketable) && (!ouritem.BuyPrice.Equals("0")))
                    {
                        SteamAutoFunction.SellingList.Add(new SteamLibrary.ItemToSell(ouritem.AssetId,
                                                                                      SteamLibrary.CalcWithFee(ouritem.BuyPrice), SteamLibrary.GetAppFromIndex(app, false)));
                    }
                }

                if (SteamAutoFunction.SellingList.Count != 0)
                {
                    if (SteamAutoFunction.IsRemove)
                    {
                        StatusLabel1.Text = "Removing";
                        StatusPB.Image    = Properties.Resources.icon1;
                    }
                    else
                    {
                        StatusLabel1.Text = "Add to sell";
                        StatusPB.Image    = Properties.Resources.icon1;
                    }

                    //steam_srch.sellDelay = Convert.ToInt32(sellDelayBox.Text);
                    //steam_srch.isDelayRand = randomDelayBox.Checked;
                    SteamAuto.SellThreadExcute();
                }
                else
                {
                    MessageBox.Show("Select items to sell first!", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
コード例 #24
0
            public byte ParseLotList(string content, string myUserId, List <SteamLibrary.BuyItem> lst, bool full,
                                     bool ismain, bool IgnoreWarn)
            {
                lst.Clear();

                //Smart ass!
                if (/*Main.isHTML &&*/ ismain)
                {
                    string jsonAssets = Regex.Match(content, @"(?<=g_rgAssets \= )(.*)(?=;
	var g_rgCurrency)"    , RegexOptions.Singleline).ToString();

                    if (jsonAssets == string.Empty)
                    {
                        return(6);
                    }

                    string jsonListInfo = Regex.Match(content, @"(?<=g_rgListingInfo \= )(.*)(?=;
	var g_plotPriceHistory)"    , RegexOptions.Singleline).ToString();

                    content = "{" + string.Format(SteamLibrary.buildJson, jsonListInfo, jsonAssets) + "}";
                }
                else
                {
                    if (content == string.Empty)
                    {
                        //Content empty
                        return(0);
                    }
                    else if (content == "403")
                    {
                        //403 Forbidden
                        return(5);
                    }
                    else if (content.Length < 40)
                    {
                        //Move along
                        return(8);
                    }
                    else if (content[0] != '{')
                    {
                        //Json is not valid
                        return(2);
                    }
                }
                try
                {
                    //"success":false
                    if (content.Substring(11, 1) == "f")
                    {
                        return(1);
                    }

                    var pageJS = JsonConvert.DeserializeObject <SteamLibrary.PageBody>(content);

                    if (pageJS.Listing.Count != 0)
                    {
                        foreach (SteamLibrary.ListingInfo ourItem in pageJS.Listing.Values)
                        {
                            var ourItemInfo = pageJS.Assets[ourItem.asset.appid][ourItem.asset.contextid][ourItem.asset.id];

                            bool isNull = false;
                            if (ourItem.userId == myUserId)
                            {
                                continue;
                            }
                            if ((IgnoreWarn) && (ourItemInfo.warnings != null))
                            {
                                //Renamed Item or Descriprtion
                                SteamLibrary.AddtoLog(string.Format("{0}: {1}", ourItemInfo.name, ourItemInfo.warnings.ToString()));
                                continue;
                            }
                            if (ourItem.price != 0)
                            {
                                lst.Add(new SteamLibrary.BuyItem(ourItem.listingid, ourItem.price, ourItem.fee,
                                                                 new SteamLibrary.AppType(ourItem.asset.appid, ourItem.asset.contextid), ourItemInfo.name));
                                isNull = false;
                            }
                            else
                            {
                                isNull = true;
                            }
                            if (!full && !isNull)
                            {
                                return(7);
                            }
                        }
                    }
                    else
                    {
                        return(1);
                    }
                }
                catch (Exception e)
                {
                    //Parsing fail
                    SteamLibrary.AddtoLog("Err Source: " + e.Message);
                    return(3);
                }

                if (lst.Count == 0)
                {
                    return(0);
                }
                else
                {
                    //Fine!
                    return(7);
                }
            }