Ts3 php framework

tes56 | 2016-12-24 15:49:09 UTC | #1

Witam,
Mam pewien problem z botem do ts3, który jest bazowany na frameworku ts3 php framework. Od czasu do czasu gdy dana osoba wejdzie na serwer wyskakuje taki błąd:

[Dec 24 14:22:56] warning: [WelcomeMessage] ErrorID: 1538
Error Message: invalid parameter
Line: 319
File/opt/ts3phpbot/class/TeamSpeak3/Adapter/ServerQuery/Reply.php

Oto kod odpowiedzialny za wysyłanie wiadomości:

    public static function onClientEnter(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3_Node_Host $host, $AllClientInfo) {
    try {
         $serverData = $host->serverGetSelected();

         $dataArray = array(
            '%VIRTUALSERVER_NAME%' => $serverData['virtualserver_name'],
            '%VIRTUALSERVER_CLIENTSONLINE%' => $serverData['virtualserver_clientsonline'],
            '%VIRTUALSERVER_MAXCLIENTS%' => $serverData['virtualserver_maxclients'],
            '%VIRTUALSERVER_CHANNELSONLINE%' => $serverData['virtualserver_channelsonline'],
            '%VIRTUALSERVER_MIN_CLIENTS_BEFORE_SILENCE%' => $serverData['virtualserver_min_clients_in_channel_before_forced_silence'],
            '%VIRTUALSERVER_VERSION%' => $serverData['virtualserver_version'],
            '%VIRTUALSERVER_CREATED%' => date('r', $serverData['virtualserver_created']),
            '%VIRTUALSERVER_COMPLAIN_AUTO_BAN_COUNT%' => $serverData['virtualserver_complain_autoban_count'],
            '%VIRTUALSERVER_COMPLAIN_AUTO_BAN_TIME%' => $serverData['virtualserver_complain_autoban_time'],
            '%VIRTUALSERVER_COMPLAIN_REMOVE_TIME%' => $serverData['virtualserver_complain_remove_time'],
            '%VIRTUALSERVER_QUERYCLIENTSONLINE%' => $serverData['virtualserver_queryclientsonline'],
            '%VIRTUALSERVER_CONNECTION_PACKETS_SENT_TOTAL%' => $serverData['connection_packets_sent_total'],
            '%VIRTUALSERVER_CONNECTION_BYTES_SENT_TOTAL%' => $serverData['connection_bytes_sent_total'],
            '%VIRTUALSERVER_CONNECTION_PACKETS_RECEIVED_TOTAL%' => $serverData['connection_packets_received_total'],
            '%VIRTUALSERVER_CONNECTION_BYTES_RECEIVED_TOTAL%' => $serverData['connection_bytes_received_total'],
            '%BOT_NAME%' => System_Daemon::getOption('appName'),
            '%BOT_VERSION%' => TS3Bot_Abstract::BOT_VERSION . ' [Build: ' . TS3Bot_Abstract::BOT_BUILD . ']',
            '%CLIENT_CONNECTION_PACKETS_SENT_TOTAL%' => $AllClientInfo['connection_packets_sent_total'],
            '%CLIENT_CONNECTION_BYTES_SENT_TOTAL%' => $AllClientInfo['connection_bytes_sent_total'],
            '%CLIENT_CONNECTION_PACKETS_RECEIVED_TOTAL%' => $AllClientInfo['connection_packets_received_total'],
            '%CLIENT_CONNECTION_BYTES_RECEIVED_TOTAL%' => $AllClientInfo['connection_bytes_received_total'],
            '%CLIENT_NICKNAME%' => $AllClientInfo['client_nickname'],
            '%CLIENT_LASTCONNECTED%' => date('r', $AllClientInfo['client_lastconnected']),
            '%CLIENT_UNIQUE_IDENTIFIER%' => $AllClientInfo['client_unique_identifier']->toString(),
            '%CLIENT_TOTAL_CONNECTIONS%' => $AllClientInfo['client_totalconnections']
                    );
                    $message = str_replace(array_keys($dataArray), array_values($dataArray), ModulesVariable::getWelcomeMessageVal());
                    $AllClientInfo->message(str_replace('', ' ', $message));
                } catch(Exception $e) { 
                    $line = $e->getLine();
                    $code = $e->getCode();
                    $message = $e->getMessage();
                    self::warning("WelcomeMessage", "ErrorID: " . $code . "<br>Error Message: " . $message . "<br>Line: " . $line . "<br>File" . $e->getFile() . "<br>Trace: " . $e->getTrace());
                }
    }

