Skip to content

Commit

Permalink
various fixes (#536)
Browse files Browse the repository at this point in the history
* added client language check

* fixed poe.ninja api url

* timeouts, improved StartupLog, update/notes
  • Loading branch information
Eruyome authored Oct 1, 2017
1 parent 7a637f2 commit 2ec89ac
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 13 deletions.
Binary file modified Fallback.exe
Binary file not shown.
54 changes: 54 additions & 0 deletions lib/PoEScripts_CheckCorrectClientLanguage.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
PoEScripts_CheckCorrectClientLanguage() {
iniPath := A_MyDocuments . "\My Games\Path of Exile\"
configs := []
productionIni := iniPath . "production_Config.ini"
betaIni := iniPath . "beta_Config.ini"

configs.push(productionIni)
configs.push(betaIni)
If (not FileExist(productionIni) and not FileExist(betaIni)) {
Loop %iniPath%\*.ini
{
configs.push(iniPath . A_LoopFileName)
}
}

wrongLanguage := false
readFile := ""
For key, val in configs {
IniRead, language, %val%, LANGUAGE, language
If (language != "ERROR") {
If (language != "en") {
wrongLanguage := true
}
RegExMatch(val, "i)([^\\]+)\.[^\\]+$", readFile)
Break
}
}

If (wrongLanguage) {
msg := "It seems that you aren't using 'English' as your game clients language, according to the file '" readFile "'." "`n`n"
msg .= "As long as GGG doesn't add a way to get the items data in english when using different game clients, this script won't work with those languages." "`n`n"
msg .= "Please change your language or click 'continue' if you want to start the script anyway."

MsgBox, 0x1012, Wrong PoE Game Client Language, % msg

IfMsgBox, Ignore
{
Return 1
}
IfMsgBox, Retry
{
PoEScripts_CheckCorrectClientLanguage()
}
IfMsgBox, Cancel
{
Return 0
}
IfMsgBox, Abort
{
Return 0
}
}
Return 1
}
2 changes: 1 addition & 1 deletion lib/PoEScripts_CheckFolderWriteAccess.ahk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PoE_Scripts_CheckFolderWriteAccess(Folder, critical = true) {
PoEScripts_CheckFolderWriteAccess(Folder, critical = true) {
access := FolderWriteAccess(Folder)

msg := "The script is not able to write any file to " Folder ".`nYour user may not have the necessary permissions. "
Expand Down
11 changes: 8 additions & 3 deletions lib/PoEScripts_Download.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,14 @@
If (StrLen(ioData)) {
commandData .= "--data """ ioData """ "
}

commandData .= "--max-time 90 "
commandHdr .= "--max-time 90 "

If (binaryDL) {
commandData .= "--connect-timeout 30 "
commandData .= "--connect-timeout 30 "
} Else {
commandData .= "--max-time 30 "
commandHdr .= "--max-time 30 "
}

; get data
html := StdOutStream(curl """" url """" commandData)
Expand Down
6 changes: 6 additions & 0 deletions resources/Updates_Trade.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
The following is a list of what has been updated, starting with 1.1.0

2.5.7
================================================================================================
Added client language check since ItemInfo/TradeMacro only work with the english client.
Fixed the changed poe.ninja API url.
Improved cURL timeouts and StartupLog.txt.

2.5.6
================================================================================================
Changed the currency search tooltip to show 4 decimal places.
Expand Down
2 changes: 1 addition & 1 deletion resources/VersionTrade.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
TradeReleaseVersion := "v2.5.6"
TradeReleaseVersion := "v2.5.7"
TradeAHKVersionRequired := "1.1.26.00"
4 changes: 4 additions & 0 deletions resources/ahk/Merge_ItemInfo.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
; ####################################################################################################
#Include, %A_ScriptDir%\..\..\lib\PoEScripts_CheckFolderWriteAccess.ahk
#Include, %A_ScriptDir%\..\..\lib\PoEScripts_CompareUserFolderWithScriptFolder.ahk
#Include, %A_ScriptDir%\..\..\lib\PoEScripts_CheckCorrectClientLanguage.ahk
#Include, %A_ScriptDir%\..\..\lib\PoEScripts_CreateTempFolder.ahk
#Include, %A_ScriptDir%\..\..\lib\PoEScripts_HandleUserSettings.ahk

Expand All @@ -23,6 +24,9 @@ projectName := "PoE-ItemInfo"
PoE_Scripts_CheckFolderWriteAccess(A_MyDocuments . "\" . projectName)
PoE_Scripts_CheckFolderWriteAccess(scriptDir)

If (not PoEScripts_CheckCorrectClientLanguage()) {
ExitApp
}
If (!PoEScripts_CreateTempFolder(scriptDir, projectName)) {
ExitApp
}
Expand Down
8 changes: 6 additions & 2 deletions resources/ahk/Merge_TradeMacro.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
; #####################################################################################################################
#Include, %A_ScriptDir%\..\..\lib\PoEScripts_CheckFolderWriteAccess.ahk
#Include, %A_ScriptDir%\..\..\lib\PoEScripts_CompareUserFolderWithScriptFolder.ahk
#Include, %A_ScriptDir%\..\..\lib\PoEScripts_CheckCorrectClientLanguage.ahk
#Include, %A_ScriptDir%\..\..\lib\PoEScripts_CreateTempFolder.ahk
#Include, %A_ScriptDir%\..\..\lib\PoEScripts_HandleUserSettings.ahk

Expand Down Expand Up @@ -38,9 +39,12 @@ projectName := "PoE-TradeMacro"
Check some folder permissions
*/

PoE_Scripts_CheckFolderWriteAccess(A_MyDocuments . "\" . projectName)
PoE_Scripts_CheckFolderWriteAccess(scriptDir)
PoEScripts_CheckFolderWriteAccess(A_MyDocuments . "\" . projectName)
PoEScripts_CheckFolderWriteAccess(scriptDir)

If (not PoEScripts_CheckCorrectClientLanguage()) {
ExitApp
}
If (!PoEScripts_CreateTempFolder(scriptDir, projectName)) {
ExitApp
}
Expand Down
2 changes: 1 addition & 1 deletion resources/ahk/POE-ItemInfo.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -10544,7 +10544,7 @@ FetchCurrencyData:

Loop, % currencyLeagues.Length() {
currencyLeague := currencyLeagues[A_Index]
url := "http://poeninja.azureedge.net/api/Data/GetCurrencyOverview?league=" . currencyLeague
url := "http://poe.ninja/api/Data/GetCurrencyOverview?league=" . currencyLeague
file := A_ScriptDir . "\temp\currencyData_" . currencyLeague . ".json"
UrlDownloadToFile, %url% , %file%

Expand Down
5 changes: 2 additions & 3 deletions resources/ahk/TradeMacro.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -3123,7 +3123,6 @@ TradeFunc_AdvancedPriceCheckGui(advItem, Stats, Sockets, Links, UniqueStats = ""
}

; make sure that the lower vaule is always min (reduced mana cost of minion skills)
console.log(switchValue)
If (not StrLen(switchValue)) {
minLabelFirst := minLF
maxLabelFirst := maxLF
Expand Down Expand Up @@ -3781,7 +3780,7 @@ ReadPoeNinjaCurrencyData:
sampleValue := ChaosEquivalents["Chaos Orb"]
league := TradeUtils.UriEncode(TradeGlobals.Get("LeagueName"))
fallback := ""
url := "http://poeninja.azureedge.net/api/Data/GetCurrencyOverview?league=" . league
url := "http://poe.ninja/api/Data/GetCurrencyOverview?league=" . league
parsedJSON := TradeFunc_DowloadURLtoJSON(url, sampleValue)

; fallback to Standard and Hardcore league if used league seems to not be available
Expand All @@ -3794,7 +3793,7 @@ ReadPoeNinjaCurrencyData:
fallback := "Standard"
}

url := "http://poeninja.azureedge.net/api/Data/GetCurrencyOverview?league=" . league
url := "http://poe.ninja/api/Data/GetCurrencyOverview?league=" . league
parsedJSON := TradeFunc_DowloadURLtoJSON(url, sampleValue, true, league)
}
global CurrencyHistoryData := parsedJSON.lines
Expand Down
8 changes: 6 additions & 2 deletions resources/ahk/TradeMacroInit.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -1290,8 +1290,12 @@ TradeFunc_DownloadDataFiles() {
Loop % files.Length() {
file := files[A_Index]
filePath = %dir%\%file%
FileCopy, %filePath%, %filePath%.bak
output := PoEScripts_Download(url . file, postData := "", reqHeaders := "", options := "", false)
FileCopy, %filePath%, %filePath%.bak
output := PoEScripts_Download(url . file, postData := "", ioHdr := reqHeaders := "", options := "", false, false, false, "", reqHeadersCurl)
If (A_Index = 1) {
TradeFunc_WriteToLogFile("Data file download from " url "...`n`n" "cURL command:`n" reqHeadersCurl "`n`nAnswer:`n" ioHdr)
}

FileDelete, %filePath%
FileAppend, %output%, %filePath%

Expand Down

0 comments on commit 2ec89ac

Please sign in to comment.