Sha256: 0984e62055c0e49bc155c813cd8fe071ce2b98254666a91554dbe6fbaec38c31

Contents?: true

Size: 1020 Bytes

Versions: 1

Compression:

Stored size: 1020 Bytes

Contents

require 'selenium-webdriver'
require 'travian_bot/tools'

class TravianBot
  class Application
    class << self
      include Tools
            
      def run!(*arguments)
        url, user, password = get_credentials
        driver = Selenium::WebDriver.for :firefox
        driver.navigate.to(url)

        # Login
        name_input = driver.find_element(:name, 'name')
        password_input = driver.find_element(:name, 'password')
        login_button = driver.find_element(:id, 's1')

        name_input.send_keys(user)
        password_input.send_keys(password)
        login_button.submit

        # Check if building something
        begin
          building_pipe = driver.find_element(:id, 'building_contract')
          building_time = driver.find_element(:class, 'buildingTime').text
          puts wait_till(building_time)
        rescue Selenium::WebDriver::Error::NoSuchElementError
          puts 'Nothing to build'
        end

        driver.quit
      
        return 1
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
travian_bot-0.1.1 lib/travian_bot/application.rb