Travian Building Bot on Ruby

Posted on 20 March 2008 by Mike

After some time playing you can encounter a problem that you need wait a lot of time to build something. At the same time, you can gain resources much more quickly. And the problem is that you will need always check your browser for a building status. That’s where travian bot can take a place. You just will need to put some queue together and leave your computer alone. The bot will done your work.

The good thing is, that such bot for travian isn’t exactly a cheat. It just simulate user work by generate browser requests to check resources and start build things. Not so good thing is that it’s written in Ruby and you’ll need an interpretor for it. Although that isn’t a real problem on any OS at the moment.

How to install and use the bot

  1. Download and install bot
  2. Configure bot
    Edit travian.rb

    You have to change the MAIN_URL and the name of the cancel-button in Settings part of the file. You also can get bot to work at night and change it sleeptime (how often it check the status)

  3. Run the bot
    Windows

    • Start > Run > ?cmd?
    • change directory to your travianfolder. For example: cd c:\programs\travianbot\
    • ruby travian.rb [username] [password] [id.id.id.id] [villageid]

    [id.id.id] means you can add as many build ids as you want. Seperated by a point. The photo below shows the id of each field (1-18). The ids for the buildings are 19-36.

    Mac and Linux
    Just open Terminal otherwise than cmd and do the same actions

  4. Enjoy!

    travian building bot

Tagged |

, , ,

