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 80 of 100 FirstFirst ... 3070787980818290 ... LastLast
Results 1,186 to 1,200 of 1498
  1. #1186
    Join Date
    November 2015
    Posts
    1
    Ok, i have a bot running and correctly registered to event "textprivate", so i can successfully receive commands and reply to the user with content.

    Now, since the queryclient isnt visible in the list, how can I register to another event "onserverjoin" or something like that, so everyone that logs in receive a message from the bot, listing the commands etc... ? Even further.. instead of registering only to private messages, how can the bot also listen to the messages sent on the server's main chat? that way i wouldnt be needed to open a private tab with the bot to send commands (which is hard since it isnt visible).

    I miss a richer documentation where is the list of events we can subscribe to other than "textprivate" thats in the example? where is the list of the variables passed to the callback thats called when an event is triggered?

    Thank you in advance!
    Last edited by Sheetos; November 26th, 2015 at 09:33 PM.

  2. #1187
    Join Date
    September 2010
    Location
    portugal
    Posts
    34
    any idea why this is the only lib that phpstorm dosent auto-complete? '-'

  3. #1188
    Join Date
    October 2003
    Location
    Germany
    Posts
    2,527
    Quote Originally Posted by Facha View Post
    any idea why this is the only lib that phpstorm dosent auto-complete? '-'
    That's something I'm working on...


  4. #1189
    Join Date
    November 2015
    Posts
    6
    Quote Originally Posted by naurel View Post
    I've got something interesting in the API :
    ORIGINAL POST

    The following code :
    PHP Code:
    $a=$ts3->clientList();
    print_r($a); 
    Doesn't return the same result as the following one :
    PHP Code:
    $a=$ts3->clientList();
    $b=$ts3->ServerGroupList();
    print_r($a); 
    Any idea why ?
    @ScP ? Am I doing something wrong ?

  5. #1190
    Join Date
    December 2015
    Posts
    1

    PHP framework loops connection for some reason

    A goodday to all of you.
    I am a developer at RoleplayUnited (gaming clan) and I am trying to develop a TS3 bot.

    I am using the PHP framework.
    What I am trying to do is make the bot respond to any .command sent through a textmessage (server, channel or private).
    I am able to receive the .command server-side and I am able to sent a response to the invoker.

    The problem is this:

    After I respond to the invoker, the bot opens up an infinite amount of ServerQuery connections up until the point that the server is full (server maxclient reached). What I want the bot to do is to go "back to sleep" and listen for other commands after calling the processCommand (onTextMessage) function.

    This is all working:
    PHP Code:
    $ts3_connection = new Ts3($pdo); /* my own TS3 class that holds connection variables */
    $ts3 TeamSpeak3::factory($ts3_connection->connect);
    $ts3->notifyRegister("textchannel");
    TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyTextmessage", array($ts3_connection"processCommand"));
    while(
    1) { $ts3->getAdapter()->wait(); }
    $ts3->logout(); 
    This is the method that processes the command. I suspect that something is wrong here:
    PHP Code:
    function processCommand(TeamSpeak3_Adapter_ServerQuery_Event $eventTeamSpeak3_Node_Host $host) {
        
    $ts3 TeamSpeak3::factory($ts3_connection->connect);
        
    /* Ping test */
        
    if(in_array($event["msg"], [".ping"])) {
            
    $ts3->clientGetByUid($event["invokeruid"])->message("Pong!");
        }
        return 
    0;

    I would be most thankful for any help that points me in the right direction.


    EDIT: Managed to fix the problem myself!
    I switched "$ts3 = ..." in the function to "global $ts3" to stay in the same connection.
    When I had fixed it, I ran across a massive memory leak problem.
    The framework picked up the ->message() as a "textprivate" event and therefor looped "default".
    I managed to fix it by comparing "$event["invokerid"]" with the bots UID.
    Last edited by bartk; December 8th, 2015 at 01:06 PM. Reason: Fixed it myself.

  6. #1191
    Join Date
    October 2003
    Location
    Germany
    Posts
    2,527
    Quote Originally Posted by naurel View Post
    @ScP ? Am I doing something wrong ?
    Sounds weird... I'll have a look at it.



    Quote Originally Posted by bartk View Post
    EDIT: Managed to fix the problem myself!
    I switched "$ts3 = ..." in the function to "global $ts3" to stay in the same connection.
    When I had fixed it, I ran across a massive memory leak problem.
    The framework picked up the ->message() as a "textprivate" event and therefor looped "default".
    I managed to fix it by comparing "$event["invokerid"]" with the bots UID.
    Good job! There's one more thing you can improve/change. Since the TeamSpeak3_Node_Host object is passed to the callback, you can also use it to get the active server object instead of using global variables.

    PHP Code:
    if($host->whoami("client_unique_identifier") != $event["invokeruid"])
    {
      
    $host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message("Pong!");


  7. #1192
    Join Date
    December 2013
    Posts
    13
    how can you handle the double events?
    This works, but i cannot seem to get the double events out of it.

    //removed code
    Last edited by Mickroz; January 10th, 2016 at 09:36 PM.

  8. #1193
    Join Date
    March 2011
    Location
    Russia
    Posts
    24

    example

    please write a working example of a script that creates a channel and gives the token.
    !thx

  9. #1194
    Join Date
    December 2013
    Posts
    13
    Quote Originally Posted by 9611262 View Post
    Hey!
    I've made a script that creates a sub-channel working with form in index.php and it's working but I would like to get back this channel ID, can you help me?

    PHP Code:
        session_start();
        require_once(
    'libraries/TeamSpeak3/TeamSpeak3.php');
        
    $server = array( 
            
    "ts_ip" => "localhost",
            
    "ts_port" => "9987",
            
    "ts_query_admin" => "admin"// admin
            
    "ts_query_password" => ":)"// hidden pass
            
    "ts_query_port" => "10011",
        );
        try {
            
    TeamSpeak3::init();
            
    $ts3_VirtualServer TeamSpeak3::factory("serverquery://".$server["ts_query_admin"].":".$server["ts_query_password"]."@".$server["ts_ip"].":".$server["ts_query_port"]."/?server_port=".$server["ts_port"]);
            
    $channel_id 2;
            
    $channel_name $_POST['channel_name'];
            
    $channel_password $_POST['channel_password'];
            
    $channel_founder $_POST['channel_admin'];
            
    $channel_operator $_POST['channel_operator'];
            
    $top_cid $ts3_VirtualServer->channelGetById($channel_id);
            
    $channel_date date('d.m.Y');
            
            
    $sub_cid $ts3_VirtualServer->channelCreate(array(
                
    "channel_name" => "$channel_name",
                
    "channel_password" => "$channel_password",
                
    "channel_topic" => "$channel_date",
                
    "channel_description" => "[size=10][b]Channel admin:[/b] "."$channel_admin"."\n[b]Channel operator:[/b] "."$channel_operator"."[/size]",
                
    "channel_codec" => TeamSpeak3::CODEC_OPUS_VOICE,
                
    "channel_codec_quality" => 10,
                
    "channel_flag_permanent" => TRUE,
                
    "cpid" => $top_cid,
                
    "cid" => $show_channel_id
            
    ));
            
            
    $_SESSION['show_channel_id'] = "Your channel ID is: "."$show_channel_id";
            
            
    header('Location: index.php');
        }
        catch(
    Exception $e) {
            echo 
    "ErrorID: <b>"$e->getCode() ."</b>; Error Message: <b>"$e->getMessage() ."</b>;";
        } 
    $sub_cid holds your channel id.

  10. #1195
    Join Date
    December 2012
    Location
    Bavaria, DE
    Posts
    120
    I want to unban someone with the uid and i dont know how because i get always "parameter not found"
    Code:
        $serverInstance->execute("bandel", array("uid" =>"5Rtv65GwCTLrt7juyCs3iVN3o/I="));

  11. #1196
    Join Date
    September 2012
    Posts
    6,079
    Quote Originally Posted by TheYesFlofus View Post
    I want to unban someone with the uid and i dont know how because i get always "parameter not found"
    Code:
        $serverInstance->execute("bandel", array("uid" =>"5Rtv65GwCTLrt7juyCs3iVN3o/I="));
    the bandel command has no uid parameter, only a banid one. So you need to specify the ban you want to delete by its internal id. If you don't know it then you'll have to search for it in the banlist output.
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  12. #1197
    Join Date
    December 2012
    Location
    Bavaria, DE
    Posts
    120
    Quote Originally Posted by Chris View Post
    the bandel command has no uid parameter, only a banid one. So you need to specify the ban you want to delete by its internal id. If you don't know it then you'll have to search for it in the banlist output.
    can you explan me how i can unban a user over uid because my php is not the best ^^

  13. #1198
    Join Date
    September 2012
    Posts
    6,079
    grab the banlist, search for the ban(s) matching the user you want to unban, get the ids for those bans and call bandel with these ids.

    Not sure how the framework returns the stuff but something along the lines of the following should do the trick.
    PHP Code:
    $banlist $server->banList();
    foreach (
    $banlist as $banId => $ban) {
        
    // Not sure what kind of stuff $ban is but assuming it's a string this should do the trick
        
    if (strpos($ban$uidToUnban) !== false) {
            
    $server->banDelete($banId);
        }

    No guarantees that the above code is fit for production, nor that it works in the first place! Above code may or may not actually destroy your server and the entire universe!
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  14. #1199
    Join Date
    December 2012
    Location
    Bavaria, DE
    Posts
    120
    Quote Originally Posted by Chris View Post
    grab the banlist, search for the ban(s) matching the user you want to unban, get the ids for those bans and call bandel with these ids.

    Not sure how the framework returns the stuff but something along the lines of the following should do the trick.
    PHP Code:
    $banlist $server->banList();
    foreach (
    $banlist as $banId => $ban) {
        
    // Not sure what kind of stuff $ban is but assuming it's a string this should do the trick
        
    if (strpos($ban$uidToUnban) !== false) {
            
    $server->banDelete($banId);
        }

    No guarantees that the above code is fit for production, nor that it works in the first place! Above code may or may not actually destroy your server and the entire universe!
    this code delete all bans (and got an error Warning: strpos() expects parameter 1 to be string, array given in)

  15. #1200
    Join Date
    December 2012
    Location
    Bavaria, DE
    Posts
    120
    i found the correct code to ban someone with the uid
    PHP Code:
    $banlist $serverInstance->banList();
    foreach (
    $banlist as $banId => $banvalue) {
            if (!
    strlen($banvalue["uid"]))
                continue;
                if(
    $banvalue["uid"] == $uidToUnban)
                try{
                        
    $serverInstance->banDelete($banvalue["banid"]);
                }
     catch (
    Exception $e)
     {
         
     }


Thread Information

Users Browsing this Thread

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

Similar Threads

  1. PHP Framework
    By Multivit4min in forum Permission System
    Replies: 1
    Last Post: June 29th, 2015, 11:28 AM
  2. PHP Framework
    By phil998 in forum Server Support
    Replies: 0
    Last Post: February 25th, 2015, 06:27 PM
  3. TS3 PHP Framework Visualizations
    By Ronin Design in forum Tools / Web Based
    Replies: 2
    Last Post: February 22nd, 2015, 05:04 AM
  4. Extraction using the Framework
    By HarryMW in forum Tools / Web Based
    Replies: 1
    Last Post: August 3rd, 2012, 07:04 PM
  5. Teamspeak, PHP Framework?
    By mario2027 in forum General Questions
    Replies: 1
    Last Post: December 21st, 2010, 09: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
  •