From 61ddc50707334b945a3de51bd147170c789dd0ad Mon Sep 17 00:00:00 2001 From: Maxx53 Date: Wed, 17 Sep 2014 14:10:58 +0400 Subject: [PATCH] MYR/RM currency support OnSale price regex fix --- scr/SCMBot/Properties/Settings.Designer.cs | 2 +- scr/SCMBot/SteamUtils.cs | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/scr/SCMBot/Properties/Settings.Designer.cs b/scr/SCMBot/Properties/Settings.Designer.cs index e7ddd59..d48682b 100644 --- a/scr/SCMBot/Properties/Settings.Designer.cs +++ b/scr/SCMBot/Properties/Settings.Designer.cs @@ -320,7 +320,7 @@ public bool ignoreWarn [global::System.Configuration.SettingsProviderAttribute(typeof(PortableSettingsProvider))] [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("100")] + [global::System.Configuration.DefaultSettingValueAttribute("0")] public int StopFunds { get diff --git a/scr/SCMBot/SteamUtils.cs b/scr/SCMBot/SteamUtils.cs index 39786ce..784b089 100644 --- a/scr/SCMBot/SteamUtils.cs +++ b/scr/SCMBot/SteamUtils.cs @@ -161,7 +161,7 @@ public class CurrInfoLst : List { public CurrInfoLst() { - //1 for USD, 2 for GBP, 3 for EUR, 5 for RUB, 7 for BRL + //1 for USD, 2 for GBP, 3 for EUR, 5 for RUB, 7 for BRL, 11 for MYR this.Add(new CurrencyInfo("$", "$", "1")); this.Add(new CurrencyInfo("pуб.", "руб.", "5")); @@ -170,6 +170,8 @@ public CurrInfoLst() //Fixed, thanks to Brasilian guy. this.Add(new CurrencyInfo("R$", "R$", "7")); + //Fixed, thanks to Malaysian guy. + this.Add(new CurrencyInfo("RM", "RM", "11")); this.NotSet = true; this.Current = 0; } @@ -649,10 +651,11 @@ public static AppType GetUrlApp(int appIndx, bool isGetInv) public StrParam GetNameBalance(CookieContainer cock, CurrInfoLst currLst) { Main.AddtoLog("Getting account name and balance..."); + string markpage = SendGet(_market, cock, false, true); //For testring purposes! - //string markpage = File.ReadAllText(@"C:\dollars.html"); + //string markpage = System.IO.File.ReadAllText(@"C:\myr.htm"); //Fix to getting name regex string parseName = Regex.Match(markpage, "(?<=buynow_dialog_myaccountname\">)(.*)(?=)").ToString().Trim(); @@ -675,6 +678,7 @@ public StrParam GetNameBalance(CookieContainer cock, CurrInfoLst currLst) string strlang = Regex.Match(markpage, "(?<=g_strLanguage = \")(.*)(?=\";)").ToString(); currLst.GetType(parseAmount); + parseAmount = currLst.ReplaceAscii(parseAmount); //?country=RU&language=russian¤cy=5&count=20 @@ -1013,10 +1017,13 @@ public int ParseOnSale(string content, CurrInfoLst currLst) string appidRaw = Regex.Match(currmatch, "(?<=market_listing_item_name_link)(.*)(?=)").ToString(); string pageLnk = Regex.Match(appidRaw, "(?<=href=\")(.*)(?=\">)").ToString(); - string captainPrice = Regex.Match(currmatch, "(?<=This is the price the buyer pays.\">)(.*)(?=This is how much you will receive)", RegexOptions.Singleline).ToString().Trim(); - - captainPrice = GetSweetPrice(Regex.Replace(captainPrice, currLst.GetAscii(), string.Empty)); + //phuckin' shit + string captainPrice = Regex.Match(currmatch, @"(?<=> + )(.*)(?= +
)", RegexOptions.Singleline).ToString(); + captainPrice = GetSweetPrice(Regex.Replace(captainPrice, currLst.GetAscii(), string.Empty).Trim()); + string[] LinkName = Regex.Match(currmatch, "(?<=_name_link\" href=\")(.*)(?=
)").ToString().Split(new string[] { "\">" }, StringSplitOptions.None); string ItemType = Regex.Match(currmatch, "(?<=_listing_game_name\">)(.*)(?=)").ToString(); @@ -1026,9 +1033,9 @@ public int ParseOnSale(string content, CurrInfoLst currLst) } } - else + // else //TODO. Add correct error processing - MessageBox.Show(Strings.OnSaleErr, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); + // MessageBox.Show(Strings.OnSaleErr, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); return matches.Count; }