tarumes

[RMMV] TaruPluginUpdater

Oct 28th, 2015
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 3.64 KB | None | 0 0
  1. ;*****************************************
  2. ;TaruUpdater.au3 by Tarumes
  3. ;AutoIt3
  4. ;http://creativecommons.org/licenses/by/4.0/
  5. ;Old Version without GUI http://pastebin.com/ybAN2aij
  6. ;*****************************************
  7. ;
  8. ;
  9. ;       Add this to the first 50 lines of YOURPLUGIN.js in comment section
  10. ;       <taruupdateurl>http://xxxx.xx</taruupdateurl>   url to raw scriptfile
  11. ;       <taruversion>0001</taruversion>                 version of your script (only numbers)
  12. ;       <tarucompatible>0001</tarucompatible>           last compatible config to actual build
  13. ;
  14. ;       Compile this script with AutoIt3 and copy exe to project root
  15. ;
  16.  
  17. #include <Array.au3>
  18. #include <FileConstants.au3>
  19. #include <MsgBoxConstants.au3>
  20. #include <WinAPIFiles.au3>
  21. #include <File.au3>
  22. #include <StaticConstants.au3>
  23. #include <GUIConstantsEx.au3>
  24. #include <WindowsConstants.au3>
  25. #Include <GuiButton.au3>
  26.  
  27. $GUI = GUICreate("TaruUpdater",250,110,-1,-1,-1,-1)
  28. $btn_update = GUICtrlCreateButton("Update",10,60,230,30,-1,-1)
  29. GUICtrlCreateLabel("before you run an update make a backup",10,10,230,42,-1,-1)
  30. GUICtrlSetBkColor(-1,"-2")
  31. GUISetState(@SW_SHOW,$GUI)
  32.  
  33.  
  34. Global $pluginlist = _FileListToArray( "./js/plugins/", "*", Default, True)
  35. If @error = 1 Then
  36.     MsgBox(16, "", "No Files\Folders Found.")
  37.     Exit
  38. EndIf
  39.  
  40. While 1
  41.     $nMsg = GUIGetMsg()
  42.     Switch $nMsg
  43.         Case $btn_update
  44.             Call("RunUpdate")
  45.         Case $GUI_EVENT_CLOSE
  46.             Exit
  47.  
  48.     EndSwitch
  49. WEnd
  50.  
  51. Func RunUpdate()
  52. For $i = 1 To $pluginlist[0]
  53.         Global $read = FileRead( $pluginlist[$i])
  54.         Global $url = StringRegExp ( $read, '(?i)<taruupdateurl>(.*?)</taruupdateurl>', 1)
  55.         Global $version = StringRegExp ( $read, '(?i)<taruversion>(.*?)</taruversion>', 1)
  56.         Global $compatible = StringRegExp ( $read, '(?i)<tarucompatible>(.*?)</tarucompatible>', 1)
  57.         If @error = 0 Then
  58.         Global $binary = InetRead ( $url[0], 1)
  59.         Global $iread = BinaryToString( $binary )
  60.         Global $iurl = StringRegExp ( $iread, '(?i)<taruupdateurl>(.*?)</taruupdateurl>', 1)
  61.         Global $iversion = StringRegExp ( $iread, '(?i)<taruversion>(.*?)</taruversion>', 1)
  62.         Global $icompatible = StringRegExp ( $iread, '(?i)<tarucompatible>(.*?)</tarucompatible>', 1)
  63. MsgBox(64,"iversion",$iversion,0)
  64.         If $iversion[0] > $version[0] Then
  65.                 If $icompatible[0] <= $compatible[0] Then
  66.                        
  67.                                 $result = MsgBox(260,"Update","You can update " & $pluginlist[$i],0)
  68.                                 switch $result
  69.  
  70.                                 case 6
  71.                                         Global $hFileOpen = FileOpen($pluginlist[$i], 2)
  72.                                         FileWrite ( $pluginlist[$i], $iread )
  73.                                         FileClose( $hFileOpen )
  74.  
  75.                                 case 7
  76.  
  77.  
  78.                                 endswitch      
  79.                 Else
  80.                                 $result = MsgBox(68,"Update","You can update " & $pluginlist[$i] & "but plugin has changed you must edit your config",0)
  81.                                 switch $result
  82.  
  83.                                 case 6
  84.                                         Global $hFileOpen = FileOpen($pluginlist[$i], 2)
  85.                                         FileWrite ( $pluginlist[$i], $iread )
  86.                                         FileClose( $hFileOpen )
  87.  
  88.                                 case 7
  89.  
  90.  
  91.                                 endswitch
  92.                 EndIf
  93.             Else
  94.             MsgBox(64,"Nothing to Update","All Scripts Up to Date or not Compatible with TaruUpdater",0)
  95.         EndIf
  96. EndIf
  97. Next
  98. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment