Skip to content

whats0n0/teamspeak-query

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

teamspeak-query npm version

A small library which exposes an API to talk to your Teamspeak-Server via the Teamspeak-ServerQuery

Installation

$ npm install teamspeak-query

Example

const TeamspeakQuery = require('teamspeak-query');
const query = new TeamspeakQuery('127.0.0.1', 10011);

query.send('login', 'serveradmin', 'changeme')
	.then(() => query.send('use', 1))
	.then(() => query.send('servernotifyregister', { 'event': 'server' }))
	.then(() => console.log('Done! Everything went fine'))
	.catch(err => console.error('An error occured:', err));

// After teamspeak has processed 'servernotifyregister' we will get notified about any connections
query.on('cliententerview', data =>
	console.log(data.client_nickname, 'connected') );

Constructor

The constructor takes 3 parameters

Name Default Description
host 127.0.0.1 The ip of the server
port 10011 The query port of the server
options { } Any options that should be passed to the socket

INFO: The raw socket can be accessed via the instance's sock property.

Methods

TeamspeakQuery.send(cmd, params?, ...flags?)

Send a command to the server.
There are 2 ways (which can also be mixed) to specify parameters for the command:

  • params: An object, e.g. { 'parameter': 'value', 'x': 42 }.
  • ...flags: Plain arguments passed to the function, e.g. query.send('login', 'username', 'password').
    You can also use it to set flags, e.g. query.send('clientlist', '-uid').

TeamspeakQuery#parse(str)

Parse the response of the server, returns an object that contains the type of the response (error, notification, etc.) and the parameters that were returned by the server.

TeamspeakQuery#escape(str)

Escape a string according to the specification.

TeamspeakQuery#unescape(str)

Unescape a string according to the specification.

Throttling

Commands are being throttled by default if the host is not set to the local machine (127.0.0.1 or localhost) in order to prevent a ban for flooding (see Whitelisting and Blacklisting in the specs).
The instance of lib/throttle.js can be accessed via TeamspeakQuery.throttle.
If you want to disable throttling, you can do it like this: TeamspeakQuery.throttle.set('enable', false).

Packages

No packages published

Languages

  • JavaScript 100.0%