Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
* Scanning url with Filter
* Keep-alive turned off for scans
* Random-range delay for selling
  • Loading branch information
Maxx53 committed Jun 19, 2014
1 parent 5783c2e commit 76ba99a
Show file tree
Hide file tree
Showing 7 changed files with 2,052 additions and 2,050 deletions.
91 changes: 46 additions & 45 deletions scr/SCMBot/Main.Designer.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scr/SCMBot/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text.RegularExpressions;


Expand Down Expand Up @@ -1251,6 +1250,7 @@ private void SellButton_Click(object sender, EventArgs e)
}

steam_srch.sellDelay = Convert.ToInt32(sellDelayBox.Text);
steam_srch.isDelayRand = randomDelayBox.Checked;
steam_srch.ItemSell();

}
Expand Down
3,945 changes: 1,965 additions & 1,980 deletions scr/SCMBot/Main.resx

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions scr/SCMBot/MainUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public partial class Main
const string helpPage = homePage + "/wiki";

public const string cockPath = "coockies.dat";
const string steamUA = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; Valve Steam Client/1401381906; ) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safari/535.19";
const string steamUA = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36 OPR/22.0.1471.70";

//Just put here your random values
private const string initVector = "tu89geji340t89u2";
Expand Down Expand Up @@ -443,7 +443,7 @@ public static int GetFreeIndex()
}


