cmr1-ts3-bot

0.1.6 • Public • Published

npm version build status

node-ts3-bot

A simple bot framework for TeamSpeak3

Install

npm install cmr1-ts3-bot --save

Usage

// Require cmr1-ts3-bot
const Bot = require('cmr1-ts3-bot');
 
// Create a new bot with desired configuration (these are the default values)
const bot = new Bot({
  sid: 1,
  name: 'Woodhouse',
  user: 'serveradmin',
  pass: 'password',
  host: '127.0.0.1',
  port: 10011,
  channel: 'Default Channel',
  verbose: false
});
 
// Initialize the bot (callback is optional)
bot.init((err) => {
  if (err) // Something didn't work
  else     // The bot is alive!
});
 
// Listen for the bot's "ready" event (emitted after succesfull "init")
bot.on('ready', () => {
  // Send a message to the TS3 main server chat
  bot.server.message('Ready for service');
});
 
// Listen for the bot's "join" event (the bot will automatically join the channel specified)
bot.on('join', channel => {
  // Send a message to the channel that the bot has now joined
  channel.message('I have joined this channel!');
});
 
// Register a command for this bot that can be invoked in the channel chat
bot.channelCommand('ping', (args, context) => {
  // When someone says "ping" in the bot's channel, reply to that channel with "pong"
  bot.channel.message('pong');
});

Configuration

The bot can be configured when created (as shown above) or using environment variables:

# Bot Settings 
BOT_VERBOSE=0
BOT_NAME=Woodhouse
 
# TS3 Settings 
TS3_SID=1
TS3_USER=serveradmin
TS3_PASS=password
TS3_CHANNEL=Default Channel
TS3_HOST=127.0.0.1
TS3_PORT=10011

Methods

  • init
  • disconnect
  • shutdown
  • getServerGroupByName
  • getServer
  • getClientById
  • getClientByName
  • getChannelById
  • getChannelByName
  • globalCommand
  • clientCommand
  • channelCommand
  • serverCommand
  • messageClient
  • messageChannel
  • messageServer

Events

  • ready
  • join
  • action
  • unknowncommand
  • cliententerview
  • clientleftview
  • cliententerchannel
  • clientleftchannel
  • warning
  • failure

Package Sidebar

Install

npm i cmr1-ts3-bot

Weekly Downloads

1

Version

0.1.6

License

MIT

Unpacked Size

33.6 kB

Total Files

27

Last publish

Collaborators

  • cmr1