You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.3 KiB
Plaintext

; GITEA Functions
;------------------------------------------------
CheckForUpdates(GitReleasesAPIURL, CurrentVersionNumber := 0){
Message = Checking For Updates at %GitReleasesAPIURL%
SaveOrPostProgress(Message,PostType:="ErrorLoggingTextFile")
data := URLDownloadToVar(GitReleasesAPIURL)
; Msgbox % "data: " data
try, parsed := JSON.Load(data)
catch e {
Message = Failed to check for updates. Gitea Releases API returned blank or malformed data.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return
}
LatestReleaseVersionNumber := parsed.1.name
if(CurrentVersionNumber >= LatestReleaseVersionNumber)
UpdateAvailable := 0
else,
UpdateAvailable := 1
ToolTip
return UpdateAvailable
}
UpdateScript(){
data := URLDownloadToVar(GitReleasesAPIURL)
try parsed := JSON.Load(data)
catch e {
Message = Failed to check for updates. Gitea Releases API returned blank or malformed data.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return
}
UpdateVersionNumber := parsed.1.name
ChangeLog := parsed.1.body
exename := parsed.1.assets.1.name
exeURL := parsed.1.assets.1.browser_download_url
ExeName := StrReplace(exename, ".exe", "")
UpdateExeName = %exename% %UpdateVersionNumber%.exe
UpdateExeFilepath = %A_ScriptDir%\%UpdateExeName%
if(ScriptVersion =< UpdateVersionNumber){
; IniWrite, 0, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable
MsgBox, You are Up-To-Date, There are no new updates to download.
; IniRead, UpdateAvailable, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable, 0
return
}
Changelog = %ScriptVersion% --> %UpdateVersionNumber%`n%Changelog%
OnMessage(0x44, "OnMsgBoxUpdateAvailable")
MsgBox 0x44, Update Available, %Changelog%
OnMessage(0x44, "")
IfMsgBox Yes, {
Return
}
Else IfMsgBox No, {
SaveOrPostProgress(Message:="Downloading Update",PostType:="Tooltip,ErrorLoggingTextFile")
UrlDownloadToFile, %exeURL%, %UpdateExeFilepath%
run, "%UpdateExeFilepath%" "%A_ScriptFullPath%"
ExitApp
}
return
}