A teeworlds 0.7 network protocol library written in ruby
Go to file
ChillerDragon 8fe595b0a6 Client info is actually used to display join msgs
Looked at the c++ client code and it actually does that.
The entergame message is only used in demos. Yeet on those.
2022-11-05 11:34:34 +01:00
docs Holy sh*t this lib is actually usable 2022-11-05 11:07:16 +01:00
examples Holy sh*t this lib is actually usable 2022-11-05 11:07:16 +01:00
lib Client info is actually used to display join msgs 2022-11-05 11:34:34 +01:00
.gitignore Decompress packet payload 2022-10-25 20:17:07 +02:00
Gemfile Decompress packet payload 2022-10-25 20:17:07 +02:00
README.md opsi 2022-11-05 11:08:19 +01:00
sample.rb Client info is actually used to display join msgs 2022-11-05 11:34:34 +01:00

teeworlds-client

A teeworlds 0.7 client library written in ruby

Sample

Here a simple sample usage of the library. Connecting a client to localhost on port 8303. Acting as a simple chat bot. Also properly disconnect when the program is killed gracefully.

For more sample usages checkout the examples/ folder.

require_relative 'lib/teeworlds-client'

client = TeeworldsClient.new(verbose: false)

client.on_chat do |msg|
  if msg.message[0] == '!'
    case msg.message[1..]
    when 'ping' then client.send_chat('pong')
    when 'whoami' then client.send_chat("You are: #{msg.author.name}")
    when 'list' then client.send_chat(client.game_client.players.values.map(&:name).join(', '))
    else client.send_chat('Unkown command! Commands: !ping, !whoami, !list')
    end
  end
end

# properly disconnect on ctrl+c
Signal.trap('INT') do
  client.disconnect
end

# connect to localhost and block the current thread
client.connect('localhost', 8303, detach: false)

Documentation

Checkout docs/01.md for a full library documentation.