• Community Rep

    I think there's already a plugin written for this teamspeak thing. This might or might not be what you're looking for as I have no experience with teamspeak.


  • The plugin is outdated and it don't do what i'm looking for i'm trying to syncronize registred users with teamspeak to make users want to register to the forum to get teamspeak powers. I already have a PHP script doing it problem is embead it to nodebb

  • Community Rep

    Might be a good opportunity to try and port it to nodejs 🙂 Even better, if it's similar in functionality to the existing plugin, you could integrate it into the broken plugin and fix it, I'm pretty sure the author @pitaj is still responding to pull requests


  • yup the problem is my node.js knowledge is -100 haha ^^ if someone can teach me the basics I can try it

  • Community Rep

    @rbeer just made a really great post on getting primed for NodeJS here, along with many other great resources. JS will bend your brain a bit, but no one ever became a worse programmer from learning a new language. IMHO JS is even easier to play around with because you can just open a dev console in Chrome and start typing!


  • I can't find a good node.js framework for TS3 :c


  • Community Rep

    I don't know much PHP, but I think what he wants is a form on his NodeBB custom page that ajaxs the form to the existing PHP page.


  • @belstgut said:

    @DavidPS really? https://www.npmjs.com/search?q=ts3

    yes there are a lot but i can't find one where i can grab client info. I just found move and poke ones


  • Anybody can send me an example using this? https://github.com/gwTumm/node-teamspeak

    just a basic things to start to test and learn.


  • var TeamSpeakClient = require("node-teamspeak"),
        util = require("util");
    
    var cl = new TeamSpeakClient("##SERVERIP###");
    cl.send("login", {client_login_name: "##USERNAME##", client_login_password: "##PASSWORD##"}, function(err, response, rawResponse){
        cl.send("use", {sid: 1}, function(err, response, rawResponse){
            cl.send("clientinfo", {clid: "##CLIENTID##"} ,function(err, response, rawResponse){
                console.log(util.inspect(response));
            });
        });
    });
    

    this should connect you to your server, log u in, select virtual server 1, and print clientinfo for the client with id ##CLIENTID##.

    (slightly modified from the node-teamspeak example)


  • in what var this information will be stored? i don't understand the concept console.log of node.js

  • Community Rep

    console.log is just a print statement, like echo or print() in php.


  • oh nice, how send it as var from plugin to template? becouse if i add this script as script won't be secure becouse i will show my user password to everyone who insepct the code


  • @belstgut said:

    var TeamSpeakClient = require("node-teamspeak"),
        util = require("util");
    
    var cl = new TeamSpeakClient("##SERVERIP###");
    cl.send("login", {client_login_name: "##USERNAME##", client_login_password: "##PASSWORD##"}, function(err, response, rawResponse){
        cl.send("use", {sid: 1}, function(err, response, rawResponse){
            cl.send("clientinfo", {clid: "##CLIENTID##"} ,function(err, response, rawResponse){
                console.log(util.inspect(response));
            });
        });
    });
    

    this should connect you to your server, log u in, select virtual server 1, and print clientinfo for the client with id ##CLIENTID##.

    (slightly modified from the node-teamspeak example)

    tryed to use it between <script> tang on HTML and nothing appeared

  • Community Rep

    That code would go in you server js.

    Example:

    (function(module) {
    	"use strict";
    
    	var TeamSpeakClient = require("node-teamspeak"),
    		util = require("util");
    
    	var Plugin = {};
    
    	// static:app.load
    	Plugin.init = function(params, callback) {
    		var app = params.router,
    			middleware = params.middleware,
    			controllers = params.controllers;
    
    		var cl = new TeamSpeakClient("##SERVERIP###");
    		cl.send("login", {client_login_name: "##USERNAME##", client_login_password: "##PASSWORD##"}, function(err, response, rawResponse){
    			cl.send("use", {sid: 1}, function(err, response, rawResponse){
    				cl.send("clientinfo", {clid: "##CLIENTID##"} ,function(err, response, rawResponse){
    					console.log(util.inspect(response));
    				});
    			});
    		});
    
    		callback();
    	};
    
    	module.exports = Plugin;
    }(module));
    

    To talk between, use Sockets like so:

    (function(module) {
    	"use strict";
    
    	var TeamSpeakClient = require("node-teamspeak"),
    		util = require("util");
    
    	var SocketPlugins = module.parent.require('./socket.io/plugins');
    
    	var Plugin = {};
    
    	// static:app.load
    	Plugin.init = function(params, callback) {
    		var app = params.router,
    			middleware = params.middleware,
    			controllers = params.controllers;
    
    		// Define a namespace for your socket listener
    		SocketPlugins.YourPlugin = {
    
    			// Define the listener
    			formSubmit: function (socket, data, next) {
    
    				// data is your form results, as an array.
    				console.log(data[0].value); // Prints the value of the first item in your form.
    
    				var cl = new TeamSpeakClient("##SERVERIP###");
    				cl.send("login", {client_login_name: "##USERNAME##", client_login_password: "##PASSWORD##"}, function(err, response, rawResponse){
    					cl.send("use", {sid: 1}, function(err, response, rawResponse){
    						cl.send("clientinfo", {clid: "##CLIENTID##"} ,function(err, response, rawResponse){
    
    							console.log(util.inspect(response));
    
    							// Send a response back to the client.
    							next(null, {whatever: datayouwant});
    						});
    					});
    				});
    			}
    		};
    		
    
    		callback();
    	};
    
    	module.exports = Plugin;
    }(module));
    

    client js:

    <form>...</form>
    
    <script>
    $( "form" ).submit(function( event ) {
      socket.emit( 'plugins.YourPlugin.formSubmit', $( this ).serializeArray(), function (err, data) {
        if (data) console.log("Got response from server.");
      });
      event.preventDefault();
    });
    </script>
    

    Check out the socket.io docs and jquery docs.


  • How to send the results in a div or something?

  • Community Rep

    @DavidPS You want to use JQuery selectors.

    Something like this.


  • Nice I nearly finished it! just need how to store some info to database and how to display errors with the nodebb modal boxes


  • More questions: How make content for registred users only?

Suggested Topics

  • 7
  • 4
  • 1
  • 2
  • 1
| |