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.

91 lines
2.8 KiB
Plaintext

; GITEA Functions
;------------------------------------------------
CheckForUpdates(GitReleasesAPIURL){
; msgbox, checking for updates
Message = Checking For Updates
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
}
UpdateVersionNumber := parsed.1.name
; Message = UpdateVersionNumber: %UpdateVersionNumber%
; DevModeMsgBox(Message)
if(ScriptVersion = UpdateVersionNumber OR ScriptVersion > UpdateVersionNumber){
ToolTip
return 0
}
else, {
UpdateAvailable := 1
; msgbox, update found!
Message = Program Update Found
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile")
; IniWrite, 1, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable
; ToolTip
return 1
}
}
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
; Msgbox % "UpdateVersionNumber: " UpdateVersionNumber
; msgbox, Version: %Version%
; Msgbox % "ChangeLog: " ChangeLog
; Msgbox % "exeURL: " exeURL
; Msgbox % "exename: " exename
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
; 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")
; Msgbox, downloading to: %A_ScriptDir%\%UpdateExeName%
UrlDownloadToFile, %exeURL%, %UpdateExeFilepath%
run, "%UpdateExeFilepath%" "%A_ScriptFullPath%"
ExitApp
}
return
}