41 Comments For This Post
  1. peter Says:

    well… this program doesn´t work…

    alway is it like “(!!) error cannot authorize ” and i am pretty sure I wrote datas correct..

    have anyone experienced same problem?

  2. Mike Says:

    I’m sure it was working but I’ve tried it 3-4 month ago.

  3. dude Says:

    It does realy work! Nice job!

  4. skyant Says:

    how can i install this? the guidelines above are so confusing

  5. Lasse Says:

    >Exit code: 1
    >ruby travian.rb
    – Error: less arguments ——-
    usage: travian.rb username passwd buildqueue dorfid
    >Exit code: 1

    what do i do?

  6. guy Says:

    When I try to use it, the lil window just exits itself.

  7. andrezinhu Says:

    i need a better tutorial because i dont understand this right

    when i go to execute it only leeds me to the documents and settings folder and only from there i can search the travian folder

    i thenk i ve done all right unless that

    (sorry for my english)

  8. andrezinhu Says:

    please help me

  9. dude2 Says:

    What should i change the image name to?

  10. hans Says:

    same problem as peter -.-

  11. yo man Says:

    yo it dosnt work i tried but it wont

  12. McKenzie Says:

    Try in this way :
    Sample -

    ruby travian.rb name password 1.4.6.8 ‘Name of your city’

    DO NOT USE IN THIS WAY (see below)!!!

    ruby travian.rb name password 1.4.6.8 Name of your city

    because name is string !!!

  13. nejc Says:

    why didnt working?

  14. dark_psp Says:

    why it doesnt work? i tried so many times… can anybody explain

  15. Mike Says:

    Probably you’re making something wrong guys. It works fine on my linux at the moment.

  16. michl Says:

    It works!!!! only follow the instructions!! dont forget to chance the MAIN_URL to your travian-server ;)

  17. Motasem alsaqqa Says:

    it works fine with me , thanks a lot ;)

  18. holla Says:

    travian just got 10x easier, tytyty

  19. ggbnet Says:

    how do you build buildings?

  20. Falki Says:

    C:\Dokumente und Einstellungen\Falk\Desktop\travianbot1-1>ruby travian.rb Falkii
    i *** 18 0
    ./ymhtml.rb:586:in `parseDTD’: DOCTYPE parse error: “!DOCTYPE” (YmHTML::ParseErr
    or)
    from ./ymhtml.rb:913:in `parse’
    from travian.rb:136:in `authorize’
    from travian.rb:384
    from travian.rb:375:in `each’
    from travian.rb:375

    please help me orangenlimonade@gmx.de
    icq 284366664

  21. HH Says:

    Since a few Days I have the same Problem as Falki - before the script worked just Fine !
    I cannot figure out, what error the ymhtml.rb parser means, i downloaded a newer version on http://www.yoshidam.net/Ruby.html, but it didnt help!

    If anyone has a clue, please help ! The script is the best one for automated building queues right now

  22. another mad person Says:

    I also recieved
    (!!) error cannot authorize

  23. another mad person Says:

    (!!) error cannot authorize
    ^ ^ ^ ^
    This is becuase for some reason .us is not able to be ‘botted’ yet…

  24. abood Says:

    ./ymhtml.rb:586:in `parseDTD?: DOCTYPE parse error: ?!DOCTYPE? (YmHTML::ParseErr
    or)
    from ./ymhtml.rb:913:in `parse?
    from travian.rb:136:in `authorize?
    from travian.rb:384
    from travian.rb:375:in `each?
    from travian.rb:375
    i have this error

  25. snoooop Says:

    dear i have this problem can any one help me pls>>>

    ./ymhtml.rb:586:in `parseDTD’: DOCTYPE parse error: “!DOCTYPE” (YmHTML::ParseErr
    or)
    from ./ymhtml.rb:913:in `parse’
    from s15.rb:181:in `authorize’
    from s15.rb:430
    from s15.rb:421:in `each’
    from s15.rb:421

  26. RtsAlex Says:

    dudes…when i start travian.rb the window closes itself..

    why does it do that…iv’e followed all the instructions :S

  27. HH Says:

    !! I think I have a solution !!
    – But pls use it at your own risk for i am not a professional programmer–

    1. download newest version of ymhtml.rb from http://www.yoshidam.net/diary/ymhtml.rb-0.1.13
    2. make a backup copy of ymhtml.rb-0.1.13 and rename it to “ymhtml.rb”. (Overwrite the older version delivered with the original script)
    3. Edit the ymhtml.rb and go to line: 586
    [if (token = nextToken) != '<!DOCTYPE'] should be changed to [if (token = nextToken) != '!DOCTYPE']
    4. Save the file and try the bot script authentification

    For me, this worked perfectly, because the Error did not occur in the authentification process in travian.rb, but in the parsing module in ymhtml.rb, as seen above.

    Try it and good Luck !

  28. pawnee Says:

    Hi Mike,

    Its glad to see you like my travianbot. But please don’t set a direct link to the download. You can provide your visitors a link to the travianbot homepage:

    http://pawnee.wordpress.com/travian-bot-building-queue/

    thanks,
    pawnee

  29. Mike Says:

    Hi Pawnee.
    I change the link as you wanted =)

  30. amkm Says:

    this is a bad

  31. gingerninja78 Says:

    It seems to log in ok, but then will time out after a few hours without building. Will try again and post the error, but any ideas?!?!?!

  32. gingerninja78 Says:

    c:/ruby/lib/ruby/1.8/net/http.rb:564:in ‘initialize’:A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. -connect(2) (Errno::ETIMEDOUT)

    etc
    etc

    any ideas about this error msg?!?!?!?!

  33. travian Says:

    sorry for English, but this bot need to plan buildings to be constructed? does not work with the PC turned off?
    I have a problem in the functioning of bots, gives me the error file ymhtml.rb
    What should I do? please reply

  34. lol Says:

    hi, is this a free program?

    must i buy this program or is this free??

  35. KK Says:

    I tried this* one time and it worked…
    but now im with the same problem again…

    *this:

    !! I think I have a solution !!
    ? But pls use it at your own risk for i am not a professional programmer?

    1. download newest version of ymhtml.rb from http://www.yoshidam.net/diary/ymhtml.rb-0.1.13
    2. make a backup copy of ymhtml.rb-0.1.13 and rename it to ?ymhtml.rb?. (Overwrite the older version delivered with the original script)
    3. Edit the ymhtml.rb and go to line: 586
    [if (token = nextToken) != '<!DOCTYPE'] should be changed to [if (token = nextToken) != '!DOCTYPE']
    4. Save the file and try the bot script authentification

    For me, this worked perfectly, because the Error did not occur in the authentification process in travian.rb, but in the parsing module in ymhtml.rb, as seen above.

    Try it and good Luck !

    —————–

    what am i supposed to do now?? this dont work anymore

  36. KK Says:

    ??

  37. Schizoidgull Says:

    // ==UserScript==

    // @name Ikariam Building List

    // @namespace http://www.dokislogeek.net

    // @description Fast Buildings info and access in city view, Ressources Level on Island view

    // @include http://*.ikariam.*/*

    // ==/UserScript==

    /* Options and Styles */
    css=’#reslvl {\
    margin:2px 10px;\
    }\
    #reslvl span {\
    float:left;\
    width:90px;\
    }\
    .build{\
    background-color:transparent;\
    font-weight:normal;\
    }\
    .build span{\
    color:black;\
    }\
    .build a{\
    text-decoration:none;\
    }\
    .build:hover {\
    background-color:#92e192;\
    font-weight:bold;\
    }\
    .buildup{\
    background-color:transparent;\
    font-weight:normal;\
    }\
    .buildup span{\
    color:red;\
    }\
    .buildup a{\
    text-decoration:none;\
    }\
    .buildup:hover {\
    background-color:#FFC2F3;\
    font-weight:bold;\
    }\
    .buildmax{\
    background-color:transparent;\
    font-weight:normal;\
    }\
    .buildmax span{\
    color:grey;\
    }\
    .buildmax a{\
    text-decoration:none;\
    }\
    .buildmax:hover {\
    background-color:#C1FAFF;\
    font-weight:bold;\
    }\
    .buildname{\
    float:left;\
    width:80%;\
    }\
    ‘;

    /* End of Options and Styles */

    /* function to add style */

    function addGlobalStyle(css) {
    var head, style;
    head = document.getElementsByTagName(’head’)[0];
    if (!head) { return; }
    style = document.createElement(’style’);
    style.type = ‘text/css’;
    style.innerHTML = css;
    head.appendChild(style);
    }

    /* function to set some language related options according to domain extension */

    function setDomainOpts(){
    var split1 = location.href.split(’ikariam.’);
    var split2 = split1[1].split(’/');
    var ext = split2[0];
    var opts = new Array();
    opts['ext'] = ext;
    if ( ext == ‘fr’ ){
    opts['lvl'] = ‘ Niveau’;
    }
    else if ( ext == ‘de’ ){
    opts['lvl'] = ‘ Stufe’;
    }
    else if ( ext == ‘com’ ){
    opts['lvl'] = ‘ Level’;
    }
    else if ( ext == ‘es’ ){
    opts['lvl'] = ‘ Nivel’;
    }
    else if ( ext == ‘gr’ ){
    opts['lvl'] = ‘εÏ?ίÏ?εδο’;
    }
    return opts;
    }

    opts = setDomainOpts();

    /* Embedded functions http://wiki.greasespot.net/Code_snippets#Embed_a_function_in_the_current_page*/

    function embedFunction(s) {
    document.body.appendChild(document.createElement(’script’)).innerHTML=s.toString().replace(/([\s\S]*?return;){2}([\s\S]*)}/,’$2′);
    }

    function showBuilding(obj) {
    var pos = obj.href.split(’position=’);
    var pos1 = ‘position’+pos[1];
    document.getElementById(pos1).style.border = ‘4px solid red’;
    }
    embedFunction(showBuilding);

    function hideBuilding(obj) {
    var pos=obj.href.split(’position=’);
    var pos1=’position’+pos[1];
    document.getElementById(pos1).style.border = ”;
    }
    embedFunction(hideBuilding);

    /* Island View */

    if( document.getElementById(’island’) ){
    addGlobalStyle(css);

    ifeatures = document.getElementById(’islandfeatures’).getElementsByTagName(’li’);

    w = ifeatures[0].className.split(’ ‘);

    woodlevel = w[w.length - 1].replace(’level’,”);

    wn = ifeatures[0].getElementsByTagName(’span’);

    woodname = wn[0].innerHTML;

    r = ifeatures[1].className.split(’ ‘);

    ressourcelevel = r[r.length - 1].replace(’level’,”);

    rn = ifeatures[1].getElementsByTagName(’span’);

    ressourcename = rn[0].innerHTML;

    var leftbox, newElement;

    leftbox = document.getElementById(’actioncontainer’);

    if (leftbox) {

    var rdiv = document.createElement(”div”);

    rdiv.innerHTML = ‘ \
    Ressources \
    \
    \
    \
    ‘+ woodname + ‘: ‘ + woodlevel + ‘ \
    \
    ‘ + ressourcename + ‘: ‘ + ressourcelevel +’ \
    \
    \
    \
    ‘;

    leftbox.parentNode.insertBefore(rdiv, leftbox.nextSibling);

    }

    }

    /* City View */

    if( document.getElementById(’city’) ){
    addGlobalStyle(css);

    table = document.getElementById(’mainview’).getElementsByTagName(’a');

    var table1 = new Array();

    var torder = new Array();
    var tclass = new Array();
    var lmax = new Array(); /* array with buildings max level, according to Ikarariam Help*/
    lmax['academy'] = 16;
    lmax['embassy'] = 16;
    lmax['workshop-army'] = 24;
    lmax['safehouse'] = 20;
    lmax['barracks'] = 24;
    lmax['shipyard'] = 16;
    lmax['branchOffice'] = 16;
    lmax['warehouse'] = 16;
    lmax['townHall'] = 24;
    lmax['wall'] = 24;
    lmax['museum'] = 8;
    lmax['port'] = 16;
    lmax['palaceColony'] = 4;
    lmax['tavern'] = 16;
    lmax['palace'] = 4;

    for(i = 0; i < table.length; i++){

    t=table[i].title;

    if( !isNaN(t.charAt(t.length - 1)) ){

    table1[table[i].title] = table[i].href;

    torder.push(table[i].title);
    tclass[table[i].title] = table[i].parentNode.className;
    }

    }

    torder.sort();

    titles = ”;

    for ( i = 0; i = lmax[tclass[torder[i]]]) {

    titles += ‘ \
    \
    ‘ + b[0] + ‘ \
    ‘ +b[1]+’ \
    \
    ‘;

    }
    /* If building is upgrading */

    else if (u && u[0].className == ‘constructionSite’){

    titles += ‘\
    \
    ^ ‘ + b[0] + ‘\
    ‘ +b[1]+’ ^\
    \
    ‘;

    }
    /* else ^^ */

    else {

    titles += ‘\
    \
    ‘ + b[0] + ‘\
    ‘ +b[1]+’\
    \
    ‘;

    }

    }

    titles = titles + ”;

    e=document.getElementById(’information’).getElementsByTagName(’div’);

    e[0].innerHTML = e[0].innerHTML + titles;

    }

  38. sinyosaja Says:

    i tried this script and it doesn’t work, because my internet connection using proxy, so i do a little modification in file : travian.rb

    line 56
    #static Settings
    PATH_LOGIN = ‘/login.php’ #PATH_LOGIN = MAIN_URL + ‘login.php’
    PATH_DORF1 = ‘/dorf1.php’ #PATH_DORF1 = MAIN_URL + ‘dorf1.php’
    PATH_DORF2 = ‘/dorf2.php’ #PATH_DORF2 = MAIN_URL + ‘dorf2.php’
    PATH_BUILD = ‘/build.php’ #PATH_BUILD = MAIN_URL + ‘build.php’

    line 86
    #new connection
    url = URI.parse(MAIN_URL)
    http = Net::HTTP.new(url.host, url.port,’myproxy_addr’, myproxy_port) #http = Net::HTTP.new(url.host, url.port)

    and now it works

    @sinyosaja-mangan ora mangan asal kumpul@

  39. nype Says:

    when i try to run ruby travian.rb [username] [password] [id.id.id.id] [villageid] ruby just opens the script…
    when i want to press “GO” by tools nothing happens :(

  40. nype Says:

    ok…
    i got it running…i took the modification form sinyosaja because i’m using proxy… but this didn’t work…
    when i took the normal version the programm is starting but gets a html error while authorizing…this is the same by the autoversion…
    i think it’s because the programm can’t access the inet…
    does somebody have an scrip for proxy that works? I’m using phproxy for surfing…

  41. nype Says:

    ok… i rewrote the complete script *puhhh*
    to work with phproxy…
    but when i want to start, it says:

    ./ymhtml.rb:588:in ‘parseDTD’ : DOCTYPE parse erro: “<!DOCTYPE”

    from ./ymhtml.rb:915:in ‘parse’
    from travian.rb: 136: in ‘authorize’
    from travian.rb:384
    from travian.rb:375:in ‘each’
    from travian.rb:375

    i tryed “HH” ’s methode,too, but it’s a although the same error…
    i hope somebody can help me :)

1 Trackbacks For This Post
  1. Travian Task Queue Script - Browser Games Digest Says:

    [...] I like ruby travian build bot and it’s more than enough for [...]

Leave a Reply

Archives