• Hey Guest, we're evolving the future of TeaSpeak.
    You're invited to join the discussion here!

Send private message to client when it connected to server

lbenicio

Well-known member
Anyone could help me figure out how to make a serverquery send a private message to all clients when it connects to my teaspeak server?

if it helps, i'm using this node project to handle the Bot: https://github.com/macpie/node-Tea*Speak-api

i managed to subscribe to all events:

JavaScript:
tsClient.subscribe('servernotifyregister', {
  event: 'all',
  specifier: 'all'
 }, function(error, resp, req) {})
then create a function that executes on all events and filter then to use:

JavaScript:
tsClient.on('notify', function(eventName, resp) {
  if (typeof(resp) == 'undefined') {
    console.log('no server response');
    return;
   }

if (eventName.localeCompare('textmessage') == 0) {
  if (resp.invokername.localeCompare(Globals.bot.name) == 0) {
    return;
  }
  if (!resp.invokername.startsWith(Globals.bot.name)) {
    command_interprerter(resp.invokerid, resp.msg, resp.invokername)
  }
} else if (eventName.localeCompare('cliententerview') == 0) {
  console.log('client enter view --')
  console.log(resp.clid + ' | ' + resp.client_nickname)
  get_client_info(resp.clid, function(client_id, client) {
    if (client_id != -1) {
      set_new_client(client_id, client);
      console.log('seted new client')
    }
  });
} else if (eventName.localeCompare('clientleftview') == 0) {
  remove_from_ts_members(resp.clid)
  }
});
all the console.log are printed out and the function execute, it succefully set the new client with the function set_new_client(client_id, client) but at the send of this function it should send the user a message that everything went ok, but it does not send.
 

lbenicio

Well-known member
my bot is whitelisted, so there isn't problem with flood time. What i mean by console.logs are printed out is that the is executed
 

lbenicio

Well-known member
just for the record, there was nothing wrong with the code. The problem was that the Bot and the TeaSpeak server is in the same host so my Bot Try to send the message fast then the TeaSpeak could "register" the user which makes the send_message via server query fail. That is why adding a delay worked. In case anyone face the same issue.