ts3query 0.5 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.rdoc +19 -14
- data/lib/ts3query.rb +26 -11
- data/lib/ts3query/client_connection.rb +17 -0
- data/lib/ts3query/errors.rb +3 -0
- data/lib/ts3query/query_options.rb +13 -0
- data/lib/ts3query/server_connection.rb +25 -0
- data/lib/ts3query/ts3_connection.rb +42 -73
- metadata +19 -17
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7563f7b294f500b54f47fbde092f70394211170c
|
4
|
+
data.tar.gz: 038562ba7964c61dcde6126454a86f2d40ea06cc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 031dcdc6b422a648c5f2dd4f09f6ed40f5c5bf1b9be3786d5dcc78beab5393ce390e8ebf67cfb2b7a692cf882cab663b7a8018805e6e4bcada674de12058e17b
|
7
|
+
data.tar.gz: 383df37aefab71c19bdecb82b3399ec263a184641faec6d6fb48e99242f1bf11cd17b9091a8a7c00c18d3269781e068cd80b8a45b437ba5ff083793ea91fee01
|
data/README.rdoc
CHANGED
@@ -5,39 +5,44 @@
|
|
5
5
|
In <b>Rails 3</b>, add this to your Gemfile and run the +bundle+ command.
|
6
6
|
|
7
7
|
gem "ts3query"
|
8
|
-
|
8
|
+
|
9
9
|
== Getting Started
|
10
10
|
|
11
11
|
=== Connecting to a Teamspeak 3 Server
|
12
12
|
|
13
|
-
@query = TS3Query.
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
@query = TS3Query.server_connect :address => "your-address.com" # default => 127.0.0.1
|
14
|
+
:port => 1234 # default => 10011
|
15
|
+
:username => "myqueryuser" # default => serveradmin
|
16
|
+
:password => "myquerypassword"
|
17
|
+
|
18
|
+
=== Connecting to a Teamspeak 3 Client (via ClientQuery plugin)
|
17
19
|
|
18
|
-
|
20
|
+
@query = TS3Query.client_connect :address => "your-address.com" # default => 127.0.0.1
|
21
|
+
:port => 1234 # default => 25639
|
22
|
+
|
23
|
+
This will raise an +ConnectionRefused+ error, if the client does not respond or the credentials are wrong.
|
19
24
|
|
20
25
|
=== Executing query commands
|
21
26
|
|
22
27
|
This retuns a result hash with all server informations.
|
23
|
-
|
28
|
+
|
24
29
|
result = @query.version()
|
25
|
-
|
30
|
+
|
26
31
|
This will return a hash with the serverlist. (Options -uid and -short)
|
27
32
|
|
28
33
|
result = @query.serverlist do |opt|
|
29
|
-
|
30
|
-
|
34
|
+
opt.uid
|
35
|
+
opt.short
|
31
36
|
end
|
32
37
|
|
33
38
|
This will select the first server. (Parameters sid=1)
|
34
39
|
|
35
40
|
@query.use :sid => 1
|
36
|
-
|
41
|
+
|
37
42
|
You can also combine parameters and options.
|
38
43
|
|
39
44
|
@query.use :sid => 1 do |opt|
|
40
|
-
|
45
|
+
opt.virtual
|
41
46
|
end
|
42
47
|
|
43
48
|
=== Close the connection
|
@@ -45,13 +50,13 @@ You can also combine parameters and options.
|
|
45
50
|
If you don't need the query connection any longer you should close it.
|
46
51
|
|
47
52
|
@query.disconnect
|
48
|
-
|
53
|
+
|
49
54
|
=== Query commands
|
50
55
|
|
51
56
|
For a full command reference you can download the {Teamspeak 3 Query Manuel}[http://media.teamspeak.com/ts3_literature/TeamSpeak%203%20Server%20Query%20Manual.pdf].
|
52
57
|
|
53
58
|
== Contributing to TS3Query
|
54
|
-
|
59
|
+
|
55
60
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
56
61
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
57
62
|
* Fork the project.
|
data/lib/ts3query.rb
CHANGED
@@ -1,15 +1,30 @@
|
|
1
|
-
require 'ts3query/
|
1
|
+
require 'ts3query/server_connection'
|
2
|
+
require 'ts3query/client_connection'
|
2
3
|
|
3
4
|
module TS3Query
|
4
|
-
|
5
|
+
|
6
|
+
DefaultServerParams = {
|
7
|
+
:address => "127.0.0.1",
|
8
|
+
:port => "10011",
|
9
|
+
:username => "serveradmin"
|
10
|
+
}
|
11
|
+
|
12
|
+
DefaultClientParams = {
|
13
|
+
:address => "127.0.0.1",
|
14
|
+
:port => "25639"
|
15
|
+
}
|
16
|
+
|
5
17
|
def self.connect(params = {})
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
18
|
+
warn "DEPRECATED(#{Kernel.caller.first}) use TS3Query.server_connect instead of TS3Query.connect"
|
19
|
+
server_connect params
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.server_connect(params = {})
|
23
|
+
ServerConnection.new DefaultServerParams.merge(params)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.client_connect(params = {})
|
27
|
+
ClientConnection.new DefaultClientParams.merge(params)
|
13
28
|
end
|
14
|
-
|
15
|
-
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'ts3query/ts3_connection'
|
2
|
+
|
3
|
+
module TS3Query
|
4
|
+
class ClientConnection < TS3Connection
|
5
|
+
private
|
6
|
+
|
7
|
+
def connect(params)
|
8
|
+
begin
|
9
|
+
@connection = Net::Telnet::new("Host" => params[:address], "Port" => params[:port])
|
10
|
+
@connection.waitfor("Match" => /TS3 Client\n(.*)\n/,
|
11
|
+
"Timeout" => 3)
|
12
|
+
rescue
|
13
|
+
raise ConnectionRefused, "client not available"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'ts3query/ts3_connection'
|
2
|
+
|
3
|
+
module TS3Query
|
4
|
+
class ServerConnection < TS3Connection
|
5
|
+
private
|
6
|
+
|
7
|
+
def connect(params)
|
8
|
+
begin
|
9
|
+
@connection = Net::Telnet::new("Host" => params[:address], "Port" => params[:port])
|
10
|
+
@connection.waitfor("Match" => /TS3\n(.*)\n/,
|
11
|
+
"Timeout" => 3)
|
12
|
+
rescue
|
13
|
+
raise ConnectionRefused, "server not available"
|
14
|
+
end
|
15
|
+
|
16
|
+
begin
|
17
|
+
@connection.cmd("String" => "login client_login_name=#{params[:username]} client_login_password=#{params[:password]}\r",
|
18
|
+
"Match" => /error id=0 msg=ok\n/,
|
19
|
+
"Timeout" => 3)
|
20
|
+
rescue
|
21
|
+
raise ConnectionRefused, "wrong user data"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,88 +1,57 @@
|
|
1
1
|
require 'net/telnet'
|
2
|
+
require 'ts3query/errors'
|
3
|
+
require 'ts3query/query_options'
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
def disconnect
|
9
|
-
@connection.close
|
10
|
-
end
|
5
|
+
module TS3Query
|
6
|
+
class TS3Connection
|
7
|
+
def initialize(params)
|
8
|
+
connect(params)
|
9
|
+
end
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
params = ""
|
11
|
+
def disconnect
|
12
|
+
@connection.close
|
13
|
+
end
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
def method_missing(meth, *args, &block)
|
16
|
+
result = []
|
17
|
+
options = ""
|
18
|
+
params = ""
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
20
|
+
if block
|
21
|
+
query_options = QueryOptions.new
|
22
|
+
yield query_options
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
query_options.options.each do |opt|
|
25
|
+
options += " -#{opt}"
|
26
|
+
end
|
29
27
|
end
|
30
|
-
end
|
31
28
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
data.split("|").each do |current|
|
36
|
-
current_data = {}
|
37
|
-
current.split(" ").each do |entity|
|
38
|
-
current_data[entity.split("=")[0]] = entity.split("=")[1]
|
29
|
+
if args.first
|
30
|
+
args.first.each do |key, value|
|
31
|
+
params += " #{key}=#{value}"
|
39
32
|
end
|
40
|
-
current_data.delete("error")
|
41
|
-
current_data.delete("id")
|
42
|
-
current_data.delete("msg")
|
43
|
-
|
44
|
-
result << current_data
|
45
33
|
end
|
46
|
-
}
|
47
|
-
result << {"id" => "0", "msg" => "ok"}
|
48
|
-
result.delete({})
|
49
|
-
result
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
34
|
|
54
|
-
|
55
|
-
begin
|
56
|
-
@connection = Net::Telnet::new("Host" => params[:address], "Port" => params[:port])
|
57
|
-
@connection.waitfor("Match" => /TS3\n(.*)\n/,
|
58
|
-
"Timeout" => 3)
|
59
|
-
rescue
|
60
|
-
raise ConnectionRefused, "server not available"
|
61
|
-
end
|
62
|
-
|
63
|
-
begin
|
64
|
-
@connection.cmd("String" => "login client_login_name=#{params[:username]} client_login_password=#{params[:password]}\r",
|
35
|
+
@connection.cmd("String" => "#{meth}#{params}#{options}\r",
|
65
36
|
"Match" => /error id=0 msg=ok\n/,
|
66
|
-
"Timeout" => 3)
|
67
|
-
|
68
|
-
|
37
|
+
"Timeout" => 3) { |data|
|
38
|
+
data.force_encoding 'UTF-8'
|
39
|
+
data.split("|").each do |current|
|
40
|
+
current_data = {}
|
41
|
+
current.split(" ").each do |entity|
|
42
|
+
key, value = entity.split "="
|
43
|
+
current_data[key] = value
|
44
|
+
end
|
45
|
+
current_data.delete("error")
|
46
|
+
current_data.delete("id")
|
47
|
+
current_data.delete("msg")
|
48
|
+
|
49
|
+
result << current_data
|
50
|
+
end
|
51
|
+
}
|
52
|
+
result << {"id" => "0", "msg" => "ok"}
|
53
|
+
result.delete({})
|
54
|
+
result
|
69
55
|
end
|
70
56
|
end
|
71
57
|
end
|
72
|
-
|
73
|
-
class QueryOptions
|
74
|
-
def initialize
|
75
|
-
@options = []
|
76
|
-
end
|
77
|
-
|
78
|
-
def method_missing(meth, *args, &block)
|
79
|
-
options << meth.to_s
|
80
|
-
end
|
81
|
-
|
82
|
-
def options
|
83
|
-
@options
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
class ConnectionRefused < StandardError
|
88
|
-
end
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ts3query
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
5
|
-
prerelease:
|
4
|
+
version: '0.6'
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- TnT Web Solutions
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-09-11 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: Simple TS3 Query Library to connect to the query port of a teamspeak
|
15
14
|
3 server.
|
@@ -18,40 +17,43 @@ executables: []
|
|
18
17
|
extensions: []
|
19
18
|
extra_rdoc_files: []
|
20
19
|
files:
|
21
|
-
- lib/ts3query/ts3_connection.rb
|
22
|
-
- lib/ts3query.rb
|
23
|
-
- features/connect_to_server.feature
|
24
|
-
- features/run_command.feature
|
25
|
-
- features/support/env.rb
|
26
|
-
- features/step_definitions/run_command_steps.rb
|
27
|
-
- features/step_definitions/connection_steps.rb
|
28
20
|
- Gemfile
|
29
|
-
- Rakefile
|
30
21
|
- LICENSE.txt
|
31
22
|
- README.rdoc
|
23
|
+
- Rakefile
|
24
|
+
- features/connect_to_server.feature
|
25
|
+
- features/run_command.feature
|
26
|
+
- features/step_definitions/connection_steps.rb
|
27
|
+
- features/step_definitions/run_command_steps.rb
|
28
|
+
- features/support/env.rb
|
32
29
|
- init.rb
|
30
|
+
- lib/ts3query.rb
|
31
|
+
- lib/ts3query/client_connection.rb
|
32
|
+
- lib/ts3query/errors.rb
|
33
|
+
- lib/ts3query/query_options.rb
|
34
|
+
- lib/ts3query/server_connection.rb
|
35
|
+
- lib/ts3query/ts3_connection.rb
|
33
36
|
homepage: https://github.com/tntwebsolutions/ts3query
|
34
37
|
licenses: []
|
38
|
+
metadata: {}
|
35
39
|
post_install_message:
|
36
40
|
rdoc_options: []
|
37
41
|
require_paths:
|
38
42
|
- lib
|
39
43
|
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
-
none: false
|
41
44
|
requirements:
|
42
|
-
- -
|
45
|
+
- - ">="
|
43
46
|
- !ruby/object:Gem::Version
|
44
47
|
version: '0'
|
45
48
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
-
none: false
|
47
49
|
requirements:
|
48
|
-
- -
|
50
|
+
- - ">="
|
49
51
|
- !ruby/object:Gem::Version
|
50
52
|
version: '0'
|
51
53
|
requirements: []
|
52
54
|
rubyforge_project:
|
53
|
-
rubygems_version:
|
55
|
+
rubygems_version: 2.2.2
|
54
56
|
signing_key:
|
55
|
-
specification_version:
|
57
|
+
specification_version: 4
|
56
58
|
summary: Simple TS3 Query Library.
|
57
59
|
test_files: []
|