Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;*****************************************
- ;TaruUpdater.au3 by Tarumes
- ;AutoIt3
- ;http://creativecommons.org/licenses/by/4.0/
- ;Old Version without GUI http://pastebin.com/ybAN2aij
- ;*****************************************
- ;
- ;
- ; Add this to the first 50 lines of YOURPLUGIN.js in comment section
- ; <taruupdateurl>http://xxxx.xx</taruupdateurl> url to raw scriptfile
- ; <taruversion>0001</taruversion> version of your script (only numbers)
- ; <tarucompatible>0001</tarucompatible> last compatible config to actual build
- ;
- ; Compile this script with AutoIt3 and copy exe to project root
- ;
- #include <Array.au3>
- #include <FileConstants.au3>
- #include <MsgBoxConstants.au3>
- #include <WinAPIFiles.au3>
- #include <File.au3>
- #include <StaticConstants.au3>
- #include <GUIConstantsEx.au3>
- #include <WindowsConstants.au3>
- #Include <GuiButton.au3>
- $GUI = GUICreate("TaruUpdater",250,110,-1,-1,-1,-1)
- $btn_update = GUICtrlCreateButton("Update",10,60,230,30,-1,-1)
- GUICtrlCreateLabel("before you run an update make a backup",10,10,230,42,-1,-1)
- GUICtrlSetBkColor(-1,"-2")
- GUISetState(@SW_SHOW,$GUI)
- Global $pluginlist = _FileListToArray( "./js/plugins/", "*", Default, True)
- If @error = 1 Then
- MsgBox(16, "", "No Files\Folders Found.")
- Exit
- EndIf
- While 1
- $nMsg = GUIGetMsg()
- Switch $nMsg
- Case $btn_update
- Call("RunUpdate")
- Case $GUI_EVENT_CLOSE
- Exit
- EndSwitch
- WEnd
- Func RunUpdate()
- For $i = 1 To $pluginlist[0]
- Global $read = FileRead( $pluginlist[$i])
- Global $url = StringRegExp ( $read, '(?i)<taruupdateurl>(.*?)</taruupdateurl>', 1)
- Global $version = StringRegExp ( $read, '(?i)<taruversion>(.*?)</taruversion>', 1)
- Global $compatible = StringRegExp ( $read, '(?i)<tarucompatible>(.*?)</tarucompatible>', 1)
- If @error = 0 Then
- Global $binary = InetRead ( $url[0], 1)
- Global $iread = BinaryToString( $binary )
- Global $iurl = StringRegExp ( $iread, '(?i)<taruupdateurl>(.*?)</taruupdateurl>', 1)
- Global $iversion = StringRegExp ( $iread, '(?i)<taruversion>(.*?)</taruversion>', 1)
- Global $icompatible = StringRegExp ( $iread, '(?i)<tarucompatible>(.*?)</tarucompatible>', 1)
- MsgBox(64,"iversion",$iversion,0)
- If $iversion[0] > $version[0] Then
- If $icompatible[0] <= $compatible[0] Then
- $result = MsgBox(260,"Update","You can update " & $pluginlist[$i],0)
- switch $result
- case 6
- Global $hFileOpen = FileOpen($pluginlist[$i], 2)
- FileWrite ( $pluginlist[$i], $iread )
- FileClose( $hFileOpen )
- case 7
- endswitch
- Else
- $result = MsgBox(68,"Update","You can update " & $pluginlist[$i] & "but plugin has changed you must edit your config",0)
- switch $result
- case 6
- Global $hFileOpen = FileOpen($pluginlist[$i], 2)
- FileWrite ( $pluginlist[$i], $iread )
- FileClose( $hFileOpen )
- case 7
- endswitch
- EndIf
- Else
- MsgBox(64,"Nothing to Update","All Scripts Up to Date or not Compatible with TaruUpdater",0)
- EndIf
- EndIf
- Next
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment