A teeworlds 0.7 network protocol library written in ruby
Go to file
ChillerDragon dfcde01257 Deduplicate CI the hacky way
yaml anchors are not supported by github
and every other deduplication seems to require creating a new action
as in a own repo with releases
2024-02-20 20:36:20 +08:00
.github Deduplicate CI the hacky way 2024-02-20 20:36:20 +08:00
docs Add --verbose-snap to sample client 2023-10-22 14:26:53 +02:00
examples Add example only for the verbose snap 2024-02-18 15:35:33 +08:00
integration_test Play with failing CI 2024-02-20 17:06:51 +08:00
lib Fix server side integration tests 2024-01-23 21:19:01 +08:00
scripts Use git for versioning not folder names 2023-09-17 17:33:46 +02:00
spec test int edge case 0111 1111 is -64 2024-02-18 15:40:36 +08:00
.gitignore Add failing server side integration test 2024-01-20 23:56:10 +08:00
.rubocop.yml Add rubocop to CI (closed #2) 2022-11-05 17:57:12 +01:00
client_sample.rb Fix rubocop indent 2023-10-22 18:19:07 +02:00
Gemfile Add tests (closed #3) 2022-11-05 17:13:23 +01:00
Rakefile Add tests (closed #3) 2022-11-05 17:13:23 +01:00
README.md Use git for versioning not folder names 2023-09-17 17:33:46 +02:00
server_sample.rb Add detach to server (closed #12) 2024-01-20 21:50:55 +08:00
teeworlds_network.gemspec Update huffman to v0.0.4 2024-02-18 16:52:16 +08:00

teeworlds_network

A teeworlds 0.7 client & server 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|
  # note use `next` instead of `return` in the block
  next unless 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

# 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/READE.md for a full library documentation.