Forum


Notice to all users

We are migrating towards a new forum system located at community.teamspeak.com, as such this forum will become read-only on January 29, 2020

Page 68 of 100 FirstFirst ... 1858666768697078 ... LastLast
Results 1,006 to 1,020 of 1498
  1. #1006
    Join Date
    April 2014
    Location
    Seattle, WA, USA
    Posts
    141
    Please explain what you would like to do.

  2. #1007
    Join Date
    October 2014
    Posts
    3
    So. I want to create a code, which will send a message to selected rooms channel admin. I have Channel ID, but not Client ID. That's my problem. I need code, which will get me current admins of channel. I was thinking about IP address, but there can be more users with the same IP address.

    Sorry for my english

  3. #1008
    Join Date
    December 2013
    Location
    Poland
    Posts
    17
    Quote Originally Posted by terrdus View Post
    I need code, which will get me current admins of channel.
    PHP Code:

     $adminchannelgroupID 
    "5"// Channel Admin Group ID

    $ts3_VirtualServer TeamSpeak3::factory("serverquery://$TSadminNickname:$TSpassword@$TSaddress:$TSqueryport/?server_port=$TSport&nickname=$botname");
     
    $arr_ChadminList $ts3_VirtualServer->channelGroupGetById("$adminchannelgroupID"); 
     
    $TSuserdata = array();
     
     foreach (
    $arr_ChadminList as $TSClid => $TSArray)
    {
        
    array_push($TSuserdata, array(

            
    "TsNICK" => $TSArray->client_nickname->toString(),
            
    "TsDBID" => $TSArray->client_database_id,
            
    "TsUID" => $TSArray->client_unique_identifier->toString(),
            
    "TsCHANID" => $TSArray->cid,
            ));
    }

    var_dump($TSuserdata); 

  4. #1009
    Join Date
    October 2003
    Location
    Germany
    Posts
    2,527
    Quote Originally Posted by terrdus View Post
    So. I want to create a code, which will send a message to selected rooms channel admin. I have Channel ID, but not Client ID. That's my problem. I need code, which will get me current admins of channel. I was thinking about IP address, but there can be more users with the same IP address.
    This sends a text message to all channel admins connected to the server:

    PHP Code:
    <?php

    // load framework
    require_once('lib/TeamSpeak3/TeamSpeak3.php');

    // connect, login and select server
    $server TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987");

    // get a list of connected clients filtered by channel ID and channel group ID
    $clients $server->clientList(array("cid" => 1"client_channel_group_id" => 5));

    // walk through clients
    foreach($clients as $client)
    {
      
    $client->message("You are a Channel Admin! :-)");
    }
    I've not tested the code, but it should do the trick...


  5. #1010
    Join Date
    October 2014
    Posts
    3
    Thanks Yanek & ScP. Both codes are working

  6. #1011
    Join Date
    October 2014
    Posts
    1
    Never mind this post, it's not related to the framework.
    Last edited by Pauluzz; October 23rd, 2014 at 08:51 PM.

  7. #1012
    Join Date
    June 2013
    Posts
    32
    What is the callback to figure out if the client has disconnected or not?
    Is it possible to make the waiting bot stay longer than just 10 minutes?

  8. #1013
    Join Date
    June 2012
    Location
    Portugal
    Posts
    317
    PHP Code:
    load framework files
    require_once("libraries/TeamSpeak3/TeamSpeak3.php");
    // connect to local server in non-blocking mode, authenticate and spawn an object for the virtual server on port 9987
    $ts3_VirtualServer TeamSpeak3::factory("serverquery://username:[email protected]:10011/?server_port=9987&blocking=0");
    // get notified on incoming private messages
    $ts3_VirtualServer->notifyRegister("server");
    // register a callback for notifyTextmessage events 
    TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyTextmessage""onServerEvent");
    // wait for events
    while(1) {
     
    $ts3_VirtualServer->getAdapter()->wait();
     
    $ts3_VirtualServer->getParent()->whoami();
     
    sleep(1);
    }
    // define a callback function
    function onServerEvent(TeamSpeak3_Adapter_ServerQuery_Event $eventTeamSpeak3_Node_Host $host)
    {
      
    var_dump($event);

    I think it is this one, if it isn't you need to stay in the default channel and subscribe for "channel".

    It will also prevent disconnect, because it will send a command at least every 1 second...
    Not sure if this works, untested!! But should be around this concept.

    Try doing this and check what var_dump shows... I don't remember any more stuff as I haven't done much for persistent scripts (prefer java to stay online connected to the server).

  9. #1014
    Join Date
    June 2011
    Location
    Germany
    Posts
    4,368
    Sending a command every second will get you banned quite quickly unless whitelisted.
    I send a \n\r every five minutes. Not sure if this API can do this.

  10. #1015
    Join Date
    April 2014
    Location
    Seattle, WA, USA
    Posts
    141
    The "Console" example shows a good implementation of a bot and it uses the built-in keepalive from the wait() method (not sure how the keepalive is implemented), but it basically prints to the console window every 20 seconds if it hasn't received any new data, then after like 120 seconds or something it triggers the keepalive routine and starts over, still waiting.

    You can find the example codes on:
    https://github.com/Luceos/ts3-php/tree/master/examples

    The "Console" example is in the "apps" folder:
    https://github.com/Luceos/ts3-php/tr...s/apps/console

    From the Console.php file we have:

    PHP Code:
    /* initialize */
    TeamSpeak3::init();
    try
    {
      
    /* subscribe to various events */
      
    TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryConnected""onConnect");
      
    TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryCommandStarted""onCommand");
      
    TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryWaitTimeout""onTimeout");
      
    TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyLogin""onLogin");
      
    TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyEvent""onEvent");
      
    TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyTextmessage""onTextmessage");
      
    TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyServerselected""onSelect");
      
    /* connect to server, login and get TeamSpeak3_Node_Host object by URI */
      
    $ts3 TeamSpeak3::factory("serverquery://" $cfg["user"] . ":" $cfg["pass"] . "@" $cfg["host"] . ":" $cfg["query"] . "/?server_port=" $cfg["voice"] . "&blocking=0");
      
    /* register for all events available */
      
    $ts3->notifyRegister("server");
      
    $ts3->notifyRegister("channel");
      
    $ts3->notifyRegister("textserver");
      
    $ts3->notifyRegister("textchannel");
      
    $ts3->notifyRegister("textprivate");
      
    /* wait for events */
      
    while(1$ts3->getAdapter()->wait();
    }
    catch(
    Exception $e)
    {
      die(
    "[ERROR]  " $e->getMessage() . "\n");

    The wait() method has the keepalive built-in. So if it's dropping after 10 minutes, this is most likely do to network or environment issues where you're running the Server Query client script. I've had several scripts running for weeks without d/c, but they're all running on the same server as the TS3Server.
    --
    Re: disconnected user

    I highly recommend reviewing the event message types on numma_cway's website:
    http://redeemer.biz/medien/artikel/ts3-query-notify/

    The event to watch for a user's disconnect will be notifyclientleftview

    You can actively watch / check each occurrence to see if your target user has disconnected.
    But, more likely, you should instead just use clientListReset() if you just want to make sure a client is connected still before running a command on them, (i.e. no unset array reference error)

  11. #1016
    Join Date
    November 2014
    Posts
    1
    i think that should work

  12. #1017
    Join Date
    June 2011
    Location
    Germany
    Posts
    4,368
    Not sure if barricas meant that, but I confirmed that subscribing alone does not prevent you from timing out.

  13. #1018
    Join Date
    June 2012
    Location
    Portugal
    Posts
    317
    Quote Originally Posted by numma_cway View Post
    Not sure if barricas meant that, but I confirmed that subscribing alone does not prevent you from timing out.
    Ah no I didn't, I never really worked much with ts3 events with PHP.

    If it keeps the connection alive then it is fine, in my code whoami() and sleep should be removed.

  14. #1019
    Join Date
    January 2010
    Location
    Germany
    Posts
    252
    Hi ScP,

    is ist possible to implement priorities into TeamSpeak3_Helper_Signal::subscribe() and can you implement a function to register aggregate classes ?

  15. #1020
    Join Date
    June 2012
    Location
    Portugal
    Posts
    317
    What you mean with register aggregate classes?

Thread Information

Users Browsing this Thread

There are currently 10 users browsing this thread. (0 members and 10 guests)

Similar Threads

  1. PHP Framework
    By Multivit4min in forum Permission System
    Replies: 1
    Last Post: June 29th, 2015, 12:28 PM
  2. PHP Framework
    By phil998 in forum Server Support
    Replies: 0
    Last Post: February 25th, 2015, 07:27 PM
  3. TS3 PHP Framework Visualizations
    By Ronin Design in forum Tools / Web Based
    Replies: 2
    Last Post: February 22nd, 2015, 06:04 AM
  4. Extraction using the Framework
    By HarryMW in forum Tools / Web Based
    Replies: 1
    Last Post: August 3rd, 2012, 08:04 PM
  5. Teamspeak, PHP Framework?
    By mario2027 in forum General Questions
    Replies: 1
    Last Post: December 21st, 2010, 10:30 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •