alfred-teamspeak

4.0.1 • Public • Published

Alfred npm version

A Teamspeak 3 Bot Module utilizing the Teamspeak ServerQuery

Installation

$ npm install alfred-teamspeak

Example

const Alfred = require('alfred-teamspeak');
const bot = new Alfred();
 
bot.login('username', 'password')
    .then(() => console.log('Connected!'))
    .catch(err => console.error(err));
    
bot.on('cliententerview', data => console.log(data.client_nickname, 'connected!'));

Options

Options are passed via an object on construction: new Alfred({ ... })

Name Default Description
name Alfred The name of the bot
host 127.0.0.1 The IP to connect
port 10011 The query port of the server
sid 1 The ID of the Virtual Server

Methods

Alfred.login(username, password)

Login with the specified name and password. Returns a promise which is being resolved on successful login and rejected on failure.

Alfred.send( ... )

Inherited from schroffl/teamspeak-query.

Alfred.set(key, value)

Set a variable.

Alfred.get(key)

Get the value of a variable.
NOTE: After the login you can use Alfred.get('clid') to obtain the ID of the bot.

Alfred.use(event, callback)

Mount the specified callback function to the given event. If event is omitted, the handler will be called for any event.

Middleware

As already said, middleware can be mounted via Alfred.use and may or may not only be used for a specific event such as cliententerview.
Whenever an event occurs, the stack for it will be called with the data the server has given. After the stack has finished, the event will be emitted. So Alfred.on('cliententerview', ...) will be fired when all the middleware has processed the data.
If you want to create your own middleware, take a look at Creating Middleware.
An example can be found here: lib/user.js

User Middleware

Alfred already ships with a package that offers an interface to easily interact with users. You can include like this:

const Alfred = require('alfred-teamspeak');
const User = Alfred.User;
 
const bot = new Alfred();
 
bot.use(User);
// [...]

So now if anyting user-related happens, you can respond to the users as easy as:

bot.on('cliententerview', data => data.user.respond('Hello', data.user.get('name')) );

Further documentation of the package can be found here.

Readme

Keywords

Package Sidebar

Install

npm i alfred-teamspeak

Weekly Downloads

15

Version

4.0.1

License

MIT

Last publish

Collaborators

  • schroffl