by Thomas Preymesser http://dragongoserver.rubyforge.org/ == DESCRIPTION: The dragongoserver gem allows you to use the Go Server (http://www.dragongoserver.net) from ruby programs. == FEATURES/PROBLEMS: You can access various features of Dragongoserver either within your own Ruby programs or via a command line tool (dgs). * get your user info * get user infos of other users * list waiting games * add a game to the waiting room * ... == SYNOPSIS: First you have to set the following environment variables: DGS_USERNAME="myname" DGS_PASSWORD="mypassword" This can be done by inserting the following two line into your .bashrc file (or a similar startup file for your preferred shell). export DGS_USERNAME="myname" export DGS_PASSWORD="mypassword" Alternatively you can pass the username and password to every call of the Dgs.new method: mydgs = Dgs.new("myname","mypassword") === Within your ruby code: # some example how you can use this gem within your programs require 'rubygems' require 'dragongoserver' require 'gorank' dgs = Dgs.new # get own user id at DGS id = dgs.userid puts "your user-id: #{id}" # your rank rank = dgs.get_rank puts "your rank:" p rank.to_s # your user infos infos = dgs.userinfo(id) puts "your attributes at DGS:" p infos # waiting games wg = dgs.waiting_games puts 'waiting games:' p wg # you can get info for every other user # user with user id 8000 user_8000 = dgs.userinfo(8000) puts "user 8000:" p user_8000 # see also the homepage of this gem for examples to use the # command line script 'dgs' require 'rubygems' require 'dragongoserver' dgs = Dgs.new dgs.username # prints your username at DGS dgs.waiting_games # prints your waiting games: # => [369607, 369303, 369412] dgs.get_rank # your rank as a GoRank object # => # dgs.get_rank.to_s # your rank as a string # => "26 kyu" dgs.add_game # adds one or more game in the waiting room # take the values from the file # ~/.dgs_default_add_game.yml if it exists === The 'dgs' command line tool: $ dgs -v dgs 0.0.3 outputs the version of the installed dragongoserver gem $ dgs --help outputs a help of the dgs-script with all current implemented options dgs --waiting prints a list of games where you have to make your next move You can open a shell, type in the following commands and watch when you have to move in a waiting game. Of course you can also write a shellscript with these commands. while true do dgs --waiting date sleep 300 done Instead of the script above you can use the '--waiting-loop' feature of this gem: $ dgs --waiting-loop in an endless loop prints a list of games where you have to make your next move. The duration until the next request is made at DGS will be dynamically adjusted. It starts with every 60 seconds and will be increased if there are no new moves in this period. If you want the messages display in big red letters as an On-Screen-Display: $ dgs --waiting-loop --osd To add a new game to the waiting room use xxx.add_game in your Ruby code or $ dgs --add-game at the command line. The add_game method looks up for a file ~/.dgs_default_add_game.yml where the game parameters will be taken from. If this file does not exists dragongoserver will just submit the new game form at dragongoserver.net without any changes (i.e. 1 game, main time 90 days, ... etc.). ==== Example of this config file --- :number_of_games: 3 :size: 19 :main_time: - 15 - :days :japanese_byoyomi: - 1 - :hours - 24 - :extra_periods :rated_game: true :clock_runs_on_weekend: false :require_rated_opponent: true :relative_range: 9 :comment: added by dragongoserver ruby gem It should be relatively clear what every parameter is meant for. If you omit some of these values the corresponding part in the DGS form will not be changed. Currently there is only the japanese byoyomi implemented. Please don't change the indentation in this file, it is important in the YAML format. There is a sample file .dgs_default_add_game.yml delivered with this gem, which you can copy to your home directory and modify it to your own needs. $ cp /your/gem/installation/path/.dgs_default_add_game.yml ~ == REQUIREMENTS: None. All dependent gems are installed automatically. If you want to use the --osd flag you have to install the osd package for your system. == INSTALL: sudo gem install dragongoserver == LICENSE: (The MIT License) Copyright (c) 2007-2009 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.