public static string GetRequest(string url, CookieContainer cookie, bool UseProxy)
public static string GetRequest(string url, CookieContainer cookie, bool UseProxy, bool keepAlive)
{
string content = string.Empty;
int proxyNum = 0;
Expand All @@ -458,8 +458,9 @@ public static string GetRequest(string url, CookieContainer cookie, bool UseProx
//New
request.Proxy = null;
request.Timeout = 30000;

//KeepAlive is True by default
//request.KeepAlive = true;
request.KeepAlive = keepAlive;

//LOL, really?
request.UserAgent = steamUA;
Expand Down
2 changes: 1 addition & 1 deletion scr/SCMBot/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 26 additions & 10 deletions scr/SCMBot/SteamSite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ partial class SteamSite
public bool NotSetHead { get; set; }

public int sellDelay { get; set; }
public bool isDelayRand { get; set; }

public static string myUserId;

Expand Down Expand Up @@ -125,7 +126,7 @@ public void CancelLogin()
public void Logout()
{
ThreadStart threadStart = delegate() {
SendGet(_logout, cookieCont, false);
SendGet(_logout, cookieCont, false, true);
doMessage(flag.Logout_, 0, string.Empty, true);
Logged = false;
};
Expand All @@ -138,7 +139,7 @@ public void ChangeLng(string lang)
{
ThreadStart threadStart = delegate()
{
SendGet(_lang_chg + lang, cookieCont, false);
SendGet(_lang_chg + lang, cookieCont, false, true);
doMessage(flag.Lang_Changed, 0, lang, true);
};
Thread pTh = new Thread(threadStart);
Expand Down Expand Up @@ -221,7 +222,7 @@ public void GetPriceTread(string appid, string markname, int pos, bool isInv)
try
{

var priceOver = JsonConvert.DeserializeObject<PriceOverview>(SendGet(string.Format(priceOverview, Main.jsonAddon, appid, markname), cookieCont, false));
var priceOver = JsonConvert.DeserializeObject<PriceOverview>(SendGet(string.Format(priceOverview, Main.jsonAddon, appid, markname), cookieCont, false, true));

if (priceOver.Success)
{
Expand Down Expand Up @@ -258,11 +259,11 @@ private void getInventory_DoWork(object sender, DoWorkEventArgs e)
if (!LoadOnSale)
{
invCount = ParseInventory(SendGet(string.Format(_jsonInv, myUserId, GetUrlApp(invApp, true).App),
cookieCont, false));
cookieCont, false, true));
}
else
{
invCount = ParseOnSale(SendGet(_market, cookieCont, false), currencies);
invCount = ParseOnSale(SendGet(_market, cookieCont, false, true), currencies);
}

if (invCount > 0)
Expand All @@ -288,6 +289,11 @@ private void sellThread_DoWork(object sender, DoWorkEventArgs e)
if (cunt > 0)
isSleep = true;


Random random = new Random();
int min = sellDelay / 2;
int max = sellDelay * 2;

for (int i = 0; i < cunt; i++)
{

Expand All @@ -310,7 +316,14 @@ private void sellThread_DoWork(object sender, DoWorkEventArgs e)
doMessage(flag.Sell_progress, 0, (incr * (i + 1)).ToString(), true);

if ((isSleep) && (i != cunt - 1))
{
if (isDelayRand)
{
Thread.Sleep(random.Next(min, max));
}
else
Thread.Sleep(sellDelay);
}
}

doMessage(flag.Items_Sold, 0, string.Empty, true);
Expand All @@ -325,7 +338,7 @@ private void sellThread_DoWork(object sender, DoWorkEventArgs e)
private void reqThread_DoWork(object sender, DoWorkEventArgs e)
{

doMessage(flag.Search_success, 0, ParseSearchRes(SendGet(linkTxt, cookieCont, false), searchList, currencies), true);
doMessage(flag.Search_success, 0, ParseSearchRes(SendGet(linkTxt, cookieCont, false, true), searchList, currencies), true);
}


Expand Down Expand Up @@ -561,7 +574,7 @@ public bool fillLotList(string link, bool full, bool ismain)
else
{
lotList.Clear();
byte ret = ParseLotList(SendGet(link, cookieCont, true), lotList, currencies, full);
byte ret = ParseLotList(SendGet(link, cookieCont, true, false), lotList, currencies, full);

if (ret != 7)
{
Expand All @@ -585,7 +598,8 @@ public string UrlForRender(string input)
}
else
{
url = url.Insert(fint, "/render" + Main.jsonAddon + "/");
//fix
url = url.Replace("?", "/render"+ Main.jsonAddon + "&");
}
return url;
}
Expand All @@ -601,7 +615,7 @@ public void scanThread_DoWork(object sender, DoWorkEventArgs e)

if (BuyNow)
{
ParseLotList(SendGet(url, cookieCont, false), lotList, currencies, false);
ParseLotList(SendGet(url, cookieCont, false, true), lotList, currencies, false);

if (lotList.Count == 0)
{
Expand Down Expand Up @@ -744,7 +758,7 @@ private void StartResellThread(string lotPrice, string resellPrice, AppType appT
}

//You get the point!
ParseInventory(SendGet(string.Format(_jsonInv, myUserId, appType.App + "/" + appType.Context), cookieCont, false));
ParseInventory(SendGet(string.Format(_jsonInv, myUserId, appType.App + "/" + appType.Context), cookieCont, false, true));

var req = string.Format(sellReq, GetSessId(cookieCont), appType.App, appType.Context, inventList.Find(p => p.Name == markName).AssetId, sellPrice.ToString());

Expand All @@ -765,6 +779,8 @@ private void StartResellThread(string lotPrice, string resellPrice, AppType appT

}



}

}
Expand Down
19 changes: 9 additions & 10 deletions scr/SCMBot/SteamUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,12 @@ private string SendPost(string data, string url, string refer, bool tolog)

}

private string SendGet(string url, CookieContainer cok, bool UseProxy)
private string SendGet(string url, CookieContainer cok, bool UseProxy, bool keepAlive)
{
Main.reqPool.WaitOne();

doMessage(flag.StripImg, 0, string.Empty, true);
var res = Main.GetRequest(url, cookieCont, UseProxy);
var res = Main.GetRequest(url, cookieCont, UseProxy, keepAlive);
doMessage(flag.StripImg, 1, string.Empty, true);

//MessageBox.Show("blocked");
Expand Down Expand Up @@ -644,7 +644,7 @@ 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);
string markpage = SendGet(_market, cock, false, true);

//For testring purposes!
//string markpage = File.ReadAllText(@"C:\dollars.html");
Expand Down Expand Up @@ -768,11 +768,6 @@ public byte ParseLotList(string content, List<ScanItem> lst, CurrInfoLst currLst
//Content empty
return 0;
}
else if ((content.Length < 200) && (content[0] == '{'))
{
//Json without data
return 1;
}
else if (content == "403")
{
//403 Forbidden
Expand All @@ -786,10 +781,13 @@ public byte ParseLotList(string content, List<ScanItem> lst, CurrInfoLst currLst

try
{
//"success":false
if (content.Substring(11, 1) == "f")
return 1;

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

if (pageJS.Listing.Count != 0 && pageJS.Success == true)
if (pageJS.Listing.Count != 0)
{
foreach (ListingInfo ourItem in pageJS.Listing.Values)
{
Expand Down Expand Up @@ -839,7 +837,8 @@ public byte ParseLotList(string content, List<ScanItem> lst, CurrInfoLst currLst
catch(Exception e)
{
//Parsing fail
Main.AddtoLog("Err Source: " + e.Source);
Main.AddtoLog("Err Source: " + e.Message);
System.IO.File.WriteAllText("xxx.txt", content);
return 3;
}

Expand Down

0 comments on commit 76ba99a

Please sign in to comment.