Send Message to teamspeak users based on txt file

Corne

Member
Jan 12, 2016
39
4
40
Name of the script: Message Affected Users

Functions of the script: This script should send a message to users that are present in a specific text file on my linux server

Why do you want it: This script should inform users of a predefined message only if their names appear in a text file. Names of affected users are automatically added to the text file. Fortunately the text file only consists of the EXACT user name. Each users on a separate line.

Screenshots: I dont have a screenshot for this one unfortunately as its just a basic script.

Original source (if any): No original source. Its just a need i have that will greatly assist us.
Other notes:
I would like a script that will connect to teamspeak. (With a custom Alias" then read the predefined file, Match the names to the users that is currently on teamspeak. and send them the predefined message.

Thank you very much guys!
 

h0tPL

Member
Sep 17, 2015
3
0
33
I think I will be able to write it down but I have few questions, how many times the script should send this message to this guy or you mean after sended message he will be automatically deleted from the list.
 

Corne

Member
Jan 12, 2016
39
4
40
The text file gets replaced by a new one ever X (How many ever minutes i set the cronjob to) minutes.
This if i can run the script via Cronjon i can ensure that the text file has been replaced and the data the "script" will see is fresh and new
To Answer your question. the "script" only needs to send the message once per execute

here is an example of the file when i cat it withing the linux cli
[test@linux ~]# cat currentusers.txt
Name IP
user1 XX.XX.8.218
test XX.XX.136.162
radio XX.XX.35.84
avril XX.XX.192.227
Please note i will remove the words "name", "IP" and the IP address if needed
 

h0tPL

Member
Sep 17, 2015
3
0
33
It will be the problem instead using txt file the script will use php file ? And this file will look like this ...

PHP:
<?php

$config = array(
    'ip_server'                     =>    '347.135.409.143',
    'query_port'                    =>     10011,
    'port'                          =>     1337,
    'server_query_login'            =>     "serveradmin",
    'server_query_password'         =>    "XYZ",

    'send' => array('h0tPL' => '123.321.1337',
                'Corner' => '321.123.1337')
);

?>
 

Corne

Member
Jan 12, 2016
39
4
40
Would i need to modify the PHP script every time? Or can we not set the array to read from file?

I can run a php file with "php /path/to/file.php" from the cli on a crontab so thats no problem.
 

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
I am a bit confused. When should the user get the message? If IP & nickname exactly matches from your text file?
 

Corne

Member
Jan 12, 2016
39
4
40
Both Values is Unique so technically either one is fine. But i originally i though about using the nick name.
If the script can send a pre defined message to the users in the group, we will achieve our goal
 

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
Try this
PHP:
<?php
$filelocation = "/home/myfile.txt";
$message = "HELLO! YOU ARE ON MY SECRET LIST";
$nicks = [];
$ips = [];

require_once("libraries/TeamSpeak3/TeamSpeak3.php");
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987");
$ts3_VirtualServer->selfUpdate(['client_nickname'=>"MY AWESOME BOT 3000"]);


$handle = fopen($filelocation, "r");
if ($handle) {
    while (($line = fgets($handle)) !== false) {
        $parts = preg_split('/\s+/', $line);
        $nicks = $parts[0];
        $ips = $parts[1];
    }
    fclose($handle);
}

foreach($ts3_VirtualServer->clientList() as $client) {
    if(in_array($client['CLIENT_NICKNAME'], $nicks)) {
        
        $client->message($message);
    } else if (in_array($client['CONNECTION_CLIENT_IP'], $ips)) {
        $client->message($message);
    }
}
 

Corne

Member
Jan 12, 2016
39
4
40
Cheking now. Thanks in advance

Almost there. Do you perhaps have any advice on the below error im getting while trying to run it?
PHP Fatal error: Class 'TeamSpeak3_Adapter_Exception' not found in /path/TS_Scripts/libraries/TeamSpeak3/Adapter/ServerQuery/Exception.php on line 32
 
Last edited by a moderator:

Corne

Member
Jan 12, 2016
39
4
40
Tried that. and additionally gave all sub directories of this directory 777 perms aswell.
Tried running it again with the same error. Im researching some more into the error on this side
 

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
Try (re)downloading latest version of the PHP framework
 

Corne

Member
Jan 12, 2016
39
4
40
Got it redownloaded. Just sorting out a password issue. I think it might be reading the login info wrong as my password contains a @ sign
but yea its keeps on not liking my login credentials

OK got passed the password issue. It does not seem to like some variable

php msg_IP_users.php
PHP Fatal error: Uncaught TeamSpeak3_Adapter_ServerQuery_Exception: invalid parameter in /path/TS_Scripts/libraries/TeamSpeak3/Node/Abstract.php:582
Stack trace:
#0 /path/TS_Scripts/msg_IP_users.php(23): TeamSpeak3_Node_Abstract->offsetGet('CLIENT_NICKNAME')
#1 {main}
thrown in /path/TS_Scripts/libraries/TeamSpeak3/Node/Abstract.php on line 582
 
Last edited by a moderator:

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
Replace CLIENT_NICKNAME with client_nickname. If it won't help try removing whole brackets so it is just $client if this wont help then try to cast $client to string - (string)$client
 

Corne

Member
Jan 12, 2016
39
4
40
Using small letter worked. I had to change "CONNECTION_CLIENT_IP" aswell.

After that i ran the script again and got the below

PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 23
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on line 26
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
PHP Warning: in_array() expects parameter 2 to be array, string given in /path/TS_Scripts/msg_IP_users.php on
 

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
This one should definitely work
PHP:
<?php
$filelocation = "/home/myfile.txt";
$message = "HELLO! YOU ARE ON MY SECRET LIST";
$nicks = [];
$ips = [];

require_once("libraries/TeamSpeak3/TeamSpeak3.php");
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987");
$ts3_VirtualServer->selfUpdate(['client_nickname'=>"MY AWESOME BOT 3000"]);


$handle = fopen($filelocation, "r");
if ($handle) {
    while (($line = fgets($handle)) !== false) {
        $parts = preg_split('/\s+/', $line);
        $nicks[] = $parts[0];
        $ips[] = $parts[1];
    }
    fclose($handle);
}

foreach($ts3_VirtualServer->clientList() as $client) {
    if(in_array($client['client_nickname'], $nicks)) {
        
        $client->message($message);
    } else if (in_array($client['connection_client_ip'], $ips)) {
        $client->message($message);
    }
}
 

Corne

Member
Jan 12, 2016
39
4
40
You are a legend!!! Works like a charm.

Thank you very much! i owe you some beers!
Let me test some more in a real world case and report back
 

Corne

Member
Jan 12, 2016
39
4
40
I had to change my text file to exclude the 1st white space, but after doing that and adding it to cron, everything works perfectly.
Thank you very much for your help. I owe you!

Blessed night further!
 

Corne

Member
Jan 12, 2016
39
4
40
Hi @Nicer
May i ask a addition question?
is it perhaps possible to add the affected users to a group as well? and perhaps remove the users of they are not on the list anymore?
 
Top