DragonTeaser
Version 2: Anyone interested?
If anybody is interested in the version 2 of the script (found on the bottom of this page), you can leave a message and I will document it better. timan72
The script
@REM "DragonTeaser" V1.0(c) 2007. Contributed to the public domain. @REM This script (Windows-cmd.exe with Unix tools) plays a sound EACH 5 minutes if a DGS game is waiting. @echo off REM Less known tools you need: "sleep" is from the Windows 2003 resource kit
:again del status.php X:\refPro\wget\wget http://username:password@www.dragongoserver.net/rss/status.php REM Put the players names here: (case-sensitive! "^|" is OR) grep -P awaiting status.php goto answer%errorlevel% :answer0 REM String found! sleep 480 & REM seconds goto again :answer1 REM String NOT found. start "" /min sndrec32 /play /close "Plop.wav" sleep 480 & REM seconds goto again
Download of the neccessary tools
- wget:
http://www.gnu.org/software/wget/
- grep:
http://gnuwin32.sourceforge.net/
- sleep: Use the script below or download the
Windows 2003 Resource Kit Tools and use its sleep.exe.
sleep-script
Copy this to sleep.vbs:
set args = WScript.Arguments WScript.Sleep(1000 * args(0))
wget.vbs-script
The following is something like wget in a vbs-script. Since vbs has also regular expressions even grep wouldn't be needed in vbs and the whole script should be rewritten as a *.vbs-script. It wouldn't need any external tools then and could easily be much user friendlier, with some controls. I hope I will find time to do this, but if anyone is good at vbs, you can probably do this in 10 minutes ... please please do.
' *************************************************************** ' * wget.vbs By Vittorio Pavesi (www.vittorio.tk) * ' * * ' * Retrieve a file from an URL and save it to the Hard Disk * ' *************************************************************** set args = WScript.Arguments
URL = args(0) saveTo = "status.php" ' args(1)
Set Obj1 = CreateObject("MSXML2.ServerObj1") Obj1.open "GET", URL, false Obj1.send() Set Obj2 = CreateObject("ADODB.Stream") Obj2.Open Obj2.Type = 1 'adTypeBinary Obj2.Write Obj1.ResponseBody 'Give the XML string to the ADO Stream Obj2.Position = 0 'Set the stream position to the start Set FSO = !Createobject("Scripting.FileSystemObject") if fso.!Fileexists(saveTo) then Fso.DeleteFile hdLocation set FSO = Nothing Obj2.SaveToFile saveTo Obj2.Close Set Obj2 = Nothing Set Obj1 = Nothing
Options
I even use a more complex grep which doesn't notify me about certain players waiting:
grep -v -P 'whoever^|someothersomeone' status.php | grep 'Game with'
You can also grep for specific player names.
You can make one instance of the script check about a move in your most exciting game with your best friend each minute and another instance check for moves in other games once an hour.
DGS keyboard shortcut
When I hear that a game is waiting I press Windows+G and the DGS Status will pop up. This is done with this AutoHotkey scriptlet:
#G:: SetTitleMatchMode 1 IfWinExist Dragon Go Server WinActivate,Dragon Go Server else Run, http://www.dragongoserver.net/status.php return
DragonTeaser 2.0
I use the following version now. With this you can "acknowledge" games which you don't want to produce sounds anymore. You have to copy the source from the edit page of this wiki, otherwise you will have wrong question marks in there.
DTack.cmd
@REM "DragonTeaser" acknowledgement script @REM This script (Windows-cmd.exe with Unix tools) will cause DragonTeaserNew? to be quiet @REM until a game is waiting on DGS, which was not waiting when this script was called. echo off
m: & cd M:\1Kosuch\b\ScriptsMy\DragonTeaser
del status.php X:\refPro\wget\wget http://username:password@www.dragongoserver.net/rss/status.php grep 'Game with' status.php >DTAck.rss
DTnew.cmd
@REM "DragonTeaserNew?" V1.0(c) 2007. Contributed to the public domain. @REM This script (Windows-cmd.exe with Unix tools) plays a sound at a set time intervall if a @REM DGS game is waiting which was not acknowledged with the script "DTAck.cmd" echo off REM Strange programs you need: "sleep" is from the Windows 2003 resource kit
REM Call the audio player to adjust volume: REM C:\Programme\mplayerc /new /play "DrChk-Plop.wav"
m: & cd M:\1Kosuch\b\ScriptsMy?\DragonTeaser
title "DragonTeaserNew?"
:again del status.php X:\refPro\wget\wget http://username:password@www.dragongoserver.net/rss/status.php & REM redir funktioniert nicht: 2>&1 >nul REM cls grep 'Game with' status.php >DTcurrent.rss fc DTcurrent.rss DTAck.rss
REM Debug: echo %errorlevel%
goto answer%errorlevel% :answer0 echo No Games found. Sleeping 1 Min. sleep 120 goto again :answer1 playsound "DrChk-Plop.wav" echo Games found! Sleeping 1 Min. sleep 120 goto again