Połączenie z serwerem wygląda tak:

            TeamSpeak3::init();
                    TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryConnected", array("TS3PHPBot", "onConnect"));
            TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyEvent", array("TS3PHPBot", "onEvent"));
            TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyServerselected", array("TS3PHPBot", "onServerSelected"));             
            TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyLogin", array("TS3PHPBot", "onLogin"));
            TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyLogout", array("TS3PHPBot", "onLogout"));
            TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryWaitTimeout", array("TS3PHPBot", "onWaitTimeout"));      
            TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyTextmessage", array("TS3PHPBot", "onTextmessage"));
            TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyCliententerview", array("TS3PHPBot", "onClientEnter"));
            TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyClientleftview", array("TS3PHPBot", "onClientExit"));
            TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyChannelcreated", array("TS3PHPBot", "onChannelCreated"));
            TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyChanneledited", array("TS3PHPBot", "onChannelModified"));
            TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyChanneldeleted", array("TS3PHPBot", "onChannelDeleted"));
            TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyServeredited", array("TS3PHPBot", "onServerModified"));
            TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyClientmoved", array("TS3PHPBot", "onClientMoved"));

            $connectStr = 'serverquery://' . self::$daemonConfig['TEAMSPEAK']['queryIP'] . ':' . self::$daemonConfig['TEAMSPEAK']['queryPort'] . '/';
            $connectStr .= '?nickname=' . urlencode(self::$virtualServerConfig['CONFIG']['nickname']) . '&blocking=0&timeout=1#no_query_clients';
            self::$serverInstance = TeamSpeak3::factory($connectStr);
            self::$serverInstance->login(self::$daemonConfig['TEAMSPEAK']['user'], self::$daemonConfig['TEAMSPEAK']['password']);
            $serverVersion = self::$serverInstance->version();
            if ($serverVersion['build'] < '14468') {
                self::emerg('You are using an outdated TeamSpeak 3 server. At least version 3.0.0-rc1 is required to run this daemon.');
            }
            self::$virtualHost = self::$serverInstance->serverGetByPort(self::$virtualServerConfig['CONFIG']['port']);
            self::$daemonConfig = NULL;
            self::$virtualServerConfig = NULL;
            self::$virtualHost->notifyRegister("server");
            self::$virtualHost->notifyRegister("channel");

            while (!System_Daemon::isDying()) {
                self::iterate();
                self::$serverInstance->getAdapter()->wait();
            }

anon10657637 | 2016-12-24 18:54:18 UTC | #2

To wina języka! Napisz w czymś innym niż w PHP, a będzie śmigało na 100%.


SystemZ | 2016-12-30 17:44:11 UTC | #4

@anon10657637 Skoro PHP jest beee to może polecisz jakąś sprawdzoną bibliotekę do obsługi TS3 na poziomie TS3 framework w innym języku? Z pewnością inni by skorzystali z takiej porady :slight_smile:


Fallen | 2016-12-31 20:07:01 UTC | #5

Java
https://github.com/TheHolyWaffle/TeamSpeak-3-Java-API
C#
https://github.com/nikeee/TeamSpeak3QueryAPI


Szymon | 2016-12-31 20:54:47 UTC | #6

To pierwsze API to chyba przytoczyłeś dla jaj. Co prawda jest to jedyne publiczne API do javy, ale jest niestety z tego gorszego sortu API jakie widziałem. Niestety to API nie zalicza się do API na poziomie TS3 framework.


Fallen | 2016-12-31 21:05:29 UTC | #7

Wiem że nie jest doskonałe ale najbardziej popularne :)
Ale jest jeszcze kilka zamienników
https://www.stefan1200.de/forum/index.php?topic=11.0
oraz
https://github.com/iBotSpeak/iServerQuery


anon10657637 | 2016-12-31 23:43:09 UTC | #8

Nie żeby coś, ale nie porównuj php do Javy. To są dwa odrębne światy.


Szymon | 2017-01-01 00:08:49 UTC | #9

Sam nie lubie php. Mam swoje powody. Patrze na wygode funkcjonalnosci tych api do innych (oczywiscie w tym samym jezyku)


Aylin | 2018-06-17 14:48:53 UTC | #10