Skip to content

Commit

Permalink
added currency stock to currency search
Browse files Browse the repository at this point in the history
  • Loading branch information
Eruyome committed Oct 28, 2016
1 parent 122be5b commit f1713e7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
26 changes: 19 additions & 7 deletions trade_data/TradeMacro.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -1068,17 +1068,19 @@ TradeFunc_ParseCurrencyHtml(html, payload){
Title .= StrPad("IGN" ,10)
Title .= StrPad("| Ratio",20)
Title .= "| " . StrPad("Buy ",20, "Left")
Title .= StrPad("Pay",20)
Title .= StrPad("Pay",18)
Title .= StrPad("| Stock",8)
Title .= "`n"

Title .= StrPad("----------" ,10)
Title .= StrPad("--------------------",20)
Title .= StrPad("--------------------",20)
Title .= StrPad("--------------------",20)
Title .= StrPad("--------------------",18)
Title .= StrPad("--------",8)
Title .= "`n"

While A_Index < NoOfItemsToShow {
Offer := TradeUtils.StrX( html, "data-username=""", N, 0, "<a href" , 1,1, N )
Offer := TradeUtils.StrX( html, "data-username=""", N, 0, "Contact Seller" , 1,1, N )
SellCurrency:= TradeUtils.StrX( Offer, "data-sellcurrency=""", 1,19, """" , 1,1, T )
SellValue := TradeUtils.StrX( Offer, "data-sellvalue=""", 1,16, """" , 1,1, T )
BuyValue := TradeUtils.StrX( Offer, "data-buyvalue=""", 1,15, """" , 1,1, T )
Expand All @@ -1088,6 +1090,15 @@ TradeFunc_ParseCurrencyHtml(html, payload){
RatioBuying := BuyValue / SellValue
RatioSelling := SellValue / BuyValue

Pos := RegExMatch(Offer, "si)displayoffer-bottom(.*)", StockMatch)
Loop, Parse, StockMatch, `n, `r
{
RegExMatch(TradeUtils.CleanUp(A_LoopField), "i)Stock:? ?(\d+) ", StockMatch)
If (StockMatch) {
Stock := StockMatch1
}
}

Pos := RegExMatch(Offer, "si)displayoffer-primary(.*)<.*displayoffer-centered", Display)
P := ""
DisplayNames := []
Expand All @@ -1106,6 +1117,7 @@ TradeFunc_ParseCurrencyHtml(html, payload){
Title .= StrPad("| " . "1 <-- " . TradeUtils.ZeroTrim(RatioBuying) ,20)
Title .= StrPad("| " . StrPad(DisplayNames[1] . " " . StrPad(TradeUtils.ZeroTrim(SellValue), 4, "left"), 17, "left") ,20)
Title .= StrPad("<= " . StrPad(TradeUtils.ZeroTrim(BuyValue), 4) . " " . DisplayNames[3] ,20)
Title .= StrPad("| " . Stock,8)
Title .= "`n"
}

Expand Down Expand Up @@ -2360,13 +2372,13 @@ AdvancedPriceCheckGui(advItem, Stats, Sockets, Links, UniqueStats = "", ChangedI
}

AdvancedPriceCheckSearch:
TradeFunc_HandleGuiSubmit()
TradeFunc_Main(false, false, true)
TradeFunc_HandleGuiSubmit()
TradeFunc_Main(false, false, true)
return

AdvancedOpenSearchOnPoeTrade:
TradeFunc_HandleGuiSubmit()
TradeFunc_Main(true, false, true)
TradeFunc_HandleGuiSubmit()
TradeFunc_Main(true, false, true)
return

TradeFunc_ResetGUI(){
Expand Down
18 changes: 16 additions & 2 deletions trade_data/TradeMacroInit.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,10 @@ TradeFunc_GetLeagues(){
leagues := []
Loop, Parse, JSONFile, `n, `r
{
If RegExMatch(A_LoopField,"iOm)id *: *""\(|\)""",leagueNames) {
If RegExMatch(A_LoopField,"im)id *: *""\(|\)""",leagueNames) {
continue
}
If RegExMatch(A_LoopField,"iOm)id *: *""(.*)""",leagueNames) {
Else If RegExMatch(A_LoopField,"iOm)id *: *""(.*)""",leagueNames) {
If (RegExMatch(leagueNames[1], "i)^Standard$")) {
leagues["standard"] := leagueNames[1]
}
Expand Down Expand Up @@ -602,12 +602,26 @@ TradeFunc_GetLatestRelease() {

;https://api.github.com/repos/thirdy/POE-TradeMacro/releases/latest
Try {
Encoding := "utf-8"
HttpObj.Open("GET",url)
HttpObj.SetRequestHeader("Content-type","application/html")
HttpObj.Send("")
HttpObj.WaitForResponse()
html := HttpObj.ResponseText

If Encoding {
oADO := ComObjCreate("adodb.stream")
oADO.Type := 1
oADO.Mode := 3
oADO.Open()
oADO.Write( HttpObj.ResponseBody )
oADO.Position := 0
oADO.Type := 2
oADO.Charset := Encoding
html := oADO.ReadText()
oADO.Close()
}

RegExMatch(html, "i)""tag_name"":""(.*?)""", tag)
RegExMatch(html, "i)""name"":""(.*?)""", vName)
RegExMatch(html, "i)""html_url"":""(.*?)""", url)
Expand Down

0 comments on commit f1713e7

Please sign in to comment.