Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ChillerDragon/teeworlds_network
A teeworlds 0.7 network protocol library written in ruby
https://github.com/ChillerDragon/teeworlds_network
ddnet ddnet-library teeworlds teeworlds-client teeworlds-library teeworlds-server
Last synced: 3 months ago
JSON representation
A teeworlds 0.7 network protocol library written in ruby
- Host: GitHub
- URL: https://github.com/ChillerDragon/teeworlds_network
- Owner: ChillerDragon
- Created: 2022-10-25T12:07:55.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-02-23T04:23:48.000Z (12 months ago)
- Last Synced: 2024-04-30T12:38:49.929Z (9 months ago)
- Topics: ddnet, ddnet-library, teeworlds, teeworlds-client, teeworlds-library, teeworlds-server
- Language: Ruby
- Homepage:
- Size: 453 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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/](examples/) folder.
```ruby
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/README.md](docs/README.md) for a full library documentation.