2022-11-05 10:59:36 +00:00
|
|
|
#!/usr/bin/env ruby
|
2022-11-05 16:27:54 +00:00
|
|
|
# frozen_string_literal: true
|
2022-11-05 10:59:36 +00:00
|
|
|
|
2022-11-09 07:40:17 +00:00
|
|
|
require_relative '../lib/teeworlds_client'
|
2022-11-05 10:59:36 +00:00
|
|
|
|
|
|
|
client = TeeworldsClient.new
|
|
|
|
|
|
|
|
client.on_client_info do |ctx|
|
2022-11-05 11:00:49 +00:00
|
|
|
puts "'#{ctx.data[:player].name}' joined the game#{reason}"
|
2022-11-05 10:59:36 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
client.on_client_drop do |ctx|
|
2022-11-05 11:00:49 +00:00
|
|
|
unless ctx.data[:silent]
|
|
|
|
reason = ctx.data[:reason] ? " (#{ctx.data[:reason]})" : ''
|
|
|
|
puts "'#{ctx.data[:player].name}' left the game#{reason}"
|
|
|
|
end
|
2022-11-05 10:59:36 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
Signal.trap('INT') do
|
|
|
|
client.disconnect
|
|
|
|
end
|
|
|
|
|
2022-11-06 17:26:14 +00:00
|
|
|
# connect and block main thread
|
2022-11-05 10:59:36 +00:00
|
|
|
client.connect('localhost', 8303, detach: false)
|