Jump to content

Checking update every minute and if update avail do ->


wazer
 Share

Recommended Posts

Hello i want to know why my script does not work as it should.

And i would really like som help to optimize it, and perhaps make it work as it should since i have tryed everything now.

I think i have done something correct but then again theres many skilled autoit developers in here :graduated:

What my script does it that it check's a website for this title "cspmod - Revision 16xx: /cspdev" and takes out what is between Revision and : so in this particular situation its the svn revision number that is 1662 now.

The revision numbers variable is used in different things.

Like checking for update <-

Editing a server.cfg file with current number as a hostname for our game mod www.cspromod.com when we are testing new revisions.

Makes a message to our private channel about new update is out and server is auto updating now with revision.

My first problem is that im not 100% sure if the check update is the right way to do the actually check since theres no actually file to check on a webserver, i only have a html string to search for.

My second problem is that i did not know how to make it check for updates and doing all the editing and and updating plus announcing new updates on irc at the same time every 1 or 2 minutes. I searched the forums abit and found out a solution that worked i think?.

Now it seems the script only works everytime i start it, if i let run the first time and theres a new revision out before the script is ran it will update. But if the program was already started and new revision is rolling out, it wont do anything.

Now here i am asking for some perfection to make it 100% work.

Cheers

wazer.

Code below.

The actually website link in my script(http://www.buy-more.dk/wazer/index.html) is not to our svn site and should only be considered as a dummy to check in here ;)

#include <INet.au3> ; needed for get source (html)
#include <String.au3> ; needed for stringbetween
#Include <File.au3>
$log = @ScriptDir & "\check_update.txt\"
$readtitle = _StringBetween(_INetGetSource("http://www.buy-more.dk/wazer/index.html"), "Revision", ":")
$fOverWrite = 1
Global $Runner
$text = "/msg #channel Automatic cspdev server update. Server was updated to revision" & $readtitle[0]
$title = WinGetTitle("mIRC 7.19", "")
HotKeySet("{HOME}", "__start")
HotKeySet("{END}", "__stop")
__start()
While 1
    Sleep(500)
WEnd
;The code it self
Func __start()
    $Runner = Not $Runner
    While $Runner
$file = FileOpen(@ScriptDir & "\" & "check_update.txt", 0)
Local $line = FileReadLine($file)
FileClose($file)
If $line = $readtitle[0] Then
    ;MsgBox(4096, "Update", "Update is not necessary!", 3)
Else
    ;MsgBox(4096, "Update", "Update is necessary!", 3)
Run ("D:\games\cspdev_server\update_cspdev.bat")
sleep(5000)
   __irc()
   _FileWriteToLine("D:\games\cspdev_server\orangebox\cspdev\cfg\server.cfg", 5, 'hostname "wazer''s playground cspdev BETA 1.09 - REV' & $readtitle[0], 1)
EndIf
FileDelete (@ScriptDir & "\"& "check_update.txt")
sleep(100)
FileWrite (@ScriptDir & '\check_update.txt',$readtitle[0]); save file
Sleep(60000)
    WEnd
EndFunc   ;==>start

;mIRC message #channel
func __irc()
WinSetState($title, "", @SW_SHOW)
ControlSetText($title, "", "RichEdit20W1", $text)
ControlSend($title, "", "RichEdit20W1", "{ENTER}")
WinSetState($title, "", @SW_HIDE)
EndFunc   ;==>stop
;exit
Func __stop()
    Exit
EndFunc   ;==>stop
Link to comment
Share on other sites

look there:

search before posting :):graduated:

try and tell me ;)

Edited by Command3r

[font="arial, helvetica, sans-serif;"]Advice for you[/font][font="arial, helvetica, sans-serif;"]: [/font][u]Search[/u] before posting.

 

[font="arial, helvetica, sans-serif;"] *********** Problem solved? if yes [/font][color=rgb(0,0,0);font-family:arial, helvetica, sans-serif;] *********[/color]

[font="arial, helvetica, sans-serif;"]******* press "Mark Solved" button. *******[/font]

Link to comment
Share on other sites

look there:

search before posting ;):graduated:

try and tell me ;)

Did you actually read my whole post before you linked me to a forum thread theres no use for me, since i im not using any files to check for as im checking for a string, the update function is working well in my script but the auto checking every minute does not work well :)

Any other's

Link to comment
Share on other sites

hope this helps

While 1
$time = 1000 * 60 ; 1 min
$UTime = Sleep($time)
MsgBox(0, "", "check for update")
WEnd

EDIT: Better ex.

Edited by Command3r

[font="arial, helvetica, sans-serif;"]Advice for you[/font][font="arial, helvetica, sans-serif;"]: [/font][u]Search[/u] before posting.

 

[font="arial, helvetica, sans-serif;"] *********** Problem solved? if yes [/font][color=rgb(0,0,0);font-family:arial, helvetica, sans-serif;] *********[/color]

[font="arial, helvetica, sans-serif;"]******* press "Mark Solved" button. *******[/font]

Link to comment
Share on other sites

Wouldn't you want the read of the static information (your check_update.txt file) to be in the script initialization at the top.

And the read of the dynamically changing information (the version number from the web) to be within your repeating loop?

It seems to me that

$readtitle = _StringBetween(_INetGetSource("http://www.buy-more.dk/wazer/index.html"), "Revision", ":")

and

$file = FileOpen(@ScriptDir & "\" & "check_update.txt", 0)
Local $line = FileReadLine($file)
FileClose($file)

ought to trade places.

Link to comment
Share on other sites

Wouldn't you want the read of the static information (your check_update.txt file) to be in the script initialization at the top.

And the read of the dynamically changing information (the version number from the web) to be within your repeating loop?

It seems to me that

$readtitle = _StringBetween(_INetGetSource("http://www.buy-more.dk/wazer/index.html"), "Revision", ":")

and

$file = FileOpen(@ScriptDir & "\" & "check_update.txt", 0)
Local $line = FileReadLine($file)
FileClose($file)

ought to trade places.

Actually you were almost right ;)

$readtitle = _StringBetween(_INetGetSource("http://www.buy-more.dk/wazer/index.html"), "Revision", ":")

Had to be placed into the timer script

Just below

Func __start()

$cspRunner = Not $cspRunner

While $cspRunner

$readtitle = _StringBetween(_INetGetSource("http://www.buy-more.dk/wazer/index.html"), "Revision", ":")'

I thought that the $readtitle was updated constantly without users attention but now it actually makes sense, it will only read it once and give the current variable it was reading.

Thanks for the post guys :graduated:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...