BattlenetTS
BattlenetTS allowes you to use battle.net OAuth2 to authenticate users against your TeamsSpeak3 server. The battlenet api is invoked to check if te authenticated user is a member of a guild on a specified realm. This allows you to make sure that your guild's teamspeak server is used by the people that are in your guild.
Features
- Connect to a teamspeak's server query
- Authenticates users against the battle.net api
- Manipulate users in teamspeak based on the result of the authentication
- Send teamspeak private text messages
- Add or remove users from teamspeak groups based on group name
- Get guild member information to get the rank id
- Listen for incoming chat messages that are sent to the bot
- Get a list of characters the account has in the guild
Initialization
var BattleTS = ; var bts = url: 'https://localhost:3000' battlenet_region: 'us' battlenet_key: '' battlenet_secret: '' ssl_ca: './server.csr' ssl_cert: './server.crt' ssl_key: './server.key' teamspeak_ip: '' teamspeak_queryport: '10011' teamspeak_username: 'serveradmin' teamspeak_password: '' teamspeak_botname: 'SuperAdmin' realm_name: '' guild_name: '';
EventEmitter
Since BattleTS is an eventemitter you can listen for the following events
- teamspeak.connected - The server query client is successfully connected to the teamspeak server
- express.started - The expressjs webserver has started and is listening for connections
- teamspeak.client.connected (client) - A client is connected to our teamspeak server
- teamspeak.chat.received (clid, message) - A client has sent a chat message to the bot
- battlenet.user.authenticated (profile) - A client is successfully authenticated against the battle.net api
- battlenet.user.verified (character) - A client is successfully verified as being part of the guild/realm
- battlenet.user.notverified (error) - A client is not verified as being part of the guild/realm
Battle.net Development
You need an account on http://dev.battle.net/ with an application to get the battlenet_key and battlenet_secret information
Example
var BattleTS = ; var bts = url: 'https://localhost:3000' battlenet_region: 'us' battlenet_key: '' battlenet_secret: '' ssl_ca: './server.csr' ssl_cert: './server.crt' ssl_key: './server.key' teamspeak_ip: '' teamspeak_queryport: '10011' teamspeak_username: 'serveradmin' teamspeak_password: '' teamspeak_botname: 'SuperAdmin' realm_name: '' guild_name: ''; bts; bts; bts; bts; bts; bts; bts; /*This does the same as the above listenerbts.on('battlenet', function(subject, action, profile) { console.log(subject); // == 'user' console.log(action); // == 'authenticated' console.log(profile);});*/ bts;
Note from author
I had to create a ssl certificate to be able to use the battle.net api
openssl genrsa -des3 -out server.key 1024openssl req -new -key server.key -out server.csrcp server.key server.key.orgopenssl rsa -in server.key.org -out server.keyopenssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crtrm server.key.org