first commit
This commit is contained in:
commit
d882f43854
80
Gitea-API.ahk
Normal file
80
Gitea-API.ahk
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
; GITEA Functions
|
||||||
|
;------------------------------------------------
|
||||||
|
CheckForUpdates(GitReleasesAPIURL){
|
||||||
|
; msgbox, checking for updates
|
||||||
|
Message = Checking For Updates
|
||||||
|
SaveOrPostProgress(Message,PostType:="ErrorLoggingTextFile")
|
||||||
|
|
||||||
|
data := URLDownloadToVar(GitReleasesAPIURL)
|
||||||
|
; Msgbox % "data: " data
|
||||||
|
|
||||||
|
parsed := JSON.Load(data)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
parsed := JSON.Load(data)